mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 10:00:08 +08:00
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:
parent
3697b31c7b
commit
3a36da1bf9
@ -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
|
||||||
|
|||||||
@ -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",
|
||||||
|
|||||||
@ -304,6 +304,7 @@
|
|||||||
"confirm": "確認",
|
"confirm": "確認",
|
||||||
"copied": "コピーされました",
|
"copied": "コピーされました",
|
||||||
"copy": "コピー",
|
"copy": "コピー",
|
||||||
|
"inspect": "検査",
|
||||||
"cut": "切り取り",
|
"cut": "切り取り",
|
||||||
"default": "デフォルト",
|
"default": "デフォルト",
|
||||||
"delete": "削除",
|
"delete": "削除",
|
||||||
|
|||||||
@ -304,6 +304,7 @@
|
|||||||
"confirm": "Подтверждение",
|
"confirm": "Подтверждение",
|
||||||
"copied": "Скопировано",
|
"copied": "Скопировано",
|
||||||
"copy": "Копировать",
|
"copy": "Копировать",
|
||||||
|
"inspect": "Осмотреть",
|
||||||
"cut": "Вырезать",
|
"cut": "Вырезать",
|
||||||
"default": "По умолчанию",
|
"default": "По умолчанию",
|
||||||
"delete": "Удалить",
|
"delete": "Удалить",
|
||||||
|
|||||||
@ -304,6 +304,7 @@
|
|||||||
"confirm": "确认",
|
"confirm": "确认",
|
||||||
"copied": "已复制",
|
"copied": "已复制",
|
||||||
"copy": "复制",
|
"copy": "复制",
|
||||||
|
"inspect": "检查",
|
||||||
"cut": "剪切",
|
"cut": "剪切",
|
||||||
"default": "默认",
|
"default": "默认",
|
||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
|
|||||||
@ -304,6 +304,7 @@
|
|||||||
"confirm": "確認",
|
"confirm": "確認",
|
||||||
"copied": "已複製",
|
"copied": "已複製",
|
||||||
"copy": "複製",
|
"copy": "複製",
|
||||||
|
"inspect": "檢查",
|
||||||
"cut": "剪下",
|
"cut": "剪下",
|
||||||
"default": "預設",
|
"default": "預設",
|
||||||
"delete": "刪除",
|
"delete": "刪除",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user