vue-vben-admin/src/layouts/page/useTransition.ts

22 lines
628 B
TypeScript
Raw Normal View History

2020-11-23 23:24:13 +08:00
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
2020-09-28 20:19:10 +08:00
import { appStore } from '/@/store/modules/app';
2020-11-02 23:04:25 +08:00
import { tryOnUnmounted } from '/@/utils/helper/vueHelper';
2020-11-23 23:24:13 +08:00
2020-09-28 20:19:10 +08:00
export function useTransition() {
function handleAfterEnter() {
2020-11-23 23:24:13 +08:00
const { getOpenPageLoading, getOpenRouterTransition } = useRootSetting();
if (!getOpenPageLoading.value || !getOpenRouterTransition.value) return;
2020-11-02 23:04:25 +08:00
// Close loading after the route switching animation ends
2020-09-28 20:19:10 +08:00
appStore.setPageLoadingAction(false);
}
2020-11-02 23:04:25 +08:00
tryOnUnmounted(() => {
2020-09-28 20:19:10 +08:00
handleAfterEnter();
stop();
});
2020-11-02 23:04:25 +08:00
2020-09-28 20:19:10 +08:00
return {
2020-11-23 23:24:13 +08:00
onAfterEnter: handleAfterEnter,
2020-09-28 20:19:10 +08:00
};
}