fix: 接口对接

This commit is contained in:
Json_Lee
2025-05-12 20:13:09 +08:00
parent 11ce542b5d
commit 7ccfc4a10c
10 changed files with 355 additions and 20 deletions
+6 -3
View File
@@ -12,11 +12,11 @@ interface BaseResponse {
}
export const request = hookFetch.create<BaseResponse, 'data' | 'rows'>({
baseURL: 'https://web.pandarobot.chat/api',
baseURL: import.meta.env.VITE_API_URL,
headers: {
'Content-Type': 'application/json',
},
plugins: [sseTextDecoderPlugin()],
plugins: [sseTextDecoderPlugin({ json: true, prefix: 'data:' })],
});
function jwtPlugin(): HookFetchPlugin<BaseResponse> {
@@ -29,10 +29,13 @@ function jwtPlugin(): HookFetchPlugin<BaseResponse> {
return config;
},
afterResponse: async (response) => {
console.log(response);
// console.log(response);
if (response.result?.code === 200) {
return response;
}
if (response.result?.code === 401) {
userStore.logout();
}
ElMessage.error(response.result?.msg);
return Promise.reject(response);
},