feat: 统一403错误提示为'无权限操作'
修改内容: 1. handleCreate: 捕获403错误,显示'无权限操作:您没有创建知识库绑定的权限' 2. handleUpdate: 捕获403错误,显示'无权限操作:您没有编辑知识库绑定的权限' 3. handleDelete: 捕获403错误,显示'无权限操作:您没有删除知识库绑定的权限' 检查逻辑: - error?.response?.status === 403 - error?.status === 403 - error?.code === 403 优势:用户能清楚知道是权限问题,而不是系统错误
This commit is contained in:
@@ -222,7 +222,12 @@ export function useAreaDatasetConfig(): UseAreaDatasetConfigReturn {
|
|||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('创建知识库绑定失败:', error);
|
console.error('创建知识库绑定失败:', error);
|
||||||
message.error('创建失败,请稍后重试');
|
// 检查是否为403权限不足错误
|
||||||
|
if (error?.response?.status === 403 || error?.status === 403 || error?.code === 403) {
|
||||||
|
message.error('无权限操作:您没有创建知识库绑定的权限');
|
||||||
|
} else {
|
||||||
|
message.error('创建失败,请稍后重试');
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
setSubmitLoading(false);
|
setSubmitLoading(false);
|
||||||
@@ -256,8 +261,8 @@ export function useAreaDatasetConfig(): UseAreaDatasetConfigReturn {
|
|||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('更新知识库绑定失败:', error);
|
console.error('更新知识库绑定失败:', error);
|
||||||
// 检查是否为403权限不足错误
|
// 检查是否为403权限不足错误
|
||||||
if (error?.response?.status === 403 || error?.status === 403) {
|
if (error?.response?.status === 403 || error?.status === 403 || error?.code === 403) {
|
||||||
message.error('权限不足:您没有编辑知识库绑定的权限');
|
message.error('无权限操作:您没有编辑知识库绑定的权限');
|
||||||
} else {
|
} else {
|
||||||
message.error('更新失败,请稍后重试');
|
message.error('更新失败,请稍后重试');
|
||||||
}
|
}
|
||||||
@@ -292,7 +297,12 @@ export function useAreaDatasetConfig(): UseAreaDatasetConfigReturn {
|
|||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('删除知识库绑定失败:', error);
|
console.error('删除知识库绑定失败:', error);
|
||||||
message.error('删除失败,请稍后重试');
|
// 检查是否为403权限不足错误
|
||||||
|
if (error?.response?.status === 403 || error?.status === 403 || error?.code === 403) {
|
||||||
|
message.error('无权限操作:您没有删除知识库绑定的权限');
|
||||||
|
} else {
|
||||||
|
message.error('删除失败,请稍后重试');
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user