2020-11-25 00:43:33 +08:00
|
|
|
import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
|
|
|
|
|
|
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-25 00:43:33 +08:00
|
|
|
const { getOpenPageLoading, getEnableTransition } = useTransitionSetting();
|
|
|
|
|
if (!getOpenPageLoading.value || !getEnableTransition.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
|
|
|
};
|
|
|
|
|
}
|