fix: 修复素材库批量删除后白屏崩溃 #509

Merged
xiaoxia merged 2 commits from fix/asset-batch-delete-crash into develop 2026-07-18 15:21:04 +08:00
Owner

问题

批量删除素材后页面白屏,报错:Cannot read properties of undefined (reading 'length')

根因

batchDeleteAssets 直接返回 response.data,当后端返回字段缺失或格式不一致时,Drawer 中 operationResult.succeeded.length 会因 succeeded 为 undefined 而崩溃,导致整个页面白屏。

修复

  1. API 层:新增 normalizeBatchResult() 工具函数,统一归一化 4 个批量操作(删除/打标签/改分类/智能标记)返回值,succeeded/failed 缺失时默认空数组,success_count/failure_count/total 缺失时根据数组长度推导
  2. 组件层apiAssets / apiLibraries 增加 Array.isArray 防御性检查,非数组时兜底为空数组

验证场景

  • 删除全部素材
  • 删除部分素材
  • 删除后再上传
### 问题 批量删除素材后页面白屏,报错:`Cannot read properties of undefined (reading 'length')` ### 根因 `batchDeleteAssets` 直接返回 `response.data`,当后端返回字段缺失或格式不一致时,Drawer 中 `operationResult.succeeded.length` 会因 `succeeded` 为 undefined 而崩溃,导致整个页面白屏。 ### 修复 1. **API 层**:新增 `normalizeBatchResult()` 工具函数,统一归一化 4 个批量操作(删除/打标签/改分类/智能标记)返回值,`succeeded`/`failed` 缺失时默认空数组,`success_count`/`failure_count`/`total` 缺失时根据数组长度推导 2. **组件层**:`apiAssets` / `apiLibraries` 增加 `Array.isArray` 防御性检查,非数组时兜底为空数组 ### 验证场景 - 删除全部素材 ✅ - 删除部分素材 ✅ - 删除后再上传 ✅
xiaoxia added 1 commit 2026-07-18 14:27:37 +08:00
fix: 修复素材库批量删除后白屏崩溃,批量操作结果归一化 + 列表防御性检查
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 27s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 52s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Successful in 57s
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Successful in 1m1s
AI Code Review / AI Code Review (pull_request) Successful in 1m22s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
8166f2c939
根因:batchDeleteAssets 直接返回 response.data,当后端返回字段缺失或格式不一致时,
Drawer 中 operationResult.succeeded.length 会报 Cannot read properties of undefined (reading 'length'),
导致整个页面白屏崩溃。

修复:
1. API 层新增 normalizeBatchResult(),统一归一化4个批量操作返回值,succeeded/failed 缺失时默认空数组
2. AssetLibrary 组件层增加 Array.isArray 防御,apiAssets / apiLibraries 非数组时兜底为空数组
3. 覆盖场景:删除全部素材、删除部分素材、删除后再上传,均不会白屏
xiaoxia added 1 commit 2026-07-18 15:18:39 +08:00
style: fix prettier formatting in assets.ts
CI Build & Deploy Pipeline / Build Staging API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Staging Worker Image (pull_request) Has been skipped
Auto Approve CI PRs / Auto Approve on CI Green (pull_request) Failing after 0s
Auto Merge CI PRs / Auto Merge on CI Green + Approved (pull_request) Failing after 0s
CI Build & Deploy Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production API Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Web Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI Build & Deploy Pipeline / Deploy Production (pull_request) Has been skipped
CI Build & Deploy Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 7s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 45s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 44s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 12s
4a73d810d2
xiaoxia merged commit 57d708d8c5 into develop 2026-07-18 15:21:04 +08:00

🗑️ 预览环境已清理

PR #509 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #509 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.