|
@@ -11,22 +11,27 @@ import { getIsOpenTab } from '/@/utils/helper/routeHelper';
|
|
|
|
|
|
const { projectSetting } = useSetting();
|
|
|
export function createGuard(router: Router) {
|
|
|
- const axiosCanceler = new AxiosCanceler();
|
|
|
-
|
|
|
+ const { openNProgress, closeMessageOnSwitch, removeAllHttpPending } = projectSetting;
|
|
|
+ let axiosCanceler: AxiosCanceler | null;
|
|
|
+ if (removeAllHttpPending) {
|
|
|
+ axiosCanceler = new AxiosCanceler();
|
|
|
+ }
|
|
|
router.beforeEach(async (to) => {
|
|
|
const isOpen = getIsOpenTab(to.path);
|
|
|
to.meta.inTab = isOpen;
|
|
|
try {
|
|
|
- Modal.destroyAll();
|
|
|
- notification.destroy();
|
|
|
+ if (closeMessageOnSwitch) {
|
|
|
+ Modal.destroyAll();
|
|
|
+ notification.destroy();
|
|
|
+ }
|
|
|
// TODO Some special interfaces require long connections
|
|
|
// Switching the route will delete the previous request
|
|
|
- axiosCanceler.removeAllPending();
|
|
|
+ removeAllHttpPending && axiosCanceler!.removeAllPending();
|
|
|
} catch (error) {
|
|
|
console.warn('basic guard error:' + error);
|
|
|
}
|
|
|
});
|
|
|
- projectSetting.openNProgress && createProgressGuard(router);
|
|
|
+ openNProgress && createProgressGuard(router);
|
|
|
createPermissionGuard(router);
|
|
|
createPageTitleGuard(router);
|
|
|
createPageLoadingGuard(router);
|