Skip to content

Commit 59b1bb7

Browse files
committed
避免 menuCommand 更新在 Tab 移除后触发
1 parent 066da8d commit 59b1bb7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/app/service/service_worker/popup.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export class PopupService {
179179

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

184183
// 此函数必须是同步执行的,避免updateMenuCommands并发问题
185184
updateMenuCommand(tabId: number, data: ScriptMenu[]): string[] {
@@ -579,6 +578,12 @@ export class PopupService {
579578
}
580579
runCountMap.delete(tabId);
581580
scriptCountMap.delete(tabId);
581+
const list = this.updateMenuCommands.get(tabId);
582+
if (list) {
583+
// 避免 menuCommand 更新在 Tab 移除后触发
584+
list.length = 0;
585+
this.updateMenuCommands.delete(tabId);
586+
}
582587
// 清理数据tab关闭需要释放的数据
583588
this.txUpdateScriptMenu(tabId, async (scripts) => {
584589
for (const { uuid } of scripts) {

0 commit comments

Comments
 (0)