From cd10eb947128da454fada58c86d8653113cbb84a Mon Sep 17 00:00:00 2001 From: vben Date: Mon, 29 Jul 2024 22:11:22 +0800 Subject: [PATCH] feat: Regular monitoring page update [deploy] --- .gitignore | 1 + .stylelintignore | 1 + apps/web-antd/.env.production | 2 +- apps/web-antd/src/app.vue | 15 +- apps/web-antd/src/layouts/basic.vue | 8 +- .../src/router/routes/modules/vben.ts | 4 +- cspell.json | 3 +- .../lint-configs/eslint-config/package.json | 2 +- .../eslint-config/src/custom-config.ts | 11 +- .../stylelint-config/package.json | 2 +- internal/tailwind-config/package.json | 2 +- .../vite-config/src/config/application.ts | 2 +- internal/vite-config/src/config/library.ts | 2 +- internal/vite-config/src/options.ts | 2 +- internal/vite-config/src/plugins/index.ts | 4 - packages/@core/preferences/src/config.ts | 4 +- packages/@core/preferences/src/types.ts | 4 + .../src/global-provider/global-provider.vue | 9 - .../common-ui/src/global-provider/index.ts | 1 - packages/effects/common-ui/src/index.ts | 1 - .../effects/hooks/src/use-design-tokens.ts | 83 +++---- packages/effects/layouts/src/basic/layout.vue | 10 +- .../widgets/check-updates/check-updates.vue | 126 ++++++++++ .../src/widgets/check-updates/index.ts | 1 + packages/effects/layouts/src/widgets/index.ts | 1 + .../preferences/blocks/general/general.vue | 4 + .../widgets/preferences/preferences-sheet.vue | 2 + packages/locales/src/langs/en-US.json | 3 + packages/locales/src/langs/zh-CN.json | 3 + pnpm-lock.yaml | 138 +++++++---- website/.vitepress/config.mts | 231 ++++++++++-------- website/.vitepress/theme/index.ts | 7 +- website/.vitepress/theme/plugins/hm.ts | 28 +++ website/package.json | 1 + website/src/guide/essentials/settings.md | 8 +- website/src/guide/other/faq.md | 20 +- website/tsconfig.json | 6 + 37 files changed, 491 insertions(+), 261 deletions(-) delete mode 100644 packages/effects/common-ui/src/global-provider/global-provider.vue delete mode 100644 packages/effects/common-ui/src/global-provider/index.ts create mode 100644 packages/effects/layouts/src/widgets/check-updates/check-updates.vue create mode 100644 packages/effects/layouts/src/widgets/check-updates/index.ts create mode 100644 website/.vitepress/theme/plugins/hm.ts create mode 100644 website/tsconfig.json diff --git a/.gitignore b/.gitignore index 5a0a7a7c..3787c523 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ coverage **/.vitepress/cache .cache .turbo +.temp dev-dist .stylelintcache yarn.lock diff --git a/.stylelintignore b/.stylelintignore index f4b2db2c..3c28ee32 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -2,3 +2,4 @@ dist public __tests__ coverage +ui-kit diff --git a/apps/web-antd/.env.production b/apps/web-antd/.env.production index 37947069..8f979f58 100644 --- a/apps/web-antd/.env.production +++ b/apps/web-antd/.env.production @@ -7,7 +7,7 @@ VITE_GLOB_API_URL=https://mock-napi.vben.pro/api VITE_COMPRESS=none # 是否开启 PWA -VITE_PWA=false +VITE_PWA=true # vue-router 的模式 VITE_ROUTER_HISTORY=hash diff --git a/apps/web-antd/src/app.vue b/apps/web-antd/src/app.vue index 39f319cb..057dd581 100644 --- a/apps/web-antd/src/app.vue +++ b/apps/web-antd/src/app.vue @@ -1,7 +1,6 @@ diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 5c92f3f3..e7259eca 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -3,7 +3,7 @@ import { computed, ref } from 'vue'; import { useRouter } from 'vue-router'; import { AuthenticationLoginExpiredModal } from '@vben/common-ui'; -import { LOGIN_PATH } from '@vben/constants'; +import { LOGIN_PATH, VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants'; import { BookOpenText, CircleHelp, MdiGithub } from '@vben/icons'; import { BasicLayout, @@ -57,7 +57,7 @@ const showDot = computed(() => const menus = computed(() => [ { handler: () => { - openWindow('https://github.com/vbenjs/vue-vben-admin', { + openWindow(VBEN_DOC_URL, { target: '_blank', }); }, @@ -66,7 +66,7 @@ const menus = computed(() => [ }, { handler: () => { - openWindow('https://github.com/vbenjs/vue-vben-admin', { + openWindow(VBEN_GITHUB_URL, { target: '_blank', }); }, @@ -75,7 +75,7 @@ const menus = computed(() => [ }, { handler: () => { - openWindow('https://github.com/vbenjs/vue-vben-admin/issues', { + openWindow(`${VBEN_GITHUB_URL}/issues`, { target: '_blank', }); }, diff --git a/apps/web-antd/src/router/routes/modules/vben.ts b/apps/web-antd/src/router/routes/modules/vben.ts index 2d1fdf24..7df7268b 100644 --- a/apps/web-antd/src/router/routes/modules/vben.ts +++ b/apps/web-antd/src/router/routes/modules/vben.ts @@ -1,6 +1,6 @@ import type { RouteRecordRaw } from 'vue-router'; -import { VBEN_GITHUB_URL, VBEN_LOGO_URL } from '@vben/constants'; +import { VBEN_DOC_URL, VBEN_GITHUB_URL, VBEN_LOGO_URL } from '@vben/constants'; import { BasicLayout, IFrameView } from '#/layouts'; import { $t } from '#/locales'; @@ -35,7 +35,7 @@ const routes: RouteRecordRaw[] = [ component: IFrameView, meta: { icon: 'lucide:book-open-text', - iframeSrc: 'https://doc.vvbin.cn/', + iframeSrc: VBEN_DOC_URL, keepAlive: true, title: $t('page.vben.document'), }, diff --git a/cspell.json b/cspell.json index 90b58f11..0a638775 100644 --- a/cspell.json +++ b/cspell.json @@ -42,7 +42,8 @@ "ependencies", "vite", "echarts", - "sortablejs" + "sortablejs", + "etag" ], "ignorePaths": [ "**/node_modules/**", diff --git a/internal/lint-configs/eslint-config/package.json b/internal/lint-configs/eslint-config/package.json index ea42b94a..73cd2839 100644 --- a/internal/lint-configs/eslint-config/package.json +++ b/internal/lint-configs/eslint-config/package.json @@ -39,7 +39,7 @@ "eslint": "^9.8.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-jsdoc": "^48.8.3", + "eslint-plugin-jsdoc": "^48.9.2", "eslint-plugin-jsonc": "^2.16.0", "eslint-plugin-n": "^17.10.1", "eslint-plugin-no-only-tests": "^3.1.0", diff --git a/internal/lint-configs/eslint-config/src/custom-config.ts b/internal/lint-configs/eslint-config/src/custom-config.ts index d871d8bc..14e56202 100644 --- a/internal/lint-configs/eslint-config/src/custom-config.ts +++ b/internal/lint-configs/eslint-config/src/custom-config.ts @@ -43,11 +43,6 @@ const customConfig: Linter.FlatConfig[] = [ message: 'The #/stores package cannot be imported, please use the @core package itself', }, - { - group: ['#/forward/*'], - message: - 'The #/forward package cannot be imported, please use the @core package itself', - }, ], }, ], @@ -99,6 +94,9 @@ const customConfig: Linter.FlatConfig[] = [ 'packages/icons/**/**', 'packages/constants/**/**', 'packages/styles/**/**', + 'packages/stores/**/**', + 'packages/preferences/**/**', + 'packages/locales/**/**', ], ignores: restrictedImportIgnores, rules: { @@ -118,11 +116,12 @@ const customConfig: Linter.FlatConfig[] = [ }, // 后端模拟代码,不需要太多规则 { - files: ['apps/backend-mock/**/**'], + files: ['apps/backend-mock/**/**', 'website/**/**'], rules: { '@typescript-eslint/no-extraneous-class': 'off', 'n/no-extraneous-import': 'off', 'n/prefer-global/buffer': 'off', + 'n/prefer-global/process': 'off', 'no-console': 'off', 'unicorn/prefer-module': 'off', }, diff --git a/internal/lint-configs/stylelint-config/package.json b/internal/lint-configs/stylelint-config/package.json index 15c310a3..a244d657 100644 --- a/internal/lint-configs/stylelint-config/package.json +++ b/internal/lint-configs/stylelint-config/package.json @@ -37,7 +37,7 @@ "postcss-html": "^1.7.0", "postcss-scss": "^4.0.9", "prettier": "^3.3.3", - "stylelint": "^16.7.0", + "stylelint": "^16.8.0", "stylelint-config-recommended": "^14.0.1", "stylelint-config-recommended-scss": "^14.1.0", "stylelint-config-recommended-vue": "^1.5.0", diff --git a/internal/tailwind-config/package.json b/internal/tailwind-config/package.json index 9db41ff5..40add28e 100644 --- a/internal/tailwind-config/package.json +++ b/internal/tailwind-config/package.json @@ -46,7 +46,7 @@ "tailwindcss": "^3.4.3" }, "dependencies": { - "@iconify/json": "^2.2.231", + "@iconify/json": "^2.2.232", "@iconify/tailwind": "^1.1.2", "@tailwindcss/nesting": "0.0.0-insiders.565cd3e", "@tailwindcss/typography": "^0.5.13", diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index 46b01bdc..11771345 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -13,7 +13,7 @@ import { loadApplicationPlugins } from '../plugins'; import { loadAndConvertEnv } from '../utils/env'; import { getCommonConfig } from './common'; -function defineApplicationConfig(userConfigPromise: DefineApplicationOptions) { +function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) { return defineConfig(async (config) => { const { appTitle, base, port, ...envConfig } = await loadAndConvertEnv(); const options = await userConfigPromise?.(config); diff --git a/internal/vite-config/src/config/library.ts b/internal/vite-config/src/config/library.ts index f56248db..931babdb 100644 --- a/internal/vite-config/src/config/library.ts +++ b/internal/vite-config/src/config/library.ts @@ -9,7 +9,7 @@ import { defineConfig, mergeConfig } from 'vite'; import { loadLibraryPlugins } from '../plugins'; import { getCommonConfig } from './common'; -function defineLibraryConfig(userConfigPromise: DefineLibraryOptions) { +function defineLibraryConfig(userConfigPromise?: DefineLibraryOptions) { return defineConfig(async (config: ConfigEnv) => { const options = await userConfigPromise?.(config); const { command, mode } = config; diff --git a/internal/vite-config/src/options.ts b/internal/vite-config/src/options.ts index 23f4ac0e..2c3bd59e 100644 --- a/internal/vite-config/src/options.ts +++ b/internal/vite-config/src/options.ts @@ -20,7 +20,7 @@ const getDefaultPwaOptions = (name: string): Partial => ({ type: 'image/png', }, ], - name: `${name}o${isDevelopment ? ' dev' : ''}`, + name: `${name}${isDevelopment ? ' dev' : ''}`, short_name: `${name}${isDevelopment ? ' dev' : ''}`, }, }); diff --git a/internal/vite-config/src/plugins/index.ts b/internal/vite-config/src/plugins/index.ts index e50f0e70..8d8d6745 100644 --- a/internal/vite-config/src/plugins/index.ts +++ b/internal/vite-config/src/plugins/index.ts @@ -150,10 +150,6 @@ async function loadApplicationPlugins( condition: pwa, plugins: () => VitePWA({ - devOptions: { - enabled: true, - type: 'module', - }, injectRegister: false, workbox: { globPatterns: [], diff --git a/packages/@core/preferences/src/config.ts b/packages/@core/preferences/src/config.ts index 90685eea..68f7d555 100644 --- a/packages/@core/preferences/src/config.ts +++ b/packages/@core/preferences/src/config.ts @@ -4,6 +4,7 @@ const defaultPreferences: Preferences = { app: { accessMode: 'frontend', authPageLayout: 'panel-right', + checkUpdatesPollingTime: 1, colorGrayMode: false, colorWeakMode: false, compact: false, @@ -11,6 +12,7 @@ const defaultPreferences: Preferences = { defaultAvatar: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/avatar-v1.webp', dynamicTitle: true, + enableCheckUpdates: true, enablePreferences: true, isMobile: false, layout: 'sidebar-nav', @@ -27,7 +29,7 @@ const defaultPreferences: Preferences = { styleType: 'normal', }, copyright: { - companyName: 'Vben Admin', + companyName: 'Vben', companySiteLink: 'https://www.vben.pro', date: '2024', enable: true, diff --git a/packages/@core/preferences/src/types.ts b/packages/@core/preferences/src/types.ts index e71d49a5..fc58415c 100644 --- a/packages/@core/preferences/src/types.ts +++ b/packages/@core/preferences/src/types.ts @@ -21,6 +21,8 @@ interface AppPreferences { accessMode: AccessModeType; /** 登录注册页面布局 */ authPageLayout: AuthPageLayoutType; + /** 检查更新轮询时间 */ + checkUpdatesPollingTime: number; /** 是否开启灰色模式 */ colorGrayMode: boolean; /** 是否开启色弱模式 */ @@ -33,6 +35,8 @@ interface AppPreferences { defaultAvatar: string; // /** 开启动态标题 */ dynamicTitle: boolean; + /** 是否开启检查更新 */ + enableCheckUpdates: boolean; /** 是否显示偏好设置 */ enablePreferences: boolean; /** 是否移动端 */ diff --git a/packages/effects/common-ui/src/global-provider/global-provider.vue b/packages/effects/common-ui/src/global-provider/global-provider.vue deleted file mode 100644 index b9eb1fc2..00000000 --- a/packages/effects/common-ui/src/global-provider/global-provider.vue +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/packages/effects/common-ui/src/global-provider/index.ts b/packages/effects/common-ui/src/global-provider/index.ts deleted file mode 100644 index 7d01dc8b..00000000 --- a/packages/effects/common-ui/src/global-provider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as GlobalProvider } from './global-provider.vue'; diff --git a/packages/effects/common-ui/src/index.ts b/packages/effects/common-ui/src/index.ts index b729d103..753baaa6 100644 --- a/packages/effects/common-ui/src/index.ts +++ b/packages/effects/common-ui/src/index.ts @@ -2,5 +2,4 @@ export * from './about'; export * from './authentication'; export * from './dashboard'; export * from './fallback'; -export * from './global-provider'; export { useToast } from '@vben-core/shadcn-ui'; diff --git a/packages/effects/hooks/src/use-design-tokens.ts b/packages/effects/hooks/src/use-design-tokens.ts index eeaa14e3..3fc33da3 100644 --- a/packages/effects/hooks/src/use-design-tokens.ts +++ b/packages/effects/hooks/src/use-design-tokens.ts @@ -1,23 +1,25 @@ -import { computed, ref, watch } from 'vue'; +import { reactive, watch } from 'vue'; import { preferences } from '@vben/preferences'; export function useDesignTokens() { const rootStyles = getComputedStyle(document.documentElement); - const colorPrimary = ref(''); - const colorError = ref(''); - const colorSuccess = ref(''); - const colorWarning = ref(''); - const colorInfo = ref(''); - const colorBgBase = ref(''); - const colorTextBase = ref(''); - const colorBgContainer = ref(''); - const colorBgElevated = ref(''); - const colorBgLayout = ref(''); - const colorBgMask = ref(''); - const colorBorder = ref(''); - const borderRadius = ref(''); + const antDesignTokens = reactive({ + borderRadius: '' as any, + colorBgBase: '', + colorBgContainer: '', + colorBgElevated: '', + colorBgLayout: '', + colorBgMask: '', + colorBorder: '', + colorError: '', + colorInfo: '', + colorPrimary: '', + colorSuccess: '', + colorTextBase: '', + colorWarning: '', + }); const getCssVariableValue = (variable: string, isColor: boolean = true) => { const value = rootStyles.getPropertyValue(variable); @@ -27,52 +29,23 @@ export function useDesignTokens() { watch( () => preferences.theme, () => { - colorInfo.value = colorPrimary.value = getCssVariableValue('--primary'); - colorError.value = getCssVariableValue('--destructive'); - colorWarning.value = getCssVariableValue('--warning'); - colorSuccess.value = getCssVariableValue('--success'); - colorBgBase.value = getCssVariableValue('--background'); - colorBgLayout.value = getCssVariableValue('--background-deep'); - colorBgMask.value = getCssVariableValue('--overlay'); - colorBorder.value = getCssVariableValue('--border'); - colorTextBase.value = getCssVariableValue('--foreground'); - colorBgElevated.value = getCssVariableValue('--popover'); - colorBgContainer.value = getCssVariableValue('--card'); - borderRadius.value = getCssVariableValue('--radius', false); + antDesignTokens.colorPrimary = getCssVariableValue('--primary'); + antDesignTokens.colorError = getCssVariableValue('--destructive'); + antDesignTokens.colorWarning = getCssVariableValue('--warning'); + antDesignTokens.colorSuccess = getCssVariableValue('--success'); + antDesignTokens.colorBgBase = getCssVariableValue('--background'); + antDesignTokens.colorBgLayout = getCssVariableValue('--background-deep'); + antDesignTokens.colorBgMask = getCssVariableValue('--overlay'); + antDesignTokens.colorBorder = getCssVariableValue('--border'); + antDesignTokens.colorTextBase = getCssVariableValue('--foreground'); + antDesignTokens.colorBgElevated = getCssVariableValue('--popover'); + antDesignTokens.colorBgContainer = getCssVariableValue('--card'); + antDesignTokens.borderRadius = getCssVariableValue('--radius', false); }, { immediate: true }, ); - const antDesignTokens = computed(() => { - return { - borderRadius: borderRadius.value, - colorBgBase: colorBgBase.value, - colorBgContainer: colorBgContainer.value, - colorBgElevated: colorBgElevated.value, - colorBgLayout: colorBgLayout.value, - colorBgMask: colorBgMask.value, - colorBorder: colorBorder.value, - colorError: colorError.value, - colorInfo: colorInfo.value, - colorPrimary: colorPrimary.value, - colorSuccess: colorSuccess.value, - colorTextBase: colorTextBase.value, - colorWarning: colorWarning.value, - }; - }); - return { antDesignTokens, - borderRadius, - colorBgBase, - colorBgContainer, - colorBgElevated, - colorBorder, - colorError, - colorInfo, - colorPrimary, - colorSuccess, - colorTextBase, - colorWarning, }; } diff --git a/packages/effects/layouts/src/basic/layout.vue b/packages/effects/layouts/src/basic/layout.vue index 3445ed4f..31da64da 100644 --- a/packages/effects/layouts/src/basic/layout.vue +++ b/packages/effects/layouts/src/basic/layout.vue @@ -12,9 +12,9 @@ import { useCoreAccessStore, useCoreLockStore } from '@vben/stores'; import { MenuRecordRaw } from '@vben/types'; import { mapTree } from '@vben/utils'; import { VbenAdminLayout } from '@vben-core/layout-ui'; -import { VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui'; +import { Toaster, VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui'; -import { Breadcrumb, Preferences } from '../widgets'; +import { Breadcrumb, CheckUpdates, Preferences } from '../widgets'; import { LayoutContent } from './content'; import { Copyright } from './copyright'; import { LayoutFooter } from './footer'; @@ -310,6 +310,12 @@ watch(