| | |
| | | baseUrl |
| | | } from '@/config/env'; |
| | | import crypto from '@/utils/crypto'; |
| | | |
| | | const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL |
| | | // 全局未授权错误提示状态,只提示一次 |
| | | let isErrorShown = false; |
| | | |
| | |
| | | const message = res.data.msg || res.data.error_description || res.data.message ||'系统错误'; |
| | | const config = res.config; |
| | | const cryptoData = config.cryptoData === true; |
| | | if (status === 511) { |
| | | ElMessage({ |
| | | message: '请联系运维人员上传密钥证书!', |
| | | type: 'error', |
| | | }); |
| | | // 获取当前路由名称 |
| | | const currentRouteName = router.currentRoute.value.name; |
| | | // 如果当前路由不是登录页,则跳转到登录页 |
| | | if (currentRouteName !== '登录页') { |
| | | store.dispatch('FedLogOut').then(() => router.push({ |
| | | path: '/login' |
| | | })); |
| | | } |
| | | return Promise.reject(new Error(message)); |
| | | } |
| | | //如果在白名单里则自行catch逻辑处理 |
| | | if (statusWhiteList.includes(status)) return Promise.reject(res); |
| | | // 如果是401并且没有重试过,尝试刷新token |
| | |
| | | removeToken(); |
| | | removeRefreshToken(); |
| | | // 重定向到登录页 |
| | | store.dispatch('FedLogOut').then(() => router.push({ |
| | | path: '/login' |
| | | })); |
| | | // store.dispatch('FedLogOut').then(() => router.push({ |
| | | // path: '/login' |
| | | // })); |
| | | store.dispatch('FedLogOut').then(() => window.location.replace(`${adminUrl}#/login`)); |
| | | return Promise.reject(new Error(message)); |
| | | }); |
| | | } |
| | |
| | | removeToken(); |
| | | removeRefreshToken(); |
| | | // 重定向到登录页 |
| | | store.dispatch('FedLogOut').then(() => router.push({ |
| | | path: '/login' |
| | | })); |
| | | // store.dispatch('FedLogOut').then(() => router.push({ |
| | | // path: '/login' |
| | | // })); |
| | | store.dispatch('FedLogOut').then(() => window.location.replace(`${adminUrl}#/login`)); |
| | | return Promise.reject(new Error(message)); |
| | | } |
| | | // 如果请求为oauth2错误码则首次报错时提示 |