Add context menus

This commit is contained in:
2026-02-16 23:32:20 +08:00
parent fbc9269e81
commit 1353ddf174
2 changed files with 18 additions and 1 deletions

View File

@@ -69,7 +69,8 @@
"page": "dist/settings.html"
},
"permissions": [
"storage"
"storage",
"contextMenus"
],
"background": {
"service_worker": "dist/background.js",

View File

@@ -41,3 +41,19 @@ chrome.runtime.onMessage.addListener((message: SendMessage, sender, sendResponse
return true; // Indicates that the response will be sent asynchronously
}
});
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: 'manage',
title: '管理数据库',
contexts: ['action'],
});
});
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === 'manage') {
chrome.tabs.create({
url: chrome.runtime.getURL('dist/manage.html'),
})
}
});