|
@@ -1,5 +1,5 @@
|
|
import { useUserSessionStore } from '@/store/userStore'
|
|
import { useUserSessionStore } from '@/store/userStore'
|
|
-import { useNavigation } from '@/router/context/NavigationContext'
|
|
|
|
|
|
+import { useNavigateContext } from '@/router/context/NavigationContext'
|
|
import { ResultEnum } from '#/enum'
|
|
import { ResultEnum } from '#/enum'
|
|
import { t } from '@/locales/i18n'
|
|
import { t } from '@/locales/i18n'
|
|
import axios, { type AxiosError, type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
|
import axios, { type AxiosError, type AxiosRequestConfig, type AxiosResponse } from 'axios'
|
|
@@ -10,7 +10,7 @@ import { BASE_URL, TIME_OUT } from './config'
|
|
|
|
|
|
const handleNetworkError = (response: AxiosResponse) => {
|
|
const handleNetworkError = (response: AxiosResponse) => {
|
|
const { actions } = useUserSessionStore.getState()
|
|
const { actions } = useUserSessionStore.getState()
|
|
- const { navigate } = useNavigation()
|
|
|
|
|
|
+ // const { navigate } = useNavigateContext()
|
|
if (!response) return
|
|
if (!response) return
|
|
let errMessage = '未知错误'
|
|
let errMessage = '未知错误'
|
|
const status = response?.status
|
|
const status = response?.status
|
|
@@ -23,7 +23,7 @@ const handleNetworkError = (response: AxiosResponse) => {
|
|
errMessage = '未授权,请重新登录'
|
|
errMessage = '未授权,请重新登录'
|
|
// abortRequestFn()
|
|
// abortRequestFn()
|
|
// logoutFn()
|
|
// logoutFn()
|
|
- navigate('/login')
|
|
|
|
|
|
+ // navigate('/login')
|
|
actions.clearUserInfoAndToken()
|
|
actions.clearUserInfoAndToken()
|
|
break
|
|
break
|
|
case 403:
|
|
case 403:
|
|
@@ -104,7 +104,8 @@ axiosInstance.interceptors.request.use(
|
|
config.data = serialize(config.data)
|
|
config.data = serialize(config.data)
|
|
delete config.data.serialize
|
|
delete config.data.serialize
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ const { navigate } = useNavigateContext()
|
|
|
|
+ navigate('/login')
|
|
if (config.method === 'get') {
|
|
if (config.method === 'get') {
|
|
config.paramsSerializer = function (params) {
|
|
config.paramsSerializer = function (params) {
|
|
return qs.stringify(params, { arrayFormat: 'repeat' })
|
|
return qs.stringify(params, { arrayFormat: 'repeat' })
|