Commit 3f78b5aa0cd3e7a6f17d58512ca93ee2905d5e2f
1 parent
577bf788
fix: pageLoading not working
Showing
6 changed files
with
19 additions
and
13 deletions
src/design/var/index.less
src/layouts/default/LayoutContent.tsx
... | ... | @@ -16,7 +16,6 @@ export default defineComponent({ |
16 | 16 | return () => { |
17 | 17 | const { contentMode, openPageLoading } = unref(getProjectConfigRef); |
18 | 18 | const { getPageLoading } = appStore; |
19 | - | |
20 | 19 | const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed'; |
21 | 20 | return ( |
22 | 21 | <div class={[`default-layout__main`]}> |
... | ... |
src/layouts/page/index.tsx
... | ... | @@ -12,9 +12,16 @@ import { appStore } from '/@/store/modules/app'; |
12 | 12 | export default defineComponent({ |
13 | 13 | name: 'PageLayout', |
14 | 14 | setup() { |
15 | - const getProjectConfigRef = computed(() => { | |
16 | - return appStore.getProjectConfig; | |
15 | + const getProjectConfigRef = computed(() => appStore.getProjectConfig); | |
16 | + const openCacheRef = computed(() => { | |
17 | + const { | |
18 | + openKeepAlive, | |
19 | + multiTabsSetting: { show }, | |
20 | + } = unref(getProjectConfigRef); | |
21 | + return openKeepAlive && show; | |
17 | 22 | }); |
23 | + const getCacheTabsRef = computed(() => toRaw(tabStore.getKeepAliveTabsState) as string[]); | |
24 | + | |
18 | 25 | const { openPageLoading } = unref(getProjectConfigRef); |
19 | 26 | |
20 | 27 | let on = {}; |
... | ... | @@ -27,21 +34,20 @@ export default defineComponent({ |
27 | 34 | const { |
28 | 35 | routerTransition, |
29 | 36 | openRouterTransition, |
30 | - openKeepAlive, | |
31 | - multiTabsSetting: { show, max }, | |
37 | + multiTabsSetting: { max }, | |
32 | 38 | } = unref(getProjectConfigRef); |
33 | 39 | |
34 | - const openCache = openKeepAlive && show; | |
35 | - const cacheTabs = toRaw(tabStore.getKeepAliveTabsState) as string[]; | |
36 | 40 | return ( |
37 | 41 | <div> |
38 | 42 | <RouterView> |
39 | 43 | {{ |
40 | 44 | default: ({ Component, route }: { Component: any; route: RouteLocation }) => { |
41 | 45 | // No longer show animations that are already in the tab |
42 | - const name = route.meta.inTab ? 'fade' : null; | |
46 | + const cacheTabs = unref(getCacheTabsRef); | |
47 | + const isInCache = cacheTabs.includes(route.name as string); | |
48 | + const name = isInCache && route.meta.inTab ? 'fade' : null; | |
43 | 49 | |
44 | - const Content = openCache ? ( | |
50 | + const Content = unref(openCacheRef) ? ( | |
45 | 51 | <KeepAlive max={max} include={cacheTabs}> |
46 | 52 | <Component key={route.fullPath} /> |
47 | 53 | </KeepAlive> |
... | ... |
src/layouts/page/useTransition.ts
... | ... | @@ -3,6 +3,7 @@ import { tryOnUnmounted } from '/@/utils/helper/vueHelper'; |
3 | 3 | export function useTransition() { |
4 | 4 | function handleAfterEnter() { |
5 | 5 | const { openRouterTransition, openPageLoading } = appStore.getProjectConfig; |
6 | + | |
6 | 7 | if (!openRouterTransition || !openPageLoading) return; |
7 | 8 | // Close loading after the route switching animation ends |
8 | 9 | appStore.setPageLoadingAction(false); |
... | ... |
src/router/guard/index.ts
... | ... | @@ -21,6 +21,8 @@ export function createGuard(router: Router) { |
21 | 21 | if (removeAllHttpPending) { |
22 | 22 | axiosCanceler = new AxiosCanceler(); |
23 | 23 | } |
24 | + | |
25 | + createPageLoadingGuard(router); | |
24 | 26 | router.beforeEach(async (to) => { |
25 | 27 | // Determine whether the tab has been opened |
26 | 28 | const isOpen = getIsOpenTab(to.fullPath); |
... | ... | @@ -59,5 +61,4 @@ export function createGuard(router: Router) { |
59 | 61 | |
60 | 62 | openNProgress && createProgressGuard(router); |
61 | 63 | createPermissionGuard(router); |
62 | - createPageLoadingGuard(router); | |
63 | 64 | } |
... | ... |
src/router/guard/pageLoadingGuard.ts