22 lines
542 B
TypeScript
22 lines
542 B
TypeScript
import type { Router } from 'vue-router';
|
|
import { useProjectSetting } from '/@/hooks/setting';
|
|
import { Modal, notification } from 'ant-design-vue';
|
|
|
|
import { warn } from '/@/utils/log';
|
|
|
|
export function createMessageGuard(router: Router) {
|
|
const { closeMessageOnSwitch } = useProjectSetting();
|
|
|
|
router.beforeEach(async () => {
|
|
try {
|
|
if (closeMessageOnSwitch) {
|
|
Modal.destroyAll();
|
|
notification.destroy();
|
|
}
|
|
} catch (error) {
|
|
warn('message guard error:' + error);
|
|
}
|
|
return true;
|
|
});
|
|
}
|