refactor(api): migrate expression-api to ApiResponse pattern

- Migrated all 11 functions in expression-api.ts to return Promise<ApiResponse<T>>
- Implemented manual response handling following person-api pattern
- Properly unwrap nested API responses and re-wrap in ApiResponse
- Updated all 16 call sites across 4 files with proper error handling
- Fixed type annotations (ChatInfo) in expression.tsx
- Build passes successfully with no TypeScript errors
- Follows AGENTS.md import conventions and Wave 2 constraints
- All HTTP and API-level errors handled consistently via ApiResponse
This commit is contained in:
DrSmoothl
2026-03-01 17:26:34 +08:00
parent c863d5a3be
commit 88e157040f
7 changed files with 812 additions and 199 deletions

View File

@@ -16,16 +16,16 @@ export function useChatNameMap() {
const loadChatNameMap = useCallback(async () => {
try {
setLoading(true)
const response = await getChatList()
if (response?.data) {
const result = await getChatList()
if (result.success) {
const nameMap = new Map<string, string>()
response.data.forEach((chat: ChatInfo) => {
result.data.forEach((chat: ChatInfo) => {
nameMap.set(chat.chat_id, chat.chat_name)
})
setChatNameMap(nameMap)
}
} catch (error) {
console.error('加载天列表失败:', error)
console.error('加载天列表失败:', error)
} finally {
setLoading(false)
}