mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 02:17:46 +08:00
refactor: 前端全面替换 any 为 unknown 并统一错误处理,后端用量记录补写请求头/体
- 前端 API 层、stores、conversation 解析器、组件全面替换 any 为 unknown/具体类型 - 错误处理统一使用 parseApiError/getErrorStatus 替代 err.response?.data?.detail 模式 - 后端 handler/TaskService/UsageLifecycle/StreamTracker 链路传递 request_headers/request_body - streaming/pending 状态更新时可补写客户端和提供商的请求头及请求体 - 新增 TaskService 和 UsageService 相关测试
This commit is contained in:
@@ -191,7 +191,7 @@ import Button from '@/components/ui/button.vue'
|
||||
import Badge from '@/components/ui/badge.vue'
|
||||
import Checkbox from '@/components/ui/checkbox.vue'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import { parseUpstreamModelError } from '@/utils/errorParser'
|
||||
import { parseApiError, parseUpstreamModelError } from '@/utils/errorParser'
|
||||
import {
|
||||
importModelsFromUpstream,
|
||||
getProviderModels,
|
||||
@@ -305,9 +305,8 @@ async function fetchUpstreamModels() {
|
||||
// 上游返回空列表但无错误
|
||||
hasQueried.value = true
|
||||
}
|
||||
} catch (err: any) {
|
||||
const rawError = err.response?.data?.detail || err.message || '获取上游模型失败'
|
||||
errorMessage.value = parseUpstreamModelError(rawError)
|
||||
} catch (err: unknown) {
|
||||
errorMessage.value = parseUpstreamModelError(parseApiError(err, '获取上游模型失败'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -378,8 +377,8 @@ async function handleImport() {
|
||||
const errorMsg = response.errors?.[0]?.error || '导入失败'
|
||||
showError(errorMsg, '导入失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
showError(err.response?.data?.detail || '导入失败', '错误')
|
||||
} catch (err: unknown) {
|
||||
showError(parseApiError(err, '导入失败'), '错误')
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user