fix: pageLoading not working
This commit is contained in:
parent
577bf78896
commit
3f78b5aa0c
|
|
@ -15,7 +15,5 @@
|
||||||
@side-drag-z-index: 200;
|
@side-drag-z-index: 200;
|
||||||
@page-loading-z-index: 10000;
|
@page-loading-z-index: 10000;
|
||||||
|
|
||||||
// app menu
|
|
||||||
|
|
||||||
// left-menu
|
// left-menu
|
||||||
@app-menu-item-height: 42px;
|
@app-menu-item-height: 46px;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ export default defineComponent({
|
||||||
return () => {
|
return () => {
|
||||||
const { contentMode, openPageLoading } = unref(getProjectConfigRef);
|
const { contentMode, openPageLoading } = unref(getProjectConfigRef);
|
||||||
const { getPageLoading } = appStore;
|
const { getPageLoading } = appStore;
|
||||||
|
|
||||||
const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
|
const wrapClass = contentMode === ContentEnum.FULL ? 'full' : 'fixed';
|
||||||
return (
|
return (
|
||||||
<div class={[`default-layout__main`]}>
|
<div class={[`default-layout__main`]}>
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,16 @@ import { appStore } from '/@/store/modules/app';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'PageLayout',
|
name: 'PageLayout',
|
||||||
setup() {
|
setup() {
|
||||||
const getProjectConfigRef = computed(() => {
|
const getProjectConfigRef = computed(() => appStore.getProjectConfig);
|
||||||
return appStore.getProjectConfig;
|
const openCacheRef = computed(() => {
|
||||||
|
const {
|
||||||
|
openKeepAlive,
|
||||||
|
multiTabsSetting: { show },
|
||||||
|
} = unref(getProjectConfigRef);
|
||||||
|
return openKeepAlive && show;
|
||||||
});
|
});
|
||||||
|
const getCacheTabsRef = computed(() => toRaw(tabStore.getKeepAliveTabsState) as string[]);
|
||||||
|
|
||||||
const { openPageLoading } = unref(getProjectConfigRef);
|
const { openPageLoading } = unref(getProjectConfigRef);
|
||||||
|
|
||||||
let on = {};
|
let on = {};
|
||||||
|
|
@ -27,21 +34,20 @@ export default defineComponent({
|
||||||
const {
|
const {
|
||||||
routerTransition,
|
routerTransition,
|
||||||
openRouterTransition,
|
openRouterTransition,
|
||||||
openKeepAlive,
|
multiTabsSetting: { max },
|
||||||
multiTabsSetting: { show, max },
|
|
||||||
} = unref(getProjectConfigRef);
|
} = unref(getProjectConfigRef);
|
||||||
|
|
||||||
const openCache = openKeepAlive && show;
|
|
||||||
const cacheTabs = toRaw(tabStore.getKeepAliveTabsState) as string[];
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<RouterView>
|
<RouterView>
|
||||||
{{
|
{{
|
||||||
default: ({ Component, route }: { Component: any; route: RouteLocation }) => {
|
default: ({ Component, route }: { Component: any; route: RouteLocation }) => {
|
||||||
// No longer show animations that are already in the tab
|
// No longer show animations that are already in the tab
|
||||||
const name = route.meta.inTab ? 'fade' : null;
|
const cacheTabs = unref(getCacheTabsRef);
|
||||||
|
const isInCache = cacheTabs.includes(route.name as string);
|
||||||
|
const name = isInCache && route.meta.inTab ? 'fade' : null;
|
||||||
|
|
||||||
const Content = openCache ? (
|
const Content = unref(openCacheRef) ? (
|
||||||
<KeepAlive max={max} include={cacheTabs}>
|
<KeepAlive max={max} include={cacheTabs}>
|
||||||
<Component key={route.fullPath} />
|
<Component key={route.fullPath} />
|
||||||
</KeepAlive>
|
</KeepAlive>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { tryOnUnmounted } from '/@/utils/helper/vueHelper';
|
||||||
export function useTransition() {
|
export function useTransition() {
|
||||||
function handleAfterEnter() {
|
function handleAfterEnter() {
|
||||||
const { openRouterTransition, openPageLoading } = appStore.getProjectConfig;
|
const { openRouterTransition, openPageLoading } = appStore.getProjectConfig;
|
||||||
|
|
||||||
if (!openRouterTransition || !openPageLoading) return;
|
if (!openRouterTransition || !openPageLoading) return;
|
||||||
// Close loading after the route switching animation ends
|
// Close loading after the route switching animation ends
|
||||||
appStore.setPageLoadingAction(false);
|
appStore.setPageLoadingAction(false);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ export function createGuard(router: Router) {
|
||||||
if (removeAllHttpPending) {
|
if (removeAllHttpPending) {
|
||||||
axiosCanceler = new AxiosCanceler();
|
axiosCanceler = new AxiosCanceler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createPageLoadingGuard(router);
|
||||||
router.beforeEach(async (to) => {
|
router.beforeEach(async (to) => {
|
||||||
// Determine whether the tab has been opened
|
// Determine whether the tab has been opened
|
||||||
const isOpen = getIsOpenTab(to.fullPath);
|
const isOpen = getIsOpenTab(to.fullPath);
|
||||||
|
|
@ -59,5 +61,4 @@ export function createGuard(router: Router) {
|
||||||
|
|
||||||
openNProgress && createProgressGuard(router);
|
openNProgress && createProgressGuard(router);
|
||||||
createPermissionGuard(router);
|
createPermissionGuard(router);
|
||||||
createPageLoadingGuard(router);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export function createPageLoadingGuard(router: Router) {
|
||||||
appStore.commitPageLoadingState(true);
|
appStore.commitPageLoadingState(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show && openKeepAlive && !isFirstLoad) {
|
if (show && openKeepAlive && !isFirstLoad) {
|
||||||
const tabList = tabStore.getTabsState;
|
const tabList = tabStore.getTabsState;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue