perf(后端): 优化删除操作的数据库查询性能
- 新增 ExistsByID 方法用于账号存在性检查,避免加载完整对象 - 新增 GetOwnerID 方法用于 API Key 所有权验证,仅查询 user_id 字段 - 优化 AccountService.Delete 使用轻量级存在性检查 - 优化 ApiKeyService.Delete 使用轻量级权限验证 - 改进前端删除错误提示,显示后端返回的具体错误消息 - 添加详细的中文注释说明优化原因 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -823,6 +823,11 @@ const handleSubmit = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理删除 API Key 的操作
|
||||
* 优化:错误处理改进,优先显示后端返回的具体错误消息(如权限不足等),
|
||||
* 若后端未返回消息则显示默认的国际化文本
|
||||
*/
|
||||
const handleDelete = async () => {
|
||||
if (!selectedKey.value) return
|
||||
|
||||
@@ -831,8 +836,10 @@ const handleDelete = async () => {
|
||||
appStore.showSuccess(t('keys.keyDeletedSuccess'))
|
||||
showDeleteDialog.value = false
|
||||
loadApiKeys()
|
||||
} catch (error) {
|
||||
appStore.showError(t('keys.failedToDelete'))
|
||||
} catch (error: any) {
|
||||
// 优先使用后端返回的错误消息,提供更具体的错误信息给用户
|
||||
const errorMsg = error?.message || t('keys.failedToDelete')
|
||||
appStore.showError(errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user