From 2998b2fc2dead28517336a88fb6ec1dc114b26fd Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:50:34 +0800 Subject: [PATCH] fix: chat request (#3281) --- ui/src/request/chat/index.ts | 28 +++++++--------------------- ui/src/router/chat/index.ts | 1 - 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/ui/src/request/chat/index.ts b/ui/src/request/chat/index.ts index a90f7f6df..449803442 100644 --- a/ui/src/request/chat/index.ts +++ b/ui/src/request/chat/index.ts @@ -42,16 +42,8 @@ instance.interceptors.response.use( (response: any) => { if (response.data) { 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) - return Promise.reject(response.data) - } + MsgError(response.data.message) + return Promise.reject(response.data) } } return response @@ -61,20 +53,14 @@ instance.interceptors.response.use( MsgError(err.message) console.error(err) } - if (err.response?.status === 404) { - if (!err.response.config.url.includes('/application/authentication')) { + if (err.response?.status === 401) { + const { chatUser } = useStore() + if (chatUser.accessToken) { + router.push({ name: 'login', params: { accessToken: chatUser.accessToken } }) + } else { 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')) { MsgError( err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问', diff --git a/ui/src/router/chat/index.ts b/ui/src/router/chat/index.ts index 557cd5927..288729172 100644 --- a/ui/src/router/chat/index.ts +++ b/ui/src/router/chat/index.ts @@ -51,7 +51,6 @@ router.beforeEach( } else { await chatUser.anonymousAuthentication() } - if (!chatUser.application) { await chatUser.applicationProfile() }