|
|
@@ -1,9 +1,20 @@
|
|
|
import axios from 'axios';
|
|
|
-import { ElNotification, ElMessageBox } from 'element-plus';
|
|
|
+import { ElNotification, ElMessageBox, ElMessage } from 'element-plus';
|
|
|
import sysConfig from "@/config";
|
|
|
import tool from '@/utils/tool';
|
|
|
import router from '@/router';
|
|
|
-
|
|
|
+import store from '@/store';
|
|
|
+function clearLoginSession() {
|
|
|
+ tool.cookie.remove('TOKEN');
|
|
|
+ tool.data.remove('USER_INFO');
|
|
|
+ tool.data.remove('MENU');
|
|
|
+ tool.data.remove('PERMISSIONS');
|
|
|
+ tool.data.remove('DASHBOARDGRID');
|
|
|
+ tool.data.remove('grid');
|
|
|
+ store.commit('clearViewTags');
|
|
|
+ store.commit('clearKeepLive');
|
|
|
+ store.commit('clearIframeList');
|
|
|
+}
|
|
|
axios.defaults.baseURL = ''
|
|
|
|
|
|
axios.defaults.timeout = sysConfig.TIMEOUT
|
|
|
@@ -39,6 +50,11 @@ let MessageBox_401_show = false
|
|
|
// HTTP response 拦截器
|
|
|
axios.interceptors.response.use(
|
|
|
(response) => {
|
|
|
+ if (response.data.code == 401) {
|
|
|
+ clearLoginSession();
|
|
|
+ ElMessage.warning('登录已失效,请重新登录');
|
|
|
+ router.replace({ path: '/login' });
|
|
|
+ }
|
|
|
return response;
|
|
|
},
|
|
|
(error) => {
|