fix: 修复右键菜单功能的多个逻辑漏洞

1. 修复时区硬编码问题 - 使用用户选择的时区而非固定 Asia/Shanghai
2. 修复 openPopup() 失败后数据残留 - 失败时清除 storage 中的待处理数据
3. 统一数据过期时间常量 - 导出 CONTEXT_MENU_DATA_EXPIRY_MS 并统一使用
4. 修复 featureKey 类型断言不安全 - 使用映射表处理非常规菜单 ID
This commit is contained in:
雨霖铃
2026-05-20 21:39:33 +08:00
parent e9a6fa3dd8
commit 0427f16cc9
5 changed files with 62 additions and 45 deletions
+2
View File
@@ -41,6 +41,8 @@ export default defineBackground(() => {
await browser.action.openPopup();
} catch (err) {
console.error('[Context Menu] 打开 popup 失败:', err);
// 打开失败时清除残留数据,避免下次打开 popup 时误触发
await chrome.storage.local.remove('contextMenu/pendingData');
}
});