✨ 增加脚本回收站功能#1585
Open
CodFrm wants to merge 23 commits into
Open
Conversation
从回收站(trashScript:)彻底销毁脚本及其关联的 scriptCode:/compiled_resource: 数据,并广播既有的 deleteScripts 事件供下游 4 个清理订阅者(value/permission/ resource/favicon)消费。作为回收站功能的销毁终点,暂无生产调用方,由后续任务 接入。
- Toolbar 新增 leading 槽位,tabs 传入后取代「已安装脚本 + 数量」标题 - 回收站顶栏 = tabs + 搜索 + 清空回收站,与已安装 tab 共用同一条 h-14 顶栏 - 保留提示移到 chips 行右侧;批量栏改为独立条件行 - 脚本数量不再丢失:改由 tab 角标显示(已安装 = scriptList.length,回收站 = trashCount) - 回收站为空时仍渲染带 tabs 的顶栏,避免用户被困在回收站 tab
- prepareScriptByCode 在所有活跃表查找之后增查回收站,命中则复用其 uuid 并置 oldInTrash - 复用 uuid 即保住 storageName → value 与权限不丢;移出回收站由 installScript 的 upsert 不变量保证 - InstallView.inTrash 透出;主按钮改为 还原 / 还原并更新(按版本是否变化) - 安装页新增 in_trash_hint 提示条,告知用户还原会保留原有数据
- zh-CN「7 天」→「7天」:对齐同文件既有的「6小时」体例(空格是我在 plan 里带进去的,zh-TW 自由翻译时就没这个问题) - ja-JP「なし」→「無期限」:该行标签是「ゴミ箱の保存期間」,值为「なし」会被读成「不保存/立刻删」,与「永不清理」语义相反
端到端验证真实扩展时发现:删除脚本后「已安装」列表的行不消失、popup 也不更新, 再点一次删除会报「删除失败: scripts not found」。 根因:Task 3 把删除的广播从 deleteScripts 改为 trashScripts 时,只迁移了 SW 侧的 4 个订阅者(spec 统计的「8 个订阅者」只涵盖 SW 侧),漏了两个页面侧的: - ScriptList/hooks.ts —— 负责从「已安装」列表移除该行 - popup/usePopupData.ts —— popup 列表 单元测试全部 mock 掉消息层,跨上下文的 topic 不匹配跑不出来,3165 个用例无一发现。 同时新增静态护栏 trash_event_partition.test.ts 钉死事件二分: - trashScripts(6) = 脚本不再活跃:注销/停 cron/刷 badge/云端删除/列表移行/popup 移行 - deleteScripts(4) = 销毁数据:value/权限/资源/图标(只在彻底删除时触发) 护栏已验证有牙:把任一订阅者订错边,测试立即失败。
Collaborator
|
1584 不用退回嗎 |
Collaborator
呀好像有force push退回? |
Member
Author
是的,退回了 |
Collaborator
|
@CodFrm 刪掉的記錄,特別是代碼部份,可以改用OPFS儲存嗎?? |
Member
Author
确实可以,我调整一下 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
检查清单
描述
测试
截图
trash-ui-ux.zip
备注
此前的 #1584 曾被误操作直接合并;main 已恢复到合并前提交,本 PR 用于重新进行正常审阅。
关联 Issue