Skip to content

Commit 3f78b5a

Browse files
committed
fix: pageLoading not working
1 parent 577bf78 commit 3f78b5a

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/design/var/index.less

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@
1515
@side-drag-z-index: 200;
1616
@page-loading-z-index: 10000;
1717

18-
// app menu
19-
2018
// left-menu
21-
@app-menu-item-height: 42px;
19+
@app-menu-item-height: 46px;

src/layouts/default/LayoutContent.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export default defineComponent({
1616
return () => {
1717
const { contentMode, openPageLoading } = unref(getProjectConfigRef);
1818
const { getPageLoading } = appStore;
19-
2019
const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
2120
return (
2221
<div class={[`default-layout__main`]}>

src/layouts/page/index.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ import { appStore } from '/@/store/modules/app';
1212
export default defineComponent({
1313
name: 'PageLayout',
1414
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;
1722
});
23+
const getCacheTabsRef = computed(() => toRaw(tabStore.getKeepAliveTabsState) as string[]);
24+
1825
const { openPageLoading } = unref(getProjectConfigRef);
1926

2027
let on = {};
@@ -27,21 +34,20 @@ export default defineComponent({
2734
const {
2835
routerTransition,
2936
openRouterTransition,
30-
openKeepAlive,
31-
multiTabsSetting: { show, max },
37+
multiTabsSetting: { max },
3238
} = unref(getProjectConfigRef);
3339

34-
const openCache = openKeepAlive && show;
35-
const cacheTabs = toRaw(tabStore.getKeepAliveTabsState) as string[];
3640
return (
3741
<div>
3842
<RouterView>
3943
{{
4044
default: ({ Component, route }: { Component: any; route: RouteLocation }) => {
4145
// 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;
4349

44-
const Content = openCache ? (
50+
const Content = unref(openCacheRef) ? (
4551
<KeepAlive max={max} include={cacheTabs}>
4652
<Component key={route.fullPath} />
4753
</KeepAlive>

src/layouts/page/useTransition.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { tryOnUnmounted } from '/@/utils/helper/vueHelper';
33
export function useTransition() {
44
function handleAfterEnter() {
55
const { openRouterTransition, openPageLoading } = appStore.getProjectConfig;
6+
67
if (!openRouterTransition || !openPageLoading) return;
78
// Close loading after the route switching animation ends
89
appStore.setPageLoadingAction(false);

src/router/guard/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export function createGuard(router: Router) {
2121
if (removeAllHttpPending) {
2222
axiosCanceler = new AxiosCanceler();
2323
}
24+
25+
createPageLoadingGuard(router);
2426
router.beforeEach(async (to) => {
2527
// Determine whether the tab has been opened
2628
const isOpen = getIsOpenTab(to.fullPath);
@@ -59,5 +61,4 @@ export function createGuard(router: Router) {
5961

6062
openNProgress && createProgressGuard(router);
6163
createPermissionGuard(router);
62-
createPageLoadingGuard(router);
6364
}

src/router/guard/pageLoadingGuard.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function createPageLoadingGuard(router: Router) {
2020
appStore.commitPageLoadingState(true);
2121
return true;
2222
}
23+
2324
if (show && openKeepAlive && !isFirstLoad) {
2425
const tabList = tabStore.getTabsState;
2526

0 commit comments

Comments
 (0)