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:
fawney19
2026-02-22 00:43:41 +08:00
parent 98e60e8f74
commit cf2eee222e
121 changed files with 1652 additions and 1179 deletions

View File

@@ -60,10 +60,12 @@
class="oauth-btn"
@click="handleOAuthLogin(oauthProviders[0].provider_type)"
>
<!-- eslint-disable vue/no-v-html -->
<span
class="oauth-icon"
v-html="getOAuthIcon(oauthProviders[0].provider_type)"
/>
<!-- eslint-enable vue/no-v-html -->
<span>使用 {{ oauthProviders[0].display_name }} 登录</span>
</button>
</div>
@@ -83,10 +85,12 @@
:title="p.display_name"
@click="handleOAuthLogin(p.provider_type)"
>
<!-- eslint-disable vue/no-v-html -->
<span
class="oauth-icon-lg"
v-html="getOAuthIcon(p.provider_type)"
/>
<!-- eslint-enable vue/no-v-html -->
</button>
</div>
</div>

View File

@@ -222,6 +222,7 @@
import { ref, computed, watch, onUnmounted, nextTick } from 'vue'
import { authApi } from '@/api/auth'
import { useToast } from '@/composables/useToast'
import { parseApiError } from '@/utils/errorParser'
import { Dialog } from '@/components/ui'
import Button from '@/components/ui/button.vue'
import Input from '@/components/ui/input.vue'
@@ -576,12 +577,8 @@ const handleSendCode = async () => {
} else {
showError(response.message || '请稍后重试', '发送失败')
}
} catch (error: any) {
const errorMsg = error.response?.data?.detail
|| error.response?.data?.error?.message
|| error.message
|| '网络错误,请重试'
showError(errorMsg, '发送失败')
} catch (error: unknown) {
showError(parseApiError(error, '网络错误,请重试'), '发送失败')
} finally {
isSendingCode.value = false
}
@@ -609,13 +606,9 @@ const handleCodeComplete = async (code: string) => {
// Clear the code input
clearCodeInputs()
}
} catch (error: any) {
} catch (error: unknown) {
verificationError.value = true
const errorMsg = error.response?.data?.detail
|| error.response?.data?.error?.message
|| error.message
|| '验证码错误,请重试'
showError(errorMsg, '验证失败')
showError(parseApiError(error, '验证码错误,请重试'), '验证失败')
// Clear the code input
clearCodeInputs()
} finally {
@@ -662,12 +655,8 @@ const handleSubmit = async () => {
emit('success')
isOpen.value = false
} catch (error: any) {
const errorMsg = error.response?.data?.detail
|| error.response?.data?.error?.message
|| error.message
|| '注册失败,请重试'
showError(errorMsg, '注册失败')
} catch (error: unknown) {
showError(parseApiError(error, '注册失败,请重试'), '注册失败')
} finally {
isLoading.value = false
}