fix:百度seo添加与对话错误处理
This commit is contained in:
@@ -44,8 +44,19 @@ const bubbleListRef = ref<BubbleListInstance | null>(null);
|
||||
|
||||
const { stream, loading: isLoading, cancel } = useHookFetch({
|
||||
request: send,
|
||||
onError: (err) => {
|
||||
console.warn('测试错误拦截', err);
|
||||
onError: async (error) => {
|
||||
if (error.status === 403) {
|
||||
const data = await (error.response.json());
|
||||
// 弹窗提示
|
||||
ElMessage.error(data.error.message);
|
||||
return Promise.reject(data);
|
||||
}
|
||||
if (error.status === 401) {
|
||||
ElMessage.error('登录已过期,请重新登录!');
|
||||
// 弹窗提示
|
||||
userStore.logout();
|
||||
userStore.openLoginDialog();
|
||||
}
|
||||
},
|
||||
});
|
||||
// 记录进入思考中
|
||||
@@ -148,9 +159,6 @@ function handleDataChunk(chunk: AnyObject) {
|
||||
|
||||
// 封装错误处理逻辑
|
||||
function handleError(err: any) {
|
||||
if (err.status === 403) {
|
||||
ElMessage.error('业务错误,请稍后再试');
|
||||
}
|
||||
console.error('Fetch error:', err);
|
||||
}
|
||||
|
||||
@@ -191,6 +199,7 @@ async function startSSE(chatContent: string) {
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log('33---');
|
||||
handleError(err);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -102,6 +102,8 @@ function jwtPlugin(): {
|
||||
return response;
|
||||
|
||||
if (response.result?.code === 403) {
|
||||
console.log('2222---');
|
||||
|
||||
router.replace({ name: '403' });
|
||||
ElMessage.error(response.result?.msg);
|
||||
return Promise.reject(response);
|
||||
|
||||
Reference in New Issue
Block a user