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 | 2 | import { useTimeout } from '/@/hooks/core/useTimeout'; |
2 | 3 | import { PageEnum } from '/@/enums/pageEnum'; |
3 | 4 | import { TabItem, tabStore } from '/@/store/modules/tab'; |
... | ... | @@ -64,6 +65,18 @@ export function useTabs() { |
64 | 65 | } |
65 | 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 | 80 | return { |
68 | 81 | initTabFn, |
69 | 82 | refreshPage: () => canIUseFn() && refreshPage(tabStore.getCurrentTab), |
... | ... | @@ -74,11 +87,13 @@ export function useTabs() { |
74 | 87 | closeCurrent: () => canIUseFn() && closeCurrent(tabStore.getCurrentTab), |
75 | 88 | resetCache: () => canIUseFn() && resetCache(), |
76 | 89 | addTab: (path: PageEnum, goTo = false, replace = false) => { |
90 | + const to = getTo(path); | |
91 | + if (!to) return; | |
77 | 92 | useTimeout(() => { |
78 | - tabStore.addTabByPathAction(path); | |
93 | + tabStore.addTabByPathAction((to as unknown) as AppRouteRecordRaw); | |
79 | 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 | 98 | activeKeyRef, |
84 | 99 | }; | ... | ... |
src/layouts/default/index.less
1 | 1 | @import (reference) '../../design/index.less'; |
2 | 2 | |
3 | 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 | 10 | &__content { |
11 | 11 | position: relative; |
... | ... | @@ -102,10 +102,12 @@ |
102 | 102 | .setting-button { |
103 | 103 | top: 45%; |
104 | 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 | 10 | // =========================== |
11 | 11 | // ==========module import==== |
12 | 12 | // =========================== |
13 | -import dashboardDemo from './modules/demo/dashboard'; | |
13 | +import dashboard from './modules/dashboard'; | |
14 | + | |
14 | 15 | import exceptionDemo from './modules/demo/exception'; |
15 | 16 | import iframeDemo from './modules/demo/iframe'; |
16 | 17 | import compDemo from './modules/demo/comp'; |
... | ... | @@ -22,7 +23,7 @@ import formDemo from './modules/demo/form'; |
22 | 23 | import treeDemo from './modules/demo/tree'; |
23 | 24 | |
24 | 25 | const menuModules = [ |
25 | - dashboardDemo, | |
26 | + dashboard, | |
26 | 27 | featDemo, |
27 | 28 | exceptionDemo, |
28 | 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 | path: '/charts', |
7 | 7 | children: [ |
8 | 8 | { |
9 | + path: '/apexChart', | |
10 | + name: 'ApexChart', | |
11 | + }, | |
12 | + { | |
9 | 13 | path: '/echarts', |
10 | 14 | name: 'Echarts', |
11 | 15 | children: [ |
... | ... | @@ -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 | 4 | import { genRouteModule } from '/@/utils/helper/routeHelper'; |
5 | 5 | |
6 | 6 | import LoginRoute from './modules/sys'; |
7 | + | |
8 | +import dashboard from './modules/dashboard'; | |
9 | + | |
7 | 10 | // demo |
8 | 11 | import exceptionDemo from './modules/demo/exception'; |
9 | -import dashboardDemo from './modules/demo/dashboard'; | |
10 | 12 | import iframeDemo from './modules/demo/iframe'; |
11 | 13 | import compDemo from './modules/demo/comp'; |
12 | 14 | import permissionDemo from './modules/demo/permission'; |
... | ... | @@ -18,7 +20,7 @@ import treeDemo from './modules/demo/tree'; |
18 | 20 | |
19 | 21 | const routeModuleList: AppRouteModule[] = [ |
20 | 22 | exceptionDemo, |
21 | - dashboardDemo, | |
23 | + dashboard, | |
22 | 24 | iframeDemo, |
23 | 25 | compDemo, |
24 | 26 | featDemo, | ... | ... |
src/router/routes/modules/demo/dashboard.ts renamed to src/router/routes/modules/dashboard.ts
src/router/routes/modules/demo/charts.ts
src/router/routes/modules/demo/feat.ts
... | ... | @@ -7,7 +7,7 @@ export default { |
7 | 7 | path: '/feat', |
8 | 8 | name: 'FeatDemo', |
9 | 9 | component: PAGE_LAYOUT_COMPONENT, |
10 | - redirect: '/feat/tabs', | |
10 | + redirect: '/feat/icon', | |
11 | 11 | meta: { |
12 | 12 | icon: 'ic:outline-featured-play-list', |
13 | 13 | title: 'Feat', |
... | ... | @@ -16,14 +16,6 @@ export default { |
16 | 16 | |
17 | 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 | 19 | path: '/icon', |
28 | 20 | name: 'IconDemo', |
29 | 21 | component: () => import('/@/views/demo/comp/icon/index.vue'), |
... | ... | @@ -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 | 36 | path: '/context-menu', |
36 | 37 | name: 'ContextMenuDemo', |
37 | 38 | component: () => import('/@/views/demo/feat/context-menu/index.vue'), | ... | ... |
src/settings/projectSetting.ts
src/store/modules/tab.ts
... | ... | @@ -181,10 +181,7 @@ class Tab extends VuexModule { |
181 | 181 | } |
182 | 182 | |
183 | 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 | 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 | 2 | import { useSetting } from '/@/hooks/core/useSetting'; |
3 | -import moment from 'moment'; | |
4 | 3 | import pkg from '../../../package.json'; |
5 | 4 | const { globSetting } = useSetting(); |
6 | 5 | |
7 | 6 | // Generate cache key according to version |
8 | 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 | }; | ... | ... |