Skip to content

Commit

Permalink
fix: fix known issues. fixed #59,fixed #61, fixed #67, fixed #68 [dep…
Browse files Browse the repository at this point in the history
…loy]
  • Loading branch information
vince292007 committed Jul 28, 2024
1 parent b98f9f9 commit 66fd052
Show file tree
Hide file tree
Showing 26 changed files with 163 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
deploy-push-ftp:
name: Deploy Push Ftp
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
if: github.actor != 'dependabot[bot]' && !contains(github.event.head_commit.message, '[skip ci]') && contains(github.event.head_commit.message, '[deploy]')
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 应用标题
VITE_GLOB_APP_TITLE=Vben Admin
VITE_APP_TITLE=Vben Admin

# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
VITE_APP_NAMESPACE=vben-web-antd
4 changes: 2 additions & 2 deletions apps/web-antd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
/>
<!-- 由 vite 注入 VITE_GLOB_APP_TITLE 变量,在 .env 文件内配置 -->
<title><%= VITE_GLOB_APP_TITLE %></title>
<!-- 由 vite 注入 VITE_APP_TITLE 变量,在 .env 文件内配置 -->
<title><%= VITE_APP_TITLE %></title>
<link rel="icon" href="/favicon.ico" />
<script>
// 生产环境下注入百度统计
Expand Down
6 changes: 0 additions & 6 deletions apps/web-antd/src/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { useAppConfig } from '@vben/hooks';
import { defineOverridesPreferences } from '@vben/preferences';

const { appTitle } = useAppConfig(import.meta.env, import.meta.env.PROD);

/**
* @description 项目配置文件
* 只需要覆盖项目中的一部分配置,不需要的配置不用覆盖,会自动使用默认配置
*/
export const overridesPreferences = defineOverridesPreferences({
// overrides
app: {
name: appTitle,
},
});
18 changes: 2 additions & 16 deletions apps/web-antd/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import {
defaultImportmapOptions,
defineConfig,
getDefaultPwaOptions,
loadAndConvertEnv,
} from '@vben/vite-config';
import { defineConfig } from '@vben/vite-config';

