Commit 02d6a3940277a5939d25d16fda58e09346821e0e
1 parent
bbfb06f0
fix: fix missing cache of refresh page
Showing
12 changed files
with
54 additions
and
40 deletions
src/hooks/web/useTabs.ts
1 | +import type { AppRouteRecordRaw } from '/@/router/types.d'; | ||
1 | import { useTimeout } from '/@/hooks/core/useTimeout'; | 2 | import { useTimeout } from '/@/hooks/core/useTimeout'; |
2 | import { PageEnum } from '/@/enums/pageEnum'; | 3 | import { PageEnum } from '/@/enums/pageEnum'; |
3 | import { TabItem, tabStore } from '/@/store/modules/tab'; | 4 | import { TabItem, tabStore } from '/@/store/modules/tab'; |
@@ -64,6 +65,18 @@ export function useTabs() { | @@ -64,6 +65,18 @@ export function useTabs() { | ||
64 | } | 65 | } |
65 | return !!show; | 66 | return !!show; |
66 | } | 67 | } |
68 | + function getTo(path: string): any { | ||
69 | + const routes = router.getRoutes(); | ||
70 | + const fn = (p: string): any => { | ||
71 | + const to = routes.find((item) => item.path === p); | ||
72 | + if (!to) return ''; | ||
73 | + if (!to.redirect) return to; | ||
74 | + if (to.redirect) { | ||
75 | + return getTo(to.redirect as string); | ||
76 | + } | ||
77 | + }; | ||
78 | + return fn(path); | ||
79 | + } | ||
67 | return { | 80 | return { |
68 | initTabFn, | 81 | initTabFn, |
69 | refreshPage: () => canIUseFn() && refreshPage(tabStore.getCurrentTab), | 82 | refreshPage: () => canIUseFn() && refreshPage(tabStore.getCurrentTab), |
@@ -74,11 +87,13 @@ export function useTabs() { | @@ -74,11 +87,13 @@ export function useTabs() { | ||
74 | closeCurrent: () => canIUseFn() && closeCurrent(tabStore.getCurrentTab), | 87 | closeCurrent: () => canIUseFn() && closeCurrent(tabStore.getCurrentTab), |
75 | resetCache: () => canIUseFn() && resetCache(), | 88 | resetCache: () => canIUseFn() && resetCache(), |
76 | addTab: (path: PageEnum, goTo = false, replace = false) => { | 89 | addTab: (path: PageEnum, goTo = false, replace = false) => { |
90 | + const to = getTo(path); | ||
91 | + if (!to) return; | ||
77 | useTimeout(() => { | 92 | useTimeout(() => { |
78 | - tabStore.addTabByPathAction(path); | 93 | + tabStore.addTabByPathAction((to as unknown) as AppRouteRecordRaw); |
79 | }, 0); | 94 | }, 0); |
80 | - activeKeyRef.value = path; | ||
81 | - goTo && replace ? router.replace : router.push(path); | 95 | + activeKeyRef.value = to.path; |
96 | + goTo && replace ? router.replace : router.push(to.path); | ||
82 | }, | 97 | }, |
83 | activeKeyRef, | 98 | activeKeyRef, |
84 | }; | 99 | }; |
src/layouts/default/index.less
1 | @import (reference) '../../design/index.less'; | 1 | @import (reference) '../../design/index.less'; |
2 | 2 | ||
3 | .default-layout { | 3 | .default-layout { |
4 | - .ant-menu-submenu .ant-menu-sub { | ||
5 | - transition: none !important; | ||
6 | - // transition: background 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s, | ||
7 | - // padding 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s !important; | ||
8 | - } | 4 | + // .ant-menu-submenu .ant-menu-sub { |
5 | + // transition: none !important; | ||
6 | + // // transition: background 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s, | ||
7 | + // // padding 0.2s cubic-bezier(0.645, 0.045, 0.355, 1) 0s !important; | ||
8 | + // } | ||
9 | 9 | ||
10 | &__content { | 10 | &__content { |
11 | position: relative; | 11 | position: relative; |
@@ -102,10 +102,12 @@ | @@ -102,10 +102,12 @@ | ||
102 | .setting-button { | 102 | .setting-button { |
103 | top: 45%; | 103 | top: 45%; |
104 | right: 0; | 104 | right: 0; |
105 | - border-radius: 10px 0 0 10px; | 105 | + padding: 14px; |
106 | + border-radius: 6px 0 0 6px; | ||
106 | 107 | ||
107 | - .svg { | ||
108 | - width: 2em; | 108 | + svg { |
109 | + width: 1.2em; | ||
110 | + height: 1.2em; | ||
109 | } | 111 | } |
110 | } | 112 | } |
111 | 113 |
src/router/menus/index.ts
@@ -10,7 +10,8 @@ import { PermissionModeEnum } from '/@/enums/appEnum'; | @@ -10,7 +10,8 @@ import { PermissionModeEnum } from '/@/enums/appEnum'; | ||
10 | // =========================== | 10 | // =========================== |
11 | // ==========module import==== | 11 | // ==========module import==== |
12 | // =========================== | 12 | // =========================== |
13 | -import dashboardDemo from './modules/demo/dashboard'; | 13 | +import dashboard from './modules/dashboard'; |
14 | + | ||
14 | import exceptionDemo from './modules/demo/exception'; | 15 | import exceptionDemo from './modules/demo/exception'; |
15 | import iframeDemo from './modules/demo/iframe'; | 16 | import iframeDemo from './modules/demo/iframe'; |
16 | import compDemo from './modules/demo/comp'; | 17 | import compDemo from './modules/demo/comp'; |
@@ -22,7 +23,7 @@ import formDemo from './modules/demo/form'; | @@ -22,7 +23,7 @@ import formDemo from './modules/demo/form'; | ||
22 | import treeDemo from './modules/demo/tree'; | 23 | import treeDemo from './modules/demo/tree'; |
23 | 24 | ||
24 | const menuModules = [ | 25 | const menuModules = [ |
25 | - dashboardDemo, | 26 | + dashboard, |
26 | featDemo, | 27 | featDemo, |
27 | exceptionDemo, | 28 | exceptionDemo, |
28 | iframeDemo, | 29 | iframeDemo, |
src/router/menus/modules/demo/dashboard.ts renamed to src/router/menus/modules/dashboard.ts
src/router/menus/modules/demo/charts.ts
@@ -6,6 +6,10 @@ const menu: MenuModule = { | @@ -6,6 +6,10 @@ const menu: MenuModule = { | ||
6 | path: '/charts', | 6 | path: '/charts', |
7 | children: [ | 7 | children: [ |
8 | { | 8 | { |
9 | + path: '/apexChart', | ||
10 | + name: 'ApexChart', | ||
11 | + }, | ||
12 | + { | ||
9 | path: '/echarts', | 13 | path: '/echarts', |
10 | name: 'Echarts', | 14 | name: 'Echarts', |
11 | children: [ | 15 | children: [ |
@@ -23,10 +27,6 @@ const menu: MenuModule = { | @@ -23,10 +27,6 @@ const menu: MenuModule = { | ||
23 | }, | 27 | }, |
24 | ], | 28 | ], |
25 | }, | 29 | }, |
26 | - { | ||
27 | - path: '/apexChart', | ||
28 | - name: 'ApexChart', | ||
29 | - }, | ||
30 | ], | 30 | ], |
31 | }, | 31 | }, |
32 | }; | 32 | }; |
src/router/routes/index.ts
@@ -4,9 +4,11 @@ import { DEFAULT_LAYOUT_COMPONENT, PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from ' | @@ -4,9 +4,11 @@ import { DEFAULT_LAYOUT_COMPONENT, PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from ' | ||
4 | import { genRouteModule } from '/@/utils/helper/routeHelper'; | 4 | import { genRouteModule } from '/@/utils/helper/routeHelper'; |
5 | 5 | ||
6 | import LoginRoute from './modules/sys'; | 6 | import LoginRoute from './modules/sys'; |
7 | + | ||
8 | +import dashboard from './modules/dashboard'; | ||
9 | + | ||
7 | // demo | 10 | // demo |
8 | import exceptionDemo from './modules/demo/exception'; | 11 | import exceptionDemo from './modules/demo/exception'; |
9 | -import dashboardDemo from './modules/demo/dashboard'; | ||
10 | import iframeDemo from './modules/demo/iframe'; | 12 | import iframeDemo from './modules/demo/iframe'; |
11 | import compDemo from './modules/demo/comp'; | 13 | import compDemo from './modules/demo/comp'; |
12 | import permissionDemo from './modules/demo/permission'; | 14 | import permissionDemo from './modules/demo/permission'; |
@@ -18,7 +20,7 @@ import treeDemo from './modules/demo/tree'; | @@ -18,7 +20,7 @@ import treeDemo from './modules/demo/tree'; | ||
18 | 20 | ||
19 | const routeModuleList: AppRouteModule[] = [ | 21 | const routeModuleList: AppRouteModule[] = [ |
20 | exceptionDemo, | 22 | exceptionDemo, |
21 | - dashboardDemo, | 23 | + dashboard, |
22 | iframeDemo, | 24 | iframeDemo, |
23 | compDemo, | 25 | compDemo, |
24 | featDemo, | 26 | featDemo, |
src/router/routes/modules/demo/dashboard.ts renamed to src/router/routes/modules/dashboard.ts
src/router/routes/modules/demo/charts.ts
@@ -7,7 +7,7 @@ export default { | @@ -7,7 +7,7 @@ export default { | ||
7 | path: '/charts', | 7 | path: '/charts', |
8 | name: 'Charts', | 8 | name: 'Charts', |
9 | component: PAGE_LAYOUT_COMPONENT, | 9 | component: PAGE_LAYOUT_COMPONENT, |
10 | - redirect: '/charts/welcome', | 10 | + redirect: '/charts/apexChart', |
11 | meta: { | 11 | meta: { |
12 | icon: 'ant-design:area-chart-outlined', | 12 | icon: 'ant-design:area-chart-outlined', |
13 | title: '图表库', | 13 | title: '图表库', |
src/router/routes/modules/demo/feat.ts
@@ -7,7 +7,7 @@ export default { | @@ -7,7 +7,7 @@ export default { | ||
7 | path: '/feat', | 7 | path: '/feat', |
8 | name: 'FeatDemo', | 8 | name: 'FeatDemo', |
9 | component: PAGE_LAYOUT_COMPONENT, | 9 | component: PAGE_LAYOUT_COMPONENT, |
10 | - redirect: '/feat/tabs', | 10 | + redirect: '/feat/icon', |
11 | meta: { | 11 | meta: { |
12 | icon: 'ic:outline-featured-play-list', | 12 | icon: 'ic:outline-featured-play-list', |
13 | title: 'Feat', | 13 | title: 'Feat', |
@@ -16,14 +16,6 @@ export default { | @@ -16,14 +16,6 @@ export default { | ||
16 | 16 | ||
17 | routes: [ | 17 | routes: [ |
18 | { | 18 | { |
19 | - path: '/tabs', | ||
20 | - name: 'TabsDemo', | ||
21 | - component: () => import('/@/views/demo/feat/tabs/index.vue'), | ||
22 | - meta: { | ||
23 | - title: '标签页操作', | ||
24 | - }, | ||
25 | - }, | ||
26 | - { | ||
27 | path: '/icon', | 19 | path: '/icon', |
28 | name: 'IconDemo', | 20 | name: 'IconDemo', |
29 | component: () => import('/@/views/demo/comp/icon/index.vue'), | 21 | component: () => import('/@/views/demo/comp/icon/index.vue'), |
@@ -32,6 +24,15 @@ export default { | @@ -32,6 +24,15 @@ export default { | ||
32 | }, | 24 | }, |
33 | }, | 25 | }, |
34 | { | 26 | { |
27 | + path: '/tabs', | ||
28 | + name: 'TabsDemo', | ||
29 | + component: () => import('/@/views/demo/feat/tabs/index.vue'), | ||
30 | + meta: { | ||
31 | + title: '标签页操作', | ||
32 | + }, | ||
33 | + }, | ||
34 | + | ||
35 | + { | ||
35 | path: '/context-menu', | 36 | path: '/context-menu', |
36 | name: 'ContextMenuDemo', | 37 | name: 'ContextMenuDemo', |
37 | component: () => import('/@/views/demo/feat/context-menu/index.vue'), | 38 | component: () => import('/@/views/demo/feat/context-menu/index.vue'), |
src/settings/projectSetting.ts
@@ -61,7 +61,7 @@ const setting: ProjectConfig = { | @@ -61,7 +61,7 @@ const setting: ProjectConfig = { | ||
61 | // 分割菜单 | 61 | // 分割菜单 |
62 | split: false, | 62 | split: false, |
63 | // 顶部菜单布局 | 63 | // 顶部菜单布局 |
64 | - topMenuAlign: 'center', | 64 | + topMenuAlign: 'start', |
65 | }, | 65 | }, |
66 | // 消息配置 | 66 | // 消息配置 |
67 | messageSetting: { | 67 | messageSetting: { |
src/store/modules/tab.ts
@@ -181,10 +181,7 @@ class Tab extends VuexModule { | @@ -181,10 +181,7 @@ class Tab extends VuexModule { | ||
181 | } | 181 | } |
182 | 182 | ||
183 | @Action | 183 | @Action |
184 | - addTabByPathAction(path: string): void { | ||
185 | - if (!path) return; | ||
186 | - const routes = router.getRoutes(); | ||
187 | - const to = routes.find((item) => item.path === path); | 184 | + addTabByPathAction(to: AppRouteRecordRaw): void { |
188 | to && this.commitAddTab((to as unknown) as AppRouteRecordRaw); | 185 | to && this.commitAddTab((to as unknown) as AppRouteRecordRaw); |
189 | } | 186 | } |
190 | 187 |
src/utils/helper/envHelper.ts
1 | -import { isDevMode, getEnv } from '/@/utils/env'; | 1 | +import { getEnv } from '/@/utils/env'; |
2 | import { useSetting } from '/@/hooks/core/useSetting'; | 2 | import { useSetting } from '/@/hooks/core/useSetting'; |
3 | -import moment from 'moment'; | ||
4 | import pkg from '../../../package.json'; | 3 | import pkg from '../../../package.json'; |
5 | const { globSetting } = useSetting(); | 4 | const { globSetting } = useSetting(); |
6 | 5 | ||
7 | // Generate cache key according to version | 6 | // Generate cache key according to version |
8 | export const getStorageShortName = () => { | 7 | export const getStorageShortName = () => { |
9 | - const shortTime = moment().format('MMDDHHmmss'); | ||
10 | - return `${globSetting.shortName}__${getEnv()}${ | ||
11 | - `__${pkg.version}` + (isDevMode() ? '' : `__${shortTime}`) | ||
12 | - }__`.toUpperCase(); | 8 | + return `${globSetting.shortName}__${getEnv()}${`__${pkg.version}`}__`.toUpperCase(); |
13 | }; | 9 | }; |