fix: 标题库API兼容直接数组返回 + 素材上传弹窗闪退修复
CI/CD Pipeline / Frontend Lint (push) Failing after 37h34m9s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 37h34m9s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1696h9m18s
CI/CD Pipeline / Deploy Production (push) Failing after 1696h9m20s
CI/CD Pipeline / Build Production Runtime Images (push) Failing after 1696h9m22s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (push) Failing after 1696h9m23s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1696h40m47s
CI/CD Pipeline / Frontend Lint (push) Failing after 37h34m9s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 37h34m9s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1696h9m18s
CI/CD Pipeline / Deploy Production (push) Failing after 1696h9m20s
CI/CD Pipeline / Build Production Runtime Images (push) Failing after 1696h9m22s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (push) Failing after 1696h9m23s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1696h40m47s
Issue 2: getTitles() 兼容后端返回直接数组 [...] 和 {items:[...]} 两种格式
Issue 5: beforeUpload 改为同步返回 false(避免 async Promise 不稳定);
上传失败时延迟1.5秒关闭弹窗,让用户能看到错误提示
This commit is contained in:
@@ -68,10 +68,14 @@ export interface CreateTitleRequest {
|
||||
|
||||
/** 获取当前用户的所有标题 */
|
||||
export const getTitles = async (): Promise<TitleItem[]> => {
|
||||
const response = await apiClient.get<{ items: BackendTitleResponse[] }>(
|
||||
"/titles",
|
||||
);
|
||||
return (response.data.items || []).map(toTitleItem);
|
||||
const response = await apiClient.get<
|
||||
{ items: BackendTitleResponse[] } | BackendTitleResponse[]
|
||||
>("/titles");
|
||||
// 兼容两种后端返回格式:{ items: [...] } 或直接 [...]
|
||||
const items = Array.isArray(response.data)
|
||||
? response.data
|
||||
: response.data.items || [];
|
||||
return items.map(toTitleItem);
|
||||
};
|
||||
|
||||
/** 创建标题 */
|
||||
|
||||
Reference in New Issue
Block a user