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 template: MenuItemConstructorOptions[] = this.createEditMenuItems(properties)
const filtered = template.filter((item) => item.visible !== false) const filtered = template.filter((item) => item.visible !== false)
if (filtered.length > 0) { if (filtered.length > 0) {
const menu = Menu.buildFromTemplate(filtered) const menu = Menu.buildFromTemplate([...filtered, ...this.createInspectMenuItems(w)])
menu.popup() 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[] { private createEditMenuItems(properties: Electron.ContextMenuParams): MenuItemConstructorOptions[] {
const locale = locales[configManager.getLanguage()] const locale = locales[configManager.getLanguage()]
const { common } = locale.translation const { common } = locale.translation

View File

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

View File

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

View File

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

View File

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

View File

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