diff --git a/.commentlint/frontend-baseline.json b/.commentlint/frontend-baseline.json index e797a29..6e8a1ef 100644 --- a/.commentlint/frontend-baseline.json +++ b/.commentlint/frontend-baseline.json @@ -1843,351 +1843,285 @@ }, { "file": "components/CardList.tsx", - "line": 10, - "kind": "member", - "name": "type" - }, - { - "file": "components/CardList.tsx", - "line": 101, - "kind": "variable", - "name": "handleSaveEdit" - }, - { - "file": "components/CardList.tsx", - "line": 11, - "kind": "member", - "name": "content" - }, - { - "file": "components/CardList.tsx", - "line": 115, - "kind": "variable", - "name": "updateData" - }, - { - "file": "components/CardList.tsx", - "line": 12, - "kind": "member", - "name": "description" - }, - { - "file": "components/CardList.tsx", - "line": 13, - "kind": "member", - "name": "enabled" - }, - { - "file": "components/CardList.tsx", - "line": 14, - "kind": "member", - "name": "delay_seconds" - }, - { - "file": "components/CardList.tsx", - "line": 143, + "line": 107, "kind": "variable", "name": "error" }, { "file": "components/CardList.tsx", - "line": 149, + "line": 113, "kind": "variable", "name": "handleDelete" }, { "file": "components/CardList.tsx", - "line": 15, - "kind": "member", - "name": "api_method" - }, - { - "file": "components/CardList.tsx", - "line": 154, + "line": 118, "kind": "variable", "name": "error" }, { "file": "components/CardList.tsx", - "line": 16, - "kind": "member", - "name": "api_timeout" - }, - { - "file": "components/CardList.tsx", - "line": 161, - "kind": "variable", - "name": "handleAddCard" - }, - { - "file": "components/CardList.tsx", - "line": 17, - "kind": "member", - "name": "api_headers" - }, - { - "file": "components/CardList.tsx", - "line": 171, - "kind": "variable", - "name": "payload" - }, - { - "file": "components/CardList.tsx", - "line": 18, - "kind": "member", - "name": "api_params" - }, - { - "file": "components/CardList.tsx", - "line": 194, - "kind": "variable", - "name": "error" - }, - { - "file": "components/CardList.tsx", - "line": 200, - "kind": "variable", - "name": "toggleCardStatus" - }, - { - "file": "components/CardList.tsx", - "line": 204, - "kind": "variable", - "name": "error" - }, - { - "file": "components/CardList.tsx", - "line": 209, - "kind": "variable", - "name": "copyCardID" - }, - { - "file": "components/CardList.tsx", - "line": 218, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 218, - "kind": "variable", - "name": "dataCards" - }, - { - "file": "components/CardList.tsx", - "line": 219, - "kind": "variable", - "name": "filteredCards" - }, - { - "file": "components/CardList.tsx", - "line": 22, - "kind": "member", - "name": "api_url" - }, - { - "file": "components/CardList.tsx", - "line": 220, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 224, - "kind": "variable", - "name": "downloadCardTemplate" - }, - { - "file": "components/CardList.tsx", - "line": 225, - "kind": "variable", - "name": "headers" - }, - { - "file": "components/CardList.tsx", - "line": 226, - "kind": "variable", - "name": "rows" - }, - { - "file": "components/CardList.tsx", - "line": 23, - "kind": "member", - "name": "api_method" - }, - { - "file": "components/CardList.tsx", - "line": 231, - "kind": "variable", - "name": "csv" - }, - { - "file": "components/CardList.tsx", - "line": 232, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 232, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 234, - "kind": "variable", - "name": "blob" - }, - { - "file": "components/CardList.tsx", - "line": 235, - "kind": "variable", - "name": "url" - }, - { - "file": "components/CardList.tsx", - "line": 236, - "kind": "variable", - "name": "link" - }, - { - "file": "components/CardList.tsx", - "line": 24, - "kind": "member", - "name": "api_timeout" - }, - { - "file": "components/CardList.tsx", - "line": 245, - "kind": "variable", - "name": "handleBatchCreate" - }, - { - "file": "components/CardList.tsx", - "line": 25, - "kind": "member", - "name": "api_headers" - }, - { - "file": "components/CardList.tsx", - "line": 250, - "kind": "variable", - "name": "res" - }, - { - "file": "components/CardList.tsx", - "line": 253, - "kind": "variable", - "name": "fresh" - }, - { - "file": "components/CardList.tsx", - "line": 256, - "kind": "variable", - "name": "e" - }, - { - "file": "components/CardList.tsx", - "line": 26, - "kind": "member", - "name": "api_params" - }, - { - "file": "components/CardList.tsx", - "line": 263, - "kind": "variable", - "name": "handleBatchAppend" - }, - { - "file": "components/CardList.tsx", - "line": 268, - "kind": "variable", - "name": "res" - }, - { - "file": "components/CardList.tsx", - "line": 271, - "kind": "variable", - "name": "fresh" - }, - { - "file": "components/CardList.tsx", - "line": 273, - "kind": "variable", - "name": "e" - }, - { - "file": "components/CardList.tsx", - "line": 280, - "kind": "variable", - "name": "openBatchModal" - }, - { - "file": "components/CardList.tsx", - "line": 29, + "line": 12, "kind": "variable", "name": "emptyAddForm" }, { "file": "components/CardList.tsx", - "line": 306, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 323, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 340, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 363, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 367, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 367, + "line": 125, "kind": "variable", - "name": "lines" + "name": "handleAddCard" }, { "file": "components/CardList.tsx", - "line": 389, + "line": 135, + "kind": "variable", + "name": "payload" + }, + { + "file": "components/CardList.tsx", + "line": 158, + "kind": "variable", + "name": "error" + }, + { + "file": "components/CardList.tsx", + "line": 164, + "kind": "variable", + "name": "toggleCardStatus" + }, + { + "file": "components/CardList.tsx", + "line": 168, + "kind": "variable", + "name": "error" + }, + { + "file": "components/CardList.tsx", + "line": 173, + "kind": "variable", + "name": "copyCardID" + }, + { + "file": "components/CardList.tsx", + "line": 182, + "kind": "variable", + "name": "filteredCards" + }, + { + "file": "components/CardList.tsx", + "line": 183, "kind": "function-expression", "name": "anonymous" }, { "file": "components/CardList.tsx", - "line": 42, + "line": 187, + "kind": "variable", + "name": "downloadCardTemplate" + }, + { + "file": "components/CardList.tsx", + "line": 188, + "kind": "variable", + "name": "headers" + }, + { + "file": "components/CardList.tsx", + "line": 189, + "kind": "variable", + "name": "rows" + }, + { + "file": "components/CardList.tsx", + "line": 194, + "kind": "variable", + "name": "csv" + }, + { + "file": "components/CardList.tsx", + "line": 195, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 195, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 197, + "kind": "variable", + "name": "blob" + }, + { + "file": "components/CardList.tsx", + "line": 198, + "kind": "variable", + "name": "url" + }, + { + "file": "components/CardList.tsx", + "line": 199, + "kind": "variable", + "name": "link" + }, + { + "file": "components/CardList.tsx", + "line": 224, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 241, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 25, "kind": "variable", "name": "CardList" }, { "file": "components/CardList.tsx", - "line": 424, + "line": 258, "kind": "function-expression", "name": "anonymous" }, { "file": "components/CardList.tsx", - "line": 43, + "line": 26, "kind": "variable", - "name": "[cards, setCards]" + "name": "{ cards, loadCards }" + }, + { + "file": "components/CardList.tsx", + "line": 27, + "kind": "variable", + "name": "[showEditModal, setShowEditModal]" + }, + { + "file": "components/CardList.tsx", + "line": 28, + "kind": "variable", + "name": "[showAddModal, setShowAddModal]" + }, + { + "file": "components/CardList.tsx", + "line": 281, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 285, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 285, + "kind": "variable", + "name": "lines" + }, + { + "file": "components/CardList.tsx", + "line": 29, + "kind": "variable", + "name": "[selectedCard, setSelectedCard]" + }, + { + "file": "components/CardList.tsx", + "line": 30, + "kind": "variable", + "name": "[editForm, setEditForm]" + }, + { + "file": "components/CardList.tsx", + "line": 307, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 31, + "kind": "variable", + "name": "[addForm, setAddForm]" + }, + { + "file": "components/CardList.tsx", + "line": 33, + "kind": "variable", + "name": "[typeFilter, setTypeFilter]" + }, + { + "file": "components/CardList.tsx", + "line": 34, + "kind": "variable", + "name": "[nameSearch, setNameSearch]" + }, + { + "file": "components/CardList.tsx", + "line": 342, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 355, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 36, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 36, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 362, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 37, + "kind": "variable", + "name": "batchState" + }, + { + "file": "components/CardList.tsx", + "line": 39, + "kind": "variable", + "name": "handleEdit" + }, + { + "file": "components/CardList.tsx", + "line": 391, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 407, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 416, + "kind": "function-expression", + "name": "anonymous" }, { "file": "components/CardList.tsx", @@ -2197,387 +2131,189 @@ }, { "file": "components/CardList.tsx", - "line": 44, + "line": 447, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 459, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 470, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 479, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 495, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 511, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 517, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 532, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 545, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 559, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 575, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 586, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 604, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 633, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 648, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 65, "kind": "variable", - "name": "[showEditModal, setShowEditModal]" + "name": "handleSaveEdit" }, { "file": "components/CardList.tsx", - "line": 444, + "line": 659, "kind": "function-expression", "name": "anonymous" }, { "file": "components/CardList.tsx", - "line": 45, + "line": 667, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 675, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 692, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 700, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 707, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 713, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 722, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 729, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 735, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 739, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 748, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 752, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 762, + "kind": "function-expression", + "name": "anonymous" + }, + { + "file": "components/CardList.tsx", + "line": 79, "kind": "variable", - "name": "[showAddModal, setShowAddModal]" - }, - { - "file": "components/CardList.tsx", - "line": 46, - "kind": "variable", - "name": "[selectedCard, setSelectedCard]" - }, - { - "file": "components/CardList.tsx", - "line": 47, - "kind": "variable", - "name": "[editForm, setEditForm]" - }, - { - "file": "components/CardList.tsx", - "line": 473, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 48, - "kind": "variable", - "name": "[addForm, setAddForm]" - }, - { - "file": "components/CardList.tsx", - "line": 489, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 498, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 519, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 52, - "kind": "variable", - "name": "[batchTab, setBatchTab]" - }, - { - "file": "components/CardList.tsx", - "line": 529, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 53, - "kind": "variable", - "name": "[batchFile, setBatchFile]" - }, - { - "file": "components/CardList.tsx", - "line": 54, - "kind": "variable", - "name": "[batchResult, setBatchResult]" - }, - { - "file": "components/CardList.tsx", - "line": 541, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 55, - "kind": "variable", - "name": "[batchBusy, setBatchBusy]" - }, - { - "file": "components/CardList.tsx", - "line": 552, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 56, - "kind": "variable", - "name": "[appendTargetId, setAppendTargetId]" - }, - { - "file": "components/CardList.tsx", - "line": 561, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 57, - "kind": "variable", - "name": "[appendContent, setAppendContent]" - }, - { - "file": "components/CardList.tsx", - "line": 577, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 58, - "kind": "member", - "name": "added" - }, - { - "file": "components/CardList.tsx", - "line": 58, - "kind": "variable", - "name": "[appendResult, setAppendResult]" - }, - { - "file": "components/CardList.tsx", - "line": 59, - "kind": "variable", - "name": "[typeFilter, setTypeFilter]" - }, - { - "file": "components/CardList.tsx", - "line": 593, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 599, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 60, - "kind": "variable", - "name": "[nameSearch, setNameSearch]" - }, - { - "file": "components/CardList.tsx", - "line": 614, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 62, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 627, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 641, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 657, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 66, - "kind": "member", - "name": "type" - }, - { - "file": "components/CardList.tsx", - "line": 66, - "kind": "variable", - "name": "CardIcon" - }, - { - "file": "components/CardList.tsx", - "line": 668, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 686, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 715, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 730, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 741, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 749, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 75, - "kind": "variable", - "name": "handleEdit" - }, - { - "file": "components/CardList.tsx", - "line": 757, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 774, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 782, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 789, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 795, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 804, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 811, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 817, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 821, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 830, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 834, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 844, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 870, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 881, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 888, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 9, - "kind": "member", - "name": "name" - }, - { - "file": "components/CardList.tsx", - "line": 913, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 923, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 923, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 943, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 946, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 955, - "kind": "function-expression", - "name": "anonymous" - }, - { - "file": "components/CardList.tsx", - "line": 974, - "kind": "function-expression", - "name": "anonymous" + "name": "updateData" }, { "file": "components/cardListState.test.ts", @@ -2603,24 +2339,6 @@ "kind": "variable", "name": "cards" }, - { - "file": "components/cardListState.ts", - "line": 3, - "kind": "variable", - "name": "filterCards" - }, - { - "file": "components/cardListState.ts", - "line": 8, - "kind": "variable", - "name": "keyword" - }, - { - "file": "components/cardListState.ts", - "line": 9, - "kind": "function-expression", - "name": "anonymous" - }, { "file": "components/Chat.tsx", "line": 101, diff --git a/docs/architecture/refactoring-master-plan.md b/docs/architecture/refactoring-master-plan.md index faf5278..a265a15 100644 --- a/docs/architecture/refactoring-master-plan.md +++ b/docs/architecture/refactoring-master-plan.md @@ -172,7 +172,8 @@ app shell / routes - 已完成阶段 7 第一个 PR 切片“React Rules feature 化与 API/行为测试边界”:按 `app/features/rules` 提取 Rules API 适配层、领域类型、数据 Hook、异常面板和交互状态模型;规则页通过 Hook 管理服务端数据与请求代次,保留旧组件入口和现有 API 路径;行为测试覆盖成功、失败、重复提交、过期响应和页签切换;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; - 已完成阶段 7 第二个 PR 切片“React ItemList feature 化与批量发布行为边界”:按 `app/features/items` 提取商品/批量 API 适配层、批量任务类型、批量 Hook 和阶段指示器组件;批量预检、任务恢复、轮询取消、失败重试和过期响应均由 feature 状态边界负责;行为测试覆盖预检门禁、取消状态、失败重试、历史任务筛选和过期轮询响应;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; - 已完成阶段 7 第三个 PR 切片“React AccountList feature 化与账号运行状态行为边界”:按 `app/features/accounts` 提取账号 API 适配层、账号数据与运行状态 Hook、运行状态展示模型、账号编辑弹窗和登录/暂停状态模型;账号加载与运行状态轮询支持取消和请求代次门禁,密码登录响应按账号与代次隔离,旧组件入口保留兼容转发;行为测试覆盖账号切换、暂停/恢复、凭证失败、风控验证和过期响应;前端类型检查、全量测试、注释检查和构建门禁通过,合并为一个可回滚提交; -- 阶段 7 下一 PR 切片为“React CardList feature 化与卡密库存/批量追加行为边界”:提取卡密 API、库存 Hook 和批量追加组件,补充卡密筛选、追加预览、提交取消、失败重试和账号切换过期响应测试; +- 已完成阶段 7 第四个 PR 切片“React CardList feature 化与卡密库存/批量追加行为边界”:按 `app/features/cards` 提取卡密 API 适配层、库存数据 Hook、批量导入/追加状态 Hook 和弹窗组件;卡密筛选、追加预览、提交取消、失败重试与账号切换过期响应均由 feature 状态边界负责,保留旧组件入口和 API 路径;新增状态模型测试并通过前端类型检查、全量测试、注释检查和构建门禁,合并为一个可回滚提交; +- 阶段 7 下一 PR 切片为“React OrderList feature 化与订单导入/刷新行为边界”:提取订单 API、导入/刷新 Hook 和订单筛选组件,补充导入预检、刷新取消、失败重试和过期响应测试; - 禁止跳过当前入口直接开始 Engine、Automation 或 DB 的大规模拆分。 ## 6. 阶段 0:治理文档与强约束 @@ -594,3 +595,4 @@ npm --prefix frontend run build | 2026-08-14 | 完成阶段 7 第一个 PR 切片“React Rules feature 化与 API/行为测试边界” | 新增 `app/features/rules` 的 API 适配层、领域类型、数据 Hook、异常面板和交互状态模型;规则请求支持并行加载与请求代次门禁,保存动作阻断重复提交;行为测试覆盖成功、失败、重复提交、过期响应和页签切换;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React ItemList feature 化与批量发布行为边界 | | 2026-08-14 | 完成阶段 7 第二个 PR 切片“React ItemList feature 化与批量发布行为边界” | 新增 `app/features/items` 的 API 适配层、批量任务类型、批量 Hook、批量状态模型和阶段指示器组件;批量预检、任务恢复、轮询过期响应、安全取消和失败重试均有独立状态边界;行为测试覆盖预检门禁、取消状态、失败重试、历史任务筛选和过期轮询响应;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React AccountList feature 化与账号运行状态行为边界 | | 2026-08-15 | 完成阶段 7 第三个 PR 切片“React AccountList feature 化与账号运行状态行为边界” | 新增 `app/features/accounts` 的 API 适配层、账号数据与运行状态 Hook、账号编辑弹窗、登录/暂停状态模型;账号加载和运行状态轮询具备取消与代次门禁,密码登录响应按账号与代次隔离,兼容入口保留;行为测试覆盖账号切换、暂停/恢复、凭证失败、风控验证和过期响应;前端类型检查、全量测试、注释检查和构建门禁通过并合并为一个可回滚提交 | 阶段 7:React CardList feature 化与卡密库存/批量追加行为边界 | +| 2026-08-15 | 完成阶段 7 第四个 PR 切片“React CardList feature 化与卡密库存/批量追加行为边界” | 按 `app/features/cards` 提取卡密 API 适配层、库存数据 Hook、批量导入/追加状态 Hook 和弹窗组件;卡密筛选、追加预览、提交取消、失败重试与账号切换过期响应均由 feature 状态边界负责,保留旧组件入口和 API 路径;新增状态模型测试并通过前端类型检查、全量测试、注释检查和构建门禁,合并为一个可回滚提交 | 阶段 7:React OrderList feature 化与订单导入/刷新行为边界 | diff --git a/frontend/app/features/cards/api.ts b/frontend/app/features/cards/api.ts new file mode 100644 index 0000000..fe1008f --- /dev/null +++ b/frontend/app/features/cards/api.ts @@ -0,0 +1,12 @@ +// 卡密 feature 只通过本适配层访问库存和批量接口,页面不直接依赖共享 API 文件。 +export { + appendCardData, + batchCreateCards, + createCard, + deleteCard, + getCards, + updateCard, +} from '../../../services/api'; + +// 卡密 feature 重新导出接口响应类型,保持批量结果契约稳定。 +export type { CardAppendResponse, CardBatchResponse } from '../../../types'; diff --git a/frontend/app/features/cards/batchState.test.ts b/frontend/app/features/cards/batchState.test.ts new file mode 100644 index 0000000..75ad906 --- /dev/null +++ b/frontend/app/features/cards/batchState.test.ts @@ -0,0 +1,34 @@ +import { expect, test } from 'vitest'; +import type { Card } from '../../../types'; +import { canSubmitAppend, filterCards, isCurrentCardRequest, previewAppendContent } from './batchState'; + +// cards 是卡密筛选测试使用的最小卡密组列表。 +const cards = [ + { id: 1, name: '年终总结 PPT', type: 'text', enabled: true }, + { id: 2, name: '年终总结兑换码', type: 'data', enabled: true }, + { id: 3, name: '产品介绍 PPT', type: 'text', enabled: false }, +] as Card[]; + +test('卡密筛选同时满足类型和名称条件', + // 类型和名称筛选必须使用 AND 语义,避免展示无关库存。 + () => { + expect(filterCards(cards, 'text', '年终')).toEqual([cards[0]]); + expect(filterCards(cards, '', ' ppt ')).toEqual([cards[0], cards[2]]); + }); + +test('追加预览会去除空行并裁剪每行空白', + // 预览数量与最终提交内容共用同一套规范化规则。 + () => { + expect(previewAppendContent(' VIP-001\n\nVIP-002 \n ')).toEqual(['VIP-001', 'VIP-002']); + expect(canSubmitAppend('2', ' VIP-001\n', false)).toBe(true); + expect(canSubmitAppend('2', '\n', false)).toBe(false); + expect(canSubmitAppend('2', 'VIP-001', true)).toBe(false); + }); + +test('追加目标切换后拒绝旧请求响应和旧代次响应', + // 用户切换卡密组或关闭弹窗后,旧追加请求不能覆盖当前状态。 + () => { + expect(isCurrentCardRequest(3, 3, '2', '2')).toBe(true); + expect(isCurrentCardRequest(2, 3, '2', '2')).toBe(false); + expect(isCurrentCardRequest(3, 3, '2', '3')).toBe(false); + }); diff --git a/frontend/app/features/cards/batchState.ts b/frontend/app/features/cards/batchState.ts new file mode 100644 index 0000000..c5b25f5 --- /dev/null +++ b/frontend/app/features/cards/batchState.ts @@ -0,0 +1,40 @@ +import type { Card } from '../../../types'; + +// filterCards 按类型和名称筛选卡密组,两个条件同时满足才保留。 +export const filterCards = ( + cards: Card[], + typeFilter: Card['type'] | '', + nameSearch: string, +): Card[] => { + // keyword 是去除首尾空格并转为小写的名称搜索词。 + const keyword = nameSearch.trim().toLocaleLowerCase(); + return cards.filter( + // card 是待判断是否符合筛选条件的卡密组。 + card => ( + (!typeFilter || card.type === typeFilter) + && (!keyword || card.name.toLocaleLowerCase().includes(keyword)) + ), + ); +}; + +// previewAppendContent 将追加文本转换为去除空行后的卡密预览列表。 +export const previewAppendContent = (content: string): string[] => content + .split('\n') + .map( + // line 是追加文本中的单行原始内容。 + line => line.trim(), + ) + .filter(Boolean); + +// canSubmitAppend 判断当前追加表单是否具备目标卡密组和有效内容。 +export const canSubmitAppend = (targetId: string, content: string, busy: boolean): boolean => Boolean( + targetId && previewAppendContent(content).length > 0 && !busy, +); + +// isCurrentCardRequest 判断卡密目标切换后响应是否仍属于当前请求。 +export const isCurrentCardRequest = ( + requestGeneration: number, + currentGeneration: number, + requestTargetId: string, + currentTargetId: string, +): boolean => requestGeneration === currentGeneration && requestTargetId === currentTargetId; diff --git a/frontend/app/features/cards/components/BatchCardImportModal.tsx b/frontend/app/features/cards/components/BatchCardImportModal.tsx new file mode 100644 index 0000000..1633636 --- /dev/null +++ b/frontend/app/features/cards/components/BatchCardImportModal.tsx @@ -0,0 +1,152 @@ +import React from 'react'; +import { createPortal } from 'react-dom'; +import { FileDown, ListPlus, Loader2, Plus, Upload, X } from 'lucide-react'; +import type { Card } from '../../../../types'; +import type { CardBatchModalProps } from '../types'; + +// BatchCardImportModal 负责卡密批量创建和单组库存追加的交互界面。 +export const BatchCardImportModal: React.FC = ({ + dataCards, + downloadCardTemplate, + ...state +}) => { + // handleFileChange 保存用户选择的批量导入文件。 + const handleFileChange = (event: React.ChangeEvent) => { + state.setBatchFile(event.target.files?.[0] || null); + }; + // handleAppendContentChange 更新追加文本并保留原始换行,预览由 Hook 派生。 + const handleAppendContentChange = (event: React.ChangeEvent) => { + state.setAppendContent(event.target.value); + }; + // handleTargetChange 切换追加库存目标卡密组。 + const handleTargetChange = (event: React.ChangeEvent) => { + state.setAppendTargetId(event.target.value); + }; + // handleClose 关闭弹窗并取消当前批量请求。 + const handleClose = () => state.closeBatchModal(); + // handleCreateTab 切换到批量创建页签。 + const handleCreateTab = () => state.setBatchTab('create'); + // handleAppendTab 切换到库存追加页签。 + const handleAppendTab = () => state.setBatchTab('append'); + // handleRetryCreate 重试最近一次批量创建。 + const handleRetryCreate = () => void state.handleRetryBatchCreate(); + // handleRetryAppend 重试最近一次库存追加。 + const handleRetryAppend = () => void state.handleRetryBatchAppend(); + // completedBatchResult 只保留包含逐行统计的成功批量结果。 + const completedBatchResult = state.batchResult && 'rows' in state.batchResult ? state.batchResult : null; + // renderCardOption 渲染追加目标卡密组的下拉选项。 + const renderCardOption = (card: Card) => ; + // handleSubmitCreate 提交批量创建请求。 + const handleSubmitCreate = () => void state.handleBatchCreate(); + // handleSubmitAppend 提交批量追加请求。 + const handleSubmitAppend = () => void state.handleBatchAppend(); + + if (!state.showBatchModal) return null; + + return createPortal( +
+
+
+

批量导入卡密

+ +
+ +
+
+ + +
+ + {state.batchTab === 'create' ? ( +
+
+ 上传表格,每行一个卡密组。表头:名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值。 + 类型填 text/data/image;data 类型的“内容”按行存卡密(CSV 单元格内换行需用引号包裹)。 +
+
+ + +
+ {state.batchResult?.error && ( +
+ {state.batchResult.error} + +
+ )} + {completedBatchResult && ( +
+
共 {completedBatchResult.total} 行 · 成功 {completedBatchResult.created} · 失败 {completedBatchResult.failed}
+ {completedBatchResult.failed > 0 && ( +
+ {completedBatchResult.rows.filter( + // row 是批量结果中的单行处理记录。 + row => !row.success, + ).map( + // row 是待展示失败说明的单行结果。 + row => ( +
第 {row.row_no} 行「{row.name}」:{row.error}
+ ), + )} +
+ )} +
+ )} +
+ ) : ( +
+ {dataCards.length === 0 ? ( +
暂无 data(批量卡密)类型的卡密组,请先创建一个再充卡密。
+ ) : ( + <> +
+ + +
+
+ +