diff --git a/packages/shared/IpcChannel.ts b/packages/shared/IpcChannel.ts index dcb4f18656..b4c4c571d6 100644 --- a/packages/shared/IpcChannel.ts +++ b/packages/shared/IpcChannel.ts @@ -135,6 +135,9 @@ export enum IpcChannel { System_GetDeviceType = 'system:getDeviceType', System_GetHostname = 'system:getHostname', + // DevTools + System_ToggleDevTools = 'system:toggleDevTools', + // events BackupProgress = 'backup-progress', ThemeChange = 'theme:change', diff --git a/src/main/index.ts b/src/main/index.ts index 132dff40fc..41c48cd977 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,7 +1,7 @@ import { electronApp, optimizer } from '@electron-toolkit/utils' import { replaceDevtoolsFont } from '@main/utils/windowUtil' import { IpcChannel } from '@shared/IpcChannel' -import { app, ipcMain } from 'electron' +import { app, BrowserWindow, ipcMain } from 'electron' import installExtension, { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } from 'electron-devtools-installer' import Logger from 'electron-log' @@ -75,6 +75,11 @@ if (!app.requestSingleInstanceLock()) { ipcMain.handle(IpcChannel.System_GetHostname, () => { return require('os').hostname() }) + + ipcMain.handle(IpcChannel.System_ToggleDevTools, (e) => { + const win = BrowserWindow.fromWebContents(e.sender) + win && win.webContents.toggleDevTools() + }) }) registerProtocolClient(app) diff --git a/src/preload/index.ts b/src/preload/index.ts index 373cad4a24..2a2f378fa2 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -29,6 +29,9 @@ const api = { getDeviceType: () => ipcRenderer.invoke(IpcChannel.System_GetDeviceType), getHostname: () => ipcRenderer.invoke(IpcChannel.System_GetHostname) }, + devTools: { + toggle: () => ipcRenderer.invoke(IpcChannel.System_ToggleDevTools) + }, zip: { compress: (text: string) => ipcRenderer.invoke(IpcChannel.Zip_Compress, text), decompress: (text: Buffer) => ipcRenderer.invoke(IpcChannel.Zip_Decompress, text) diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 631f92bc11..171d5a9786 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -905,6 +905,8 @@ "about.checkUpdate.available": "Update", "about.contact.button": "Email", "about.contact.title": "Contact", + "about.debug.title": "Debug", + "about.debug.open": "Open", "about.description": "A powerful AI assistant for producer", "about.downloading": "Downloading...", "about.feedback.button": "Feedback", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 6ffb9620c1..b194461eba 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -905,6 +905,8 @@ "about.checkUpdate.available": "立即更新", "about.contact.button": "邮件", "about.contact.title": "邮件联系", + "about.debug.title": "调试面板", + "about.debug.open": "打开", "about.description": "一款为创造者而生的 AI 助手", "about.downloading": "正在下载更新...", "about.feedback.button": "反馈", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 17667120e0..0279639c8c 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -905,6 +905,8 @@ "about.checkUpdate.available": "立即更新", "about.contact.button": "電子郵件", "about.contact.title": "聯絡方式", + "about.debug.title": "調試面板", + "about.debug.open": "開啟", "about.description": "一款為創作者而生的強大 AI 助手", "about.downloading": "正在下載...", "about.feedback.button": "回饋", diff --git a/src/renderer/src/pages/settings/AboutSettings.tsx b/src/renderer/src/pages/settings/AboutSettings.tsx index 62a4971caa..bd7e174f6f 100644 --- a/src/renderer/src/pages/settings/AboutSettings.tsx +++ b/src/renderer/src/pages/settings/AboutSettings.tsx @@ -12,7 +12,7 @@ import { ThemeMode } from '@renderer/types' import { compareVersions, runAsyncFunction } from '@renderer/utils' import { Avatar, Button, Progress, Row, Switch, Tag } from 'antd' import { debounce } from 'lodash' -import { FileCheck, Github, Globe, Mail, Rss } from 'lucide-react' +import { Bug, FileCheck, Github, Globe, Mail, Rss } from 'lucide-react' import { FC, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import Markdown from 'react-markdown' @@ -69,6 +69,10 @@ const AboutSettings: FC = () => { onOpenWebsite(url) } + const debug = async () => { + await window.api.devTools.toggle() + } + const showLicense = async () => { const { appPath } = await window.api.getAppInfo() openMinapp({ @@ -219,6 +223,14 @@ const AboutSettings: FC = () => { + + + + + {t('settings.about.debug.title')} + + + )