feat: add inspect option to context menu with localization support (#5807)

* implemented a new inspect menu item in the context menu that toggles developer tools
* added localization for the inspect option in English, Japanese, Russian, and Chinese (both simplified and traditional)
This commit is contained in:
beyondkmp 2025-05-09 22:12:16 +08:00 committed by GitHub
parent 3697b31c7b
commit 3a36da1bf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 1 deletions

View File

@ -9,12 +9,29 @@ class ContextMenu {
const template: MenuItemConstructorOptions[] = this.createEditMenuItems(properties)
const filtered = template.filter((item) => item.visible !== false)
if (filtered.length > 0) {
const menu = Menu.buildFromTemplate(filtered)
const menu = Menu.buildFromTemplate([...filtered, ...this.createInspectMenuItems(w)])
menu.popup()
}
})
}
private createInspectMenuItems(w: Electron.BrowserWindow): MenuItemConstructorOptions[] {
const locale = locales[configManager.getLanguage()]
const { common } = locale.translation
const template: MenuItemConstructorOptions[] = [
{
id: 'inspect',
label: common.inspect,
click: () => {
w.webContents.toggleDevTools()
},
enabled: true
}
]
return template
}
private createEditMenuItems(properties: Electron.ContextMenuParams): MenuItemConstructorOptions[] {
const locale = locales[configManager.getLanguage()]
const { common } = locale.translation

View File

@ -304,6 +304,7 @@
"confirm": "Confirm",
"copied": "Copied",
"copy": "Copy",
"inspect": "Inspect",
"cut": "Cut",
"default": "Default",
"delete": "Delete",

View File

@ -304,6 +304,7 @@
"confirm": "確認",
"copied": "コピーされました",
"copy": "コピー",
"inspect": "検査",
"cut": "切り取り",
"default": "デフォルト",
"delete": "削除",

View File

@ -304,6 +304,7 @@
"confirm": "Подтверждение",
"copied": "Скопировано",
"copy": "Копировать",
"inspect": "Осмотреть",
"cut": "Вырезать",
"default": "По умолчанию",
"delete": "Удалить",

View File

@ -304,6 +304,7 @@
"confirm": "确认",
"copied": "已复制",
"copy": "复制",
"inspect": "检查",
"cut": "剪切",
"default": "默认",
"delete": "删除",

View File

@ -304,6 +304,7 @@
"confirm": "確認",
"copied": "已複製",
"copy": "複製",
"inspect": "檢查",
"cut": "剪下",
"default": "預設",
"delete": "刪除",