export default defineConfig(async () => {
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
return {
application: {
...envConfig,
importmap: false,
importmapOptions: defaultImportmapOptions,
pwa: false,
pwaOptions: getDefaultPwaOptions(appTitle),
},
application: {},
vite: {
base,
server: {
port,
proxy: {
'/api': {
changeOrigin: true,
Expand Down
7 changes: 7 additions & 0 deletions internal/vite-config/src/config/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { findMonorepoRoot } from '@vben/node-utils';

import { defineConfig, loadEnv, mergeConfig } from 'vite';

import { getDefaultPwaOptions } from '../options';
import { loadApplicationPlugins } from '../plugins';
import { loadAndConvertEnv } from '../utils/env';
import { getCommonConfig } from './common';

function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
return defineConfig(async (config) => {
const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv();
const options = await userConfigPromise?.(config);
const { command, mode } = config;
const { application = {}, vite = {} } = options || {};
Expand Down Expand Up @@ -40,12 +43,15 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
'Vben Admin Docs': 'https://docs.vben.pro',
},
pwa: true,
pwaOptions: getDefaultPwaOptions(appTitle),
...envConfig,
...application,
});

const { injectGlobalScss = true } = application;

const applicationConfig: UserConfig = {
base,
build: {
rollupOptions: {
output: {
Expand All @@ -69,6 +75,7 @@ function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) {
plugins,
server: {
host: true,
port,
warmup: {
// 预热文件
clientFiles: ['./index.html', './src/{views,layouts}/*'],
Expand Down
2 changes: 1 addition & 1 deletion internal/vite-config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getDefaultPwaOptions = (name: string): Partial<PwaPluginOptions> => ({
const defaultImportmapOptions: ImportmapPluginOptions = {
// 通过 Importmap CDN 方式引入,
// 目前只有esm.sh源兼容性好一点,jspm.io对于 esm 入口要求高
defaultProvider: 'esm.sh',
defaultProvider: 'jspm.io',
importmap: [
{ name: 'vue' },
{ name: 'pinia' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@
</style>
<div class="loading" id="__app-loading__">
<span class="dot dot-spin"><i></i><i></i><i></i><i></i></span>
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
<div class="title"><%= VITE_APP_TITLE %></div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@
</style>
<div class="loading" id="__app-loading__">
<div class="loader"></div>
<div class="title"><%= VITE_GLOB_APP_TITLE %></div>
<div class="title"><%= VITE_APP_TITLE %></div>
</div>
4 changes: 2 additions & 2 deletions internal/vite-config/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ async function loadAndConvertEnv(
> {
const envConfig = await loadEnv(match, confFiles);
const {
VITE_APP_TITLE,
VITE_BASE,
VITE_COMPRESS,
VITE_DEVTOOLS,
VITE_GLOB_APP_TITLE,
VITE_INJECT_APP_LOADING,
VITE_NITRO_MOCK,
VITE_PORT,
Expand All @@ -80,7 +80,7 @@ async function loadAndConvertEnv(
.filter((item) => item === 'brotli' || item === 'gzip');

return {
appTitle: VITE_GLOB_APP_TITLE ?? 'Vben Admin',
appTitle: VITE_APP_TITLE ?? 'Vben Admin',
base: VITE_BASE || '/',
compress: !!compress,
compressTypes: compressTypes as ('brotli' | 'gzip')[],
Expand Down
14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@
"build:analyze": "turbo build:analyze",
"build:docker": "./build-local-docker-image.sh",
"changeset": "pnpm exec changeset",
"check": "pnpm run check:dep && pnpm run check:circular && pnpm run check:type && pnpm run check:cspell",
"check": "pnpm run check:circular && pnpm run check:dep && pnpm run check:type",
"check:circular": "vsh check-circular",
"check:cspell": "cspell lint \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress",
"check:dep": "vsh check-dep",
"check:type": "turbo run typecheck",
"clean": "vsh clean",
"commit": "czg",
"dev": "cross-env TURBO_UI=1 turbo run dev",
"dev": "cross-env turbo run dev",
"dev:docs": "pnpm -F @vben/website run docs:dev",
"format": "vsh lint --format",
"lint": "vsh lint",
Expand All @@ -56,7 +55,7 @@
"@changesets/cli": "^2.27.7",
"@ls-lint/ls-lint": "^2.2.3",
"@types/jsdom": "^21.1.7",
"@types/node": "^20.14.12",
"@types/node": "^22.0.0",
"@vben/commitlint-config": "workspace:*",
"@vben/eslint-config": "workspace:*",
"@vben/lint-staged-config": "workspace:*",
Expand Down Expand Up @@ -95,11 +94,6 @@
"canvas",
"node-gyp",
"playwright"
],
"updateConfig": {
"ignoreDependencies": [
"zx"
]
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function handleClick(path?: string) {
>
<li>
<a href="javascript:void 0" @click.stop="handleClick(item.path)">
<span class="flex-center h-full">
<span class="flex-center z-10 h-full">
<VbenIcon
v-if="item.icon && showIcon"
:icon="item.icon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { cn } from '@vben-core/toolkit';
interface Props {
class?: HTMLAttributes['class'];
horizontal?: boolean;
scrollBarClass?: HTMLAttributes['class'];
shadow?: boolean;
shadowBorder?: boolean;
}
Expand Down Expand Up @@ -58,7 +59,11 @@ function handleScroll(event: Event) {
}"
class="scrollbar-bottom-shadow pointer-events-none absolute bottom-0 z-10 h-12 w-full opacity-0 transition-opacity duration-300 ease-in-out will-change-[opacity]"
></div>
<ScrollBar v-if="horizontal" orientation="horizontal" />
<ScrollBar
v-if="horizontal"
:class="scrollBarClass"
orientation="horizontal"
/>
</ScrollArea>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ function scrollIntoView() {

<template>
<div :style="style" class="tabs-chrome size-full flex-1 overflow-hidden pt-1">
<VbenScrollbar class="tabs-chrome__scrollbar h-full" horizontal>
<VbenScrollbar
class="tabs-chrome__scrollbar h-full"
horizontal
scroll-bar-class="z-10"
>
<!-- footer -> 4px -->
<div
ref="contentRef"
Expand Down
6 changes: 5 additions & 1 deletion packages/@core/ui-kit/tabs-ui/src/components/tabs/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ function scrollIntoView() {

<template>
<div class="h-full flex-1 overflow-hidden">
<VbenScrollbar class="tabs-scrollbar h-full" horizontal>
<VbenScrollbar
class="tabs-scrollbar h-full"
horizontal
scroll-bar-class="z-10"
>
<div
:class="contentClass"
class="relative !flex h-full w-max items-center"
Expand Down
12 changes: 10 additions & 2 deletions packages/@core/ui-kit/tabs-ui/src/tabs-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ async function initTabsSortable() {
const el = document.querySelectorAll(`.${contentClass}`)?.[0] as HTMLElement;
const resetElState = () => {
el.style.cursor = 'default';
el.classList.remove('dragging');
};
const { initializeSortable } = useSortable(el, {
filter: (_evt, target: HTMLElement) => {
const parent = findParentElement(target);
Expand All @@ -57,16 +62,20 @@ async function initTabsSortable() {
const { srcElement } = (evt as any).originalEvent;
if (!srcElement) {
resetElState();
return;
}
const srcParent = findParentElement(srcElement);
if (!srcParent) {
resetElState();
return;
}
if (!srcParent.classList.contains('dragable')) {
resetElState();
return;
}
Expand All @@ -79,8 +88,7 @@ async function initTabsSortable() {
) {
emit('sortTabs', oldIndex, newIndex);
}
el.classList.remove('dragging');
el.style.cursor = 'default';
resetElState();
},
onMove(evt) {
const parent = findParentElement(evt.related);
Expand Down
3 changes: 1 addition & 2 deletions packages/effects/hooks/src/use-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export function useAppConfig(
? window._VBEN_ADMIN_PRO_APP_CONF_
: (env as VbenAdminProAppConfigRaw);

const { VITE_GLOB_API_URL, VITE_GLOB_APP_TITLE } = config;
const { VITE_GLOB_API_URL } = config;

return {
apiURL: VITE_GLOB_API_URL,
appTitle: VITE_GLOB_APP_TITLE,
};
}
11 changes: 8 additions & 3 deletions packages/stores/src/modules/tabbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {
} else {
// 页面已经存在,不重复添加选项卡,只更新选项卡参数
const currentTab = toRaw(this.tabs)[tabIndex];
this.tabs.splice(tabIndex, 1, { ...currentTab, ...tab });
if (!currentTab.meta.affixTab) {
const mergedTab = { ...currentTab, ...tab };
this.tabs.splice(tabIndex, 1, mergedTab);
}
}
this.updateCacheTab();
},
Expand Down Expand Up @@ -269,7 +272,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {
);
if (index !== -1) {
tab.meta.affixTab = true;
this.addTab(tab);
// this.addTab(tab);
this.tabs.splice(index, 1, tab);
}
},

Expand Down Expand Up @@ -369,7 +373,8 @@ export const useCoreTabbarStore = defineStore('core-tabbar', {

if (index !== -1) {
tab.meta.affixTab = false;
this.addTab(tab);
// this.addTab(tab);
this.tabs.splice(index, 1, tab);
}
},

Expand Down
2 changes: 0 additions & 2 deletions packages/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ declare module 'vue-router' {

export interface VbenAdminProAppConfigRaw {
VITE_GLOB_API_URL: string;
VITE_GLOB_APP_TITLE: string;
}

export interface ApplicationConfig {
apiURL: string;
appTitle: string;
}

declare global {
Expand Down
Loading

0 comments on commit 66fd052

Please sign in to comment.