Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/service/service_worker/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export class PopupService {

// 防止并发导致频繁更新菜单,将注册菜单的请求集中在一个队列中处理
updateMenuCommands = new Map<number, ((TScriptMenuRegister | TScriptMenuUnregister) & { registerType: number })[]>();
isUpdateMenuDirty = false;

// 此函数必须是同步执行的,避免updateMenuCommands并发问题
updateMenuCommand(tabId: number, data: ScriptMenu[]): string[] {
Expand Down Expand Up @@ -579,6 +578,12 @@ export class PopupService {
}
runCountMap.delete(tabId);
scriptCountMap.delete(tabId);
const list = this.updateMenuCommands.get(tabId);
if (list) {
// 避免 menuCommand 更新在 Tab 移除后触发
list.length = 0;
Comment thread
CodFrm marked this conversation as resolved.
this.updateMenuCommands.delete(tabId);
}
Copy link
Copy Markdown
Member

@CodFrm CodFrm Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我理解 this.updateMenuCommand 在 updateMenuCommand 最后面肯定会删除的,且updateMenuCommand是一个同步函数,这实际是一个无效操作

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

呀。原来现在是 ScriptMenu 没删 (${CACHE_KEY_TAB_SCRIPT}${tabId}
对。会跑。所以如果推了10个registerMenu, onRemoved 后才执行,那么就会变成在 script.menus 里残留

// 清理数据tab关闭需要释放的数据
this.txUpdateScriptMenu(tabId, async (scripts) => {
for (const { uuid } of scripts) {
Expand Down
Loading