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

24 lines
588 B
TypeScript
Raw Normal View History

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-09-28 20:19:10 +08:00
export function useTransition() {
function handleAfterEnter() {
const { openRouterTransition, openPageLoading } = appStore.getProjectConfig;
2020-11-12 23:58:44 +08:00
2020-09-28 20:19:10 +08:00
if (!openRouterTransition || !openPageLoading) 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 {
handleAfterEnter,
on: {
onAfterEnter: handleAfterEnter,
},
};
}