diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index d6e237bf..5498103f 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -4,6 +4,7 @@ - 新增`headerTitle` slot - 新增打印示例 +- 新增关于界面 ### ✨ Refactor @@ -15,6 +16,7 @@ - 确保面包屑正确的显示图标 - 修复 tinymce 上传按钮全屏模式下消失问题 +- 确保 title 在重新登录后正常改变 ## 2.1.1 (2021-03-26) diff --git a/src/components/Table/src/BasicTable.vue b/src/components/Table/src/BasicTable.vue index 55492ad2..176458af 100644 --- a/src/components/Table/src/BasicTable.vue +++ b/src/components/Table/src/BasicTable.vue @@ -185,7 +185,7 @@ } = useTableForm(getProps, slots, fetch); const getBindValues = computed(() => { - const dataSource = toRaw(unref(getDataSourceRef)); + const dataSource = unref(getDataSourceRef); let propsData: Recordable = { size: 'middle', // ...(dataSource.length === 0 ? { getPopupContainer: () => document.body } : {}), diff --git a/src/components/Table/src/hooks/useTable.ts b/src/components/Table/src/hooks/useTable.ts index b481be25..57edd2bb 100644 --- a/src/components/Table/src/hooks/useTable.ts +++ b/src/components/Table/src/hooks/useTable.ts @@ -17,7 +17,12 @@ type UseTableMethod = TableActionType & { export function useTable( tableProps?: Props -): [(instance: TableActionType, formInstance: UseTableMethod) => void, TableActionType] { +): [ + (instance: TableActionType, formInstance: UseTableMethod) => void, + TableActionType & { + getForm: () => FormActionType; + } +] { const tableRef = ref>(null); const loadedRef = ref>(false); const formRef = ref>(null); diff --git a/src/hooks/web/useTitle.ts b/src/hooks/web/useTitle.ts index b4a20455..7566ce50 100644 --- a/src/hooks/web/useTitle.ts +++ b/src/hooks/web/useTitle.ts @@ -1,22 +1,29 @@ +import { watch, unref } from 'vue'; import { useI18n } from '/@/hooks/web/useI18n'; import { useTitle as usePageTitle } from '@vueuse/core'; import { useGlobSetting } from '/@/hooks/setting'; +import { useRouter } from 'vue-router'; import { REDIRECT_NAME } from '/@/router/constant'; -import { listenerRouteChange } from '/@/logics/mitt/routeChange'; export function useTitle() { const { title } = useGlobSetting(); const { t } = useI18n(); + const { currentRoute } = useRouter(); const pageTitle = usePageTitle(); - listenerRouteChange((route) => { - if (route.name === REDIRECT_NAME) { - return; - } + watch( + () => currentRoute.value.path, + () => { + const route = unref(currentRoute); + if (route.name === REDIRECT_NAME) { + return; + } - const tTitle = t(route?.meta?.title as string); - pageTitle.value = tTitle ? ` ${tTitle} - ${title} ` : `${title}`; - }); + const tTitle = t(route?.meta?.title as string); + pageTitle.value = tTitle ? ` ${tTitle} - ${title} ` : `${title}`; + }, + { immediate: true } + ); } diff --git a/src/locales/lang/en/routes/dashboard.ts b/src/locales/lang/en/routes/dashboard.ts index bb1845ea..6d047b57 100644 --- a/src/locales/lang/en/routes/dashboard.ts +++ b/src/locales/lang/en/routes/dashboard.ts @@ -1,6 +1,6 @@ export default { dashboard: 'Dashboard', - welcome: 'Home', + about: 'About', workbench: 'Workbench', analysis: 'Analysis', }; diff --git a/src/locales/lang/zh_CN/routes/dashboard.ts b/src/locales/lang/zh_CN/routes/dashboard.ts index 6e93cced..04b1b197 100644 --- a/src/locales/lang/zh_CN/routes/dashboard.ts +++ b/src/locales/lang/zh_CN/routes/dashboard.ts @@ -1,6 +1,6 @@ export default { dashboard: 'Dashboard', - welcome: '首页', + about: '关于', workbench: '工作台', analysis: '分析页', }; diff --git a/src/router/menus/modules/about.ts b/src/router/menus/modules/about.ts new file mode 100644 index 00000000..1c36b37d --- /dev/null +++ b/src/router/menus/modules/about.ts @@ -0,0 +1,11 @@ +import type { MenuModule } from '/@/router/types'; +import { t } from '/@/hooks/web/useI18n'; + +const about: MenuModule = { + orderNo: 100000, + menu: { + path: '/about/index', + name: t('routes.dashboard.about'), + }, +}; +export default about; diff --git a/src/router/menus/modules/home.ts b/src/router/menus/modules/home.ts deleted file mode 100644 index b58536bd..00000000 --- a/src/router/menus/modules/home.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { MenuModule } from '/@/router/types'; -import { t } from '/@/hooks/web/useI18n'; - -const menu: MenuModule = { - orderNo: 0, - menu: { - path: '/home/welcome', - name: t('routes.dashboard.welcome'), - }, -}; -export default menu; diff --git a/src/router/routes/modules/about.ts b/src/router/routes/modules/about.ts new file mode 100644 index 00000000..897a4264 --- /dev/null +++ b/src/router/routes/modules/about.ts @@ -0,0 +1,28 @@ +import type { AppRouteModule } from '/@/router/types'; + +import { LAYOUT } from '/@/router/constant'; +import { t } from '/@/hooks/web/useI18n'; + +const dashboard: AppRouteModule = { + path: '/about', + name: 'About', + component: LAYOUT, + redirect: '/about/index', + meta: { + icon: 'simple-icons:about-dot-me', + title: t('routes.dashboard.about'), + }, + children: [ + { + path: 'index', + name: 'AboutPage', + component: () => import('/@/views/sys/about/index.vue'), + meta: { + title: t('routes.dashboard.about'), + icon: 'simple-icons:about-dot-me', + }, + }, + ], +}; + +export default dashboard; diff --git a/src/router/routes/modules/home.ts b/src/router/routes/modules/home.ts deleted file mode 100644 index 0fa86141..00000000 --- a/src/router/routes/modules/home.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { AppRouteModule } from '/@/router/types'; - -import { LAYOUT } from '/@/router/constant'; -import { t } from '/@/hooks/web/useI18n'; - -const dashboard: AppRouteModule = { - path: '/home', - name: 'Home', - component: LAYOUT, - redirect: '/home/welcome', - meta: { - icon: 'ion:home-outline', - title: t('routes.dashboard.welcome'), - }, - children: [ - { - path: 'welcome', - name: 'Welcome', - component: () => import('/@/views/dashboard/welcome/index.vue'), - meta: { - title: t('routes.dashboard.welcome'), - affix: true, - icon: 'bx:bx-home', - }, - }, - ], -}; - -export default dashboard; diff --git a/src/views/demo/table/FormTable.vue b/src/views/demo/table/FormTable.vue index f92ba8b8..71b683b1 100644 --- a/src/views/demo/table/FormTable.vue +++ b/src/views/demo/table/FormTable.vue @@ -1,6 +1,10 @@ diff --git a/types/global.d.ts b/types/global.d.ts index 9862bb4d..07a8f354 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -10,6 +10,16 @@ declare global { declare interface Window { // Global vue app instance __APP__: App; + + __APP_INFO__: { + pkg: { + name: string; + version: string; + dependencies: Recordable; + devDependencies: Recordable; + }; + lastBuildTime: string; + }; } // vue diff --git a/vite.config.ts b/vite.config.ts index 2934a944..e912925b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,6 +9,13 @@ import { createAlias } from './build/vite/alias'; import { wrapperEnv } from './build/utils'; import { createVitePlugins } from './build/vite/plugin'; import { OUTPUT_DIR } from './build/constant'; +import pkg from './package.json'; +import moment from 'moment'; + +const APP_INFO = { + pkg, + lastBuildTime: moment().format('YYYY-MM-DD HH:mm:ss'), +}; export default ({ command, mode }: ConfigEnv): UserConfig => { const root = process.cwd(); @@ -58,6 +65,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { __VUE_I18N_LEGACY_API__: false, __VUE_I18N_FULL_INSTALL__: false, __INTLIFY_PROD_DEVTOOLS__: false, + + __APP_INFO__: JSON.stringify(APP_INFO), }, css: { preprocessorOptions: {