fix: chat request (#3281)

This commit is contained in:
shaohuzhang1 2025-06-17 16:50:34 +08:00 committed by GitHub
parent 63b783c8f5
commit 2998b2fc2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 22 deletions

View File

@ -42,18 +42,10 @@ instance.interceptors.response.use(
(response: any) => { (response: any) => {
if (response.data) { if (response.data) {
if (response.data.code !== 200 && !(response.data instanceof Blob)) { if (response.data.code !== 200 && !(response.data instanceof Blob)) {
if (response.config.url.includes('/application/authentication')) {
return Promise.reject(response.data)
}
if (
!response.config.url.includes('/valid') &&
!response.config.url.includes('/tool/debug')
) {
MsgError(response.data.message) MsgError(response.data.message)
return Promise.reject(response.data) return Promise.reject(response.data)
} }
} }
}
return response return response
}, },
(err: any) => { (err: any) => {
@ -61,20 +53,14 @@ instance.interceptors.response.use(
MsgError(err.message) MsgError(err.message)
console.error(err) console.error(err)
} }
if (err.response?.status === 404) { if (err.response?.status === 401) {
if (!err.response.config.url.includes('/application/authentication')) { const { chatUser } = useStore()
if (chatUser.accessToken) {
router.push({ name: 'login', params: { accessToken: chatUser.accessToken } })
} else {
router.push('/404 ') router.push('/404 ')
} }
} }
if (err.response?.status === 401) {
if (
!err.response.config.url.includes('chat/open') &&
!err.response.config.url.includes('application/profile')
) {
router.push({ name: 'login' })
}
}
if (err.response?.status === 403 && !err.response.config.url.includes('chat/open')) { if (err.response?.status === 403 && !err.response.config.url.includes('chat/open')) {
MsgError( MsgError(
err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问', err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问',

View File

@ -51,7 +51,6 @@ router.beforeEach(
} else { } else {
await chatUser.anonymousAuthentication() await chatUser.anonymousAuthentication()
} }
if (!chatUser.application) { if (!chatUser.application) {
await chatUser.applicationProfile() await chatUser.applicationProfile()
} }