@lobehub/chat 1.82.10 → 1.83.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/.env.desktop +1 -2
  2. package/.github/workflows/{release-desktop.yml → desktop-pr-build.yml} +59 -137
  3. package/.github/workflows/release-desktop-beta.yml +194 -0
  4. package/CHANGELOG.md +42 -0
  5. package/apps/desktop/.i18nrc.js +31 -0
  6. package/apps/desktop/Development.md +47 -0
  7. package/apps/desktop/README.md +6 -0
  8. package/apps/desktop/build/Icon-beta.icns +0 -0
  9. package/apps/desktop/build/Icon-nightly.icns +0 -0
  10. package/apps/desktop/build/Icon.icns +0 -0
  11. package/apps/desktop/build/entitlements.mac.plist +12 -0
  12. package/apps/desktop/build/favicon.ico +0 -0
  13. package/apps/desktop/build/icon-beta.png +0 -0
  14. package/apps/desktop/build/icon-dev.png +0 -0
  15. package/apps/desktop/build/icon-nightly.ico +0 -0
  16. package/apps/desktop/build/icon-nightly.png +0 -0
  17. package/apps/desktop/build/icon.ico +0 -0
  18. package/apps/desktop/build/icon.png +0 -0
  19. package/apps/desktop/dev-app-update.yml +6 -0
  20. package/apps/desktop/electron-builder.js +92 -0
  21. package/apps/desktop/electron.vite.config.ts +40 -0
  22. package/apps/desktop/package.json +72 -0
  23. package/apps/desktop/pnpm-workspace.yaml +5 -0
  24. package/apps/desktop/resources/error.html +136 -0
  25. package/apps/desktop/resources/locales/ar/common.json +32 -0
  26. package/apps/desktop/resources/locales/ar/dialog.json +31 -0
  27. package/apps/desktop/resources/locales/ar/menu.json +70 -0
  28. package/apps/desktop/resources/locales/bg-BG/common.json +32 -0
  29. package/apps/desktop/resources/locales/bg-BG/dialog.json +31 -0
  30. package/apps/desktop/resources/locales/bg-BG/menu.json +70 -0
  31. package/apps/desktop/resources/locales/de-DE/common.json +32 -0
  32. package/apps/desktop/resources/locales/de-DE/dialog.json +31 -0
  33. package/apps/desktop/resources/locales/de-DE/menu.json +70 -0
  34. package/apps/desktop/resources/locales/en-US/common.json +32 -0
  35. package/apps/desktop/resources/locales/en-US/dialog.json +31 -0
  36. package/apps/desktop/resources/locales/en-US/menu.json +70 -0
  37. package/apps/desktop/resources/locales/es-ES/common.json +32 -0
  38. package/apps/desktop/resources/locales/es-ES/dialog.json +31 -0
  39. package/apps/desktop/resources/locales/es-ES/menu.json +70 -0
  40. package/apps/desktop/resources/locales/fa-IR/common.json +32 -0
  41. package/apps/desktop/resources/locales/fa-IR/dialog.json +31 -0
  42. package/apps/desktop/resources/locales/fa-IR/menu.json +70 -0
  43. package/apps/desktop/resources/locales/fr-FR/common.json +32 -0
  44. package/apps/desktop/resources/locales/fr-FR/dialog.json +31 -0
  45. package/apps/desktop/resources/locales/fr-FR/menu.json +70 -0
  46. package/apps/desktop/resources/locales/it-IT/common.json +32 -0
  47. package/apps/desktop/resources/locales/it-IT/dialog.json +31 -0
  48. package/apps/desktop/resources/locales/it-IT/menu.json +70 -0
  49. package/apps/desktop/resources/locales/ja-JP/common.json +32 -0
  50. package/apps/desktop/resources/locales/ja-JP/dialog.json +31 -0
  51. package/apps/desktop/resources/locales/ja-JP/menu.json +70 -0
  52. package/apps/desktop/resources/locales/ko-KR/common.json +32 -0
  53. package/apps/desktop/resources/locales/ko-KR/dialog.json +31 -0
  54. package/apps/desktop/resources/locales/ko-KR/menu.json +70 -0
  55. package/apps/desktop/resources/locales/nl-NL/common.json +32 -0
  56. package/apps/desktop/resources/locales/nl-NL/dialog.json +31 -0
  57. package/apps/desktop/resources/locales/nl-NL/menu.json +70 -0
  58. package/apps/desktop/resources/locales/pl-PL/common.json +32 -0
  59. package/apps/desktop/resources/locales/pl-PL/dialog.json +31 -0
  60. package/apps/desktop/resources/locales/pl-PL/menu.json +70 -0
  61. package/apps/desktop/resources/locales/pt-BR/common.json +32 -0
  62. package/apps/desktop/resources/locales/pt-BR/dialog.json +31 -0
  63. package/apps/desktop/resources/locales/pt-BR/menu.json +70 -0
  64. package/apps/desktop/resources/locales/ru-RU/common.json +32 -0
  65. package/apps/desktop/resources/locales/ru-RU/dialog.json +31 -0
  66. package/apps/desktop/resources/locales/ru-RU/menu.json +70 -0
  67. package/apps/desktop/resources/locales/tr-TR/common.json +32 -0
  68. package/apps/desktop/resources/locales/tr-TR/dialog.json +31 -0
  69. package/apps/desktop/resources/locales/tr-TR/menu.json +70 -0
  70. package/apps/desktop/resources/locales/vi-VN/common.json +32 -0
  71. package/apps/desktop/resources/locales/vi-VN/dialog.json +31 -0
  72. package/apps/desktop/resources/locales/vi-VN/menu.json +70 -0
  73. package/apps/desktop/resources/locales/zh-CN/common.json +32 -0
  74. package/apps/desktop/resources/locales/zh-CN/dialog.json +31 -0
  75. package/apps/desktop/resources/locales/zh-CN/menu.json +70 -0
  76. package/apps/desktop/resources/locales/zh-TW/common.json +32 -0
  77. package/apps/desktop/resources/locales/zh-TW/dialog.json +31 -0
  78. package/apps/desktop/resources/locales/zh-TW/menu.json +70 -0
  79. package/apps/desktop/resources/splash.html +88 -0
  80. package/apps/desktop/scripts/i18nWorkflow/const.ts +18 -0
  81. package/apps/desktop/scripts/i18nWorkflow/genDefaultLocale.ts +35 -0
  82. package/apps/desktop/scripts/i18nWorkflow/genDiff.ts +57 -0
  83. package/apps/desktop/scripts/i18nWorkflow/index.ts +35 -0
  84. package/apps/desktop/scripts/i18nWorkflow/utils.ts +54 -0
  85. package/apps/desktop/scripts/pglite-server.ts +14 -0
  86. package/apps/desktop/src/common/routes.ts +78 -0
  87. package/apps/desktop/src/main/appBrowsers.ts +47 -0
  88. package/apps/desktop/src/main/const/dir.ts +29 -0
  89. package/apps/desktop/src/main/const/env.ts +3 -0
  90. package/apps/desktop/src/main/const/store.ts +22 -0
  91. package/apps/desktop/src/main/controllers/AuthCtr.ts +390 -0
  92. package/apps/desktop/src/main/controllers/BrowserWindowsCtr.ts +95 -0
  93. package/apps/desktop/src/main/controllers/DevtoolsCtr.ts +9 -0
  94. package/apps/desktop/src/main/controllers/LocalFileCtr.ts +380 -0
  95. package/apps/desktop/src/main/controllers/MenuCtr.ts +29 -0
  96. package/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts +335 -0
  97. package/apps/desktop/src/main/controllers/RemoteServerSyncCtr.ts +321 -0
  98. package/apps/desktop/src/main/controllers/ShortcutCtr.ts +19 -0
  99. package/apps/desktop/src/main/controllers/SystemCtr.ts +93 -0
  100. package/apps/desktop/src/main/controllers/UpdaterCtr.ts +43 -0
  101. package/apps/desktop/src/main/controllers/UploadFileCtr.ts +34 -0
  102. package/apps/desktop/src/main/controllers/_template.ts +9 -0
  103. package/apps/desktop/src/main/controllers/index.ts +58 -0
  104. package/apps/desktop/src/main/core/App.ts +370 -0
  105. package/apps/desktop/src/main/core/Browser.ts +345 -0
  106. package/apps/desktop/src/main/core/BrowserManager.ts +154 -0
  107. package/apps/desktop/src/main/core/I18nManager.ts +185 -0
  108. package/apps/desktop/src/main/core/IoCContainer.ts +12 -0
  109. package/apps/desktop/src/main/core/MenuManager.ts +64 -0
  110. package/apps/desktop/src/main/core/ShortcutManager.ts +173 -0
  111. package/apps/desktop/src/main/core/StoreManager.ts +89 -0
  112. package/apps/desktop/src/main/core/UpdaterManager.ts +321 -0
  113. package/apps/desktop/src/main/index.ts +5 -0
  114. package/apps/desktop/src/main/locales/default/common.ts +34 -0
  115. package/apps/desktop/src/main/locales/default/dialog.ts +33 -0
  116. package/apps/desktop/src/main/locales/default/index.ts +11 -0
  117. package/apps/desktop/src/main/locales/default/menu.ts +72 -0
  118. package/apps/desktop/src/main/locales/resources.ts +35 -0
  119. package/apps/desktop/src/main/menus/impls/BaseMenuPlatform.ts +10 -0
  120. package/apps/desktop/src/main/menus/impls/linux.ts +243 -0
  121. package/apps/desktop/src/main/menus/impls/macOS.ts +360 -0
  122. package/apps/desktop/src/main/menus/impls/windows.ts +226 -0
  123. package/apps/desktop/src/main/menus/index.ts +34 -0
  124. package/apps/desktop/src/main/menus/types.ts +28 -0
  125. package/apps/desktop/src/main/modules/fileSearch/impl/macOS.ts +577 -0
  126. package/apps/desktop/src/main/modules/fileSearch/index.ts +23 -0
  127. package/apps/desktop/src/main/modules/fileSearch/type.ts +27 -0
  128. package/apps/desktop/src/main/modules/updater/configs.ts +22 -0
  129. package/apps/desktop/src/main/modules/updater/utils.ts +33 -0
  130. package/apps/desktop/src/main/services/fileSearchSrv.ts +35 -0
  131. package/apps/desktop/src/main/services/fileSrv.ts +255 -0
  132. package/apps/desktop/src/main/services/index.ts +9 -0
  133. package/apps/desktop/src/main/shortcuts/config.ts +18 -0
  134. package/apps/desktop/src/main/shortcuts/index.ts +1 -0
  135. package/apps/desktop/src/main/types/fileSearch.ts +51 -0
  136. package/apps/desktop/src/main/types/store.ts +14 -0
  137. package/apps/desktop/src/main/utils/file-system.ts +15 -0
  138. package/apps/desktop/src/main/utils/logger.ts +44 -0
  139. package/apps/desktop/src/main/utils/next-electron-rsc.ts +383 -0
  140. package/apps/desktop/src/preload/electronApi.ts +18 -0
  141. package/apps/desktop/src/preload/index.ts +14 -0
  142. package/apps/desktop/src/preload/invoke.ts +10 -0
  143. package/apps/desktop/src/preload/routeInterceptor.ts +162 -0
  144. package/apps/desktop/tsconfig.json +21 -0
  145. package/changelog/v1.json +14 -0
  146. package/package.json +1 -1
  147. package/packages/electron-client-ipc/src/events/remoteServer.ts +11 -4
  148. package/packages/electron-client-ipc/src/types/dataSync.ts +15 -0
  149. package/packages/electron-client-ipc/src/types/index.ts +2 -1
  150. package/packages/electron-client-ipc/src/types/proxyTRPCRequest.ts +21 -0
  151. package/packages/electron-server-ipc/src/const.ts +3 -3
  152. package/packages/electron-server-ipc/src/ipcClient.test.ts +7 -6
  153. package/packages/electron-server-ipc/src/ipcClient.ts +17 -8
  154. package/packages/electron-server-ipc/src/ipcServer.ts +7 -3
  155. package/scripts/electronWorkflow/setDesktopVersion.ts +60 -43
  156. package/src/app/[variants]/(main)/_layout/Desktop/index.tsx +1 -1
  157. package/src/components/Analytics/Desktop.tsx +19 -0
  158. package/src/components/Analytics/index.tsx +3 -0
  159. package/src/database/core/db-adaptor.ts +4 -1
  160. package/src/database/core/electron.ts +317 -0
  161. package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Mode.tsx → features/ElectronTitlebar/Connection/ConnectionMode.tsx} +24 -21
  162. package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Option.tsx +3 -5
  163. package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Sync.tsx → features/ElectronTitlebar/Connection/RemoteStatus.tsx} +10 -7
  164. package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/index.tsx +4 -4
  165. package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateModal.tsx +2 -1
  166. package/src/libs/trpc/client/async.ts +6 -0
  167. package/src/libs/trpc/client/edge.ts +6 -0
  168. package/src/libs/trpc/client/helpers/desktopRemoteRPCFetch.ts +72 -0
  169. package/src/libs/trpc/client/index.ts +1 -0
  170. package/src/libs/trpc/client/lambda.ts +10 -1
  171. package/src/libs/trpc/client/tools.ts +6 -0
  172. package/src/server/globalConfig/index.ts +0 -3
  173. package/src/server/modules/ElectronIPCClient/index.ts +3 -1
  174. package/src/server/routers/desktop/index.ts +2 -0
  175. package/src/server/routers/desktop/mcp.ts +47 -0
  176. package/src/server/routers/lambda/user.ts +38 -23
  177. package/src/server/routers/tools/mcp.ts +0 -6
  178. package/src/services/electron/remoteServer.ts +4 -4
  179. package/src/services/mcp.ts +17 -7
  180. package/src/services/upload.ts +9 -0
  181. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +11 -2
  182. package/src/store/chat/slices/builtinTool/actions/localFile.ts +110 -53
  183. package/src/store/electron/actions/sync.ts +20 -19
  184. package/src/store/electron/initialState.ts +3 -3
  185. package/src/store/electron/selectors/sync.ts +6 -3
  186. package/src/store/electron/store.ts +2 -0
  187. package/src/store/file/slices/upload/action.ts +11 -3
  188. package/src/store/tool/selectors/tool.ts +10 -1
  189. package/src/utils/fetch/headers.ts +27 -0
  190. package/src/utils/fetch/index.ts +2 -0
  191. package/src/utils/fetch/request.ts +28 -0
  192. package/packages/electron-client-ipc/src/types/remoteServer.ts +0 -8
  193. /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Waiting.tsx +0 -0
  194. /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateNotification.tsx +0 -0
  195. /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/index.tsx +0 -0
@@ -0,0 +1,33 @@
1
+ const dialog = {
2
+ about: {
3
+ button: '确定',
4
+ detail: '一个基于大语言模型的聊天应用',
5
+ message: '{{appName}} {{appVersion}}',
6
+ title: '关于',
7
+ },
8
+ confirm: {
9
+ cancel: '取消',
10
+ no: '否',
11
+ title: '确认',
12
+ yes: '是',
13
+ },
14
+ error: {
15
+ button: '确定',
16
+ detail: '操作过程中发生错误,请稍后重试',
17
+ message: '发生错误',
18
+ title: '错误',
19
+ },
20
+ update: {
21
+ downloadAndInstall: '下载并安装',
22
+ downloadComplete: '下载完成',
23
+ downloadCompleteMessage: '更新包已下载完成,是否立即安装?',
24
+ installLater: '稍后安装',
25
+ installNow: '立即安装',
26
+ later: '稍后提醒',
27
+ newVersion: '发现新版本',
28
+ newVersionAvailable: '发现新版本: {{version}}',
29
+ skipThisVersion: '跳过此版本',
30
+ },
31
+ };
32
+
33
+ export default dialog;
@@ -0,0 +1,11 @@
1
+ import common from './common';
2
+ import dialog from './dialog';
3
+ import menu from './menu';
4
+
5
+ const resources = {
6
+ common,
7
+ dialog,
8
+ menu,
9
+ } as const;
10
+
11
+ export default resources;
@@ -0,0 +1,72 @@
1
+ const menu = {
2
+ common: {
3
+ checkUpdates: '检查更新...',
4
+ },
5
+ dev: {
6
+ devPanel: '开发者面板',
7
+ devTools: '开发者工具',
8
+ forceReload: '强制重新加载',
9
+ openStore: '打开存储文件',
10
+ refreshMenu: '刷新菜单',
11
+ reload: '重新加载',
12
+ title: '开发',
13
+ },
14
+ edit: {
15
+ copy: '复制',
16
+ cut: '剪切',
17
+ paste: '粘贴',
18
+ redo: '重做',
19
+ selectAll: '全选',
20
+ speech: '语音',
21
+ startSpeaking: '开始朗读',
22
+ stopSpeaking: '停止朗读',
23
+ title: '编辑',
24
+ undo: '撤销',
25
+ },
26
+ file: {
27
+ preferences: '首选项',
28
+ quit: '退出',
29
+ title: '文件',
30
+ },
31
+ help: {
32
+ about: '关于',
33
+ githubRepo: 'GitHub 仓库',
34
+ reportIssue: '报告问题',
35
+ title: '帮助',
36
+ visitWebsite: '访问官网',
37
+ },
38
+ macOS: {
39
+ about: '关于 {{appName}}',
40
+ devTools: 'LobeHub 开发者工具',
41
+ hide: '隐藏 {{appName}}',
42
+ hideOthers: '隐藏其他',
43
+ preferences: '偏好设置...',
44
+ services: '服务',
45
+ unhide: '全部显示',
46
+ },
47
+ tray: {
48
+ open: '打开 {{appName}}',
49
+ quit: '退出',
50
+ show: '显示 {{appName}}',
51
+ },
52
+ view: {
53
+ forceReload: '强制重新加载',
54
+ reload: '重新加载',
55
+ resetZoom: '重置缩放',
56
+ title: '视图',
57
+ toggleFullscreen: '切换全屏',
58
+ zoomIn: '放大',
59
+ zoomOut: '缩小',
60
+ },
61
+ window: {
62
+ bringAllToFront: '前置所有窗口',
63
+ close: '关闭',
64
+ front: '前置所有窗口',
65
+ minimize: '最小化',
66
+ title: '窗口',
67
+ toggleFullscreen: '切换全屏',
68
+ zoom: '缩放',
69
+ },
70
+ };
71
+
72
+ export default menu;
@@ -0,0 +1,35 @@
1
+ import { isDev } from '@/const/env';
2
+
3
+ /**
4
+ * 规范化语言代码
5
+ */
6
+ export const normalizeLocale = (locale: string) => {
7
+ return locale.toLowerCase().replace('_', '-');
8
+ };
9
+
10
+ /**
11
+ * 按需加载翻译资源
12
+ */
13
+ export const loadResources = async (lng: string, ns: string) => {
14
+ // 开发环境下,直接使用中文源文件
15
+ if (isDev && lng === 'zh-CN') {
16
+ try {
17
+ // 使用 require 加载模块,这在 Electron 中更可靠
18
+ const { default: content } = await import(`@/locales/default/${ns}.ts`);
19
+
20
+ return content;
21
+ } catch (error) {
22
+ console.error(`[I18n] 无法加载翻译文件: ${ns}`, error);
23
+ return {};
24
+ }
25
+ }
26
+
27
+ // 生产环境使用编译后的 JSON 文件
28
+
29
+ try {
30
+ return await import(`@/../../resources/locales/${lng}/${ns}.json`);
31
+ } catch (error) {
32
+ console.error(`无法加载翻译文件: ${lng} - ${ns}`, error);
33
+ return {};
34
+ }
35
+ };
@@ -0,0 +1,10 @@
1
+ // apps/desktop/src/main/menus/impl/BaseMenuPlatform.ts
2
+ import type { App } from '@/core/App';
3
+
4
+ export abstract class BaseMenuPlatform {
5
+ protected app: App;
6
+
7
+ constructor(app: App) {
8
+ this.app = app;
9
+ }
10
+ }
@@ -0,0 +1,243 @@
1
+ import { Menu, MenuItemConstructorOptions, app, dialog, shell } from 'electron';
2
+
3
+ import { isDev } from '@/const/env';
4
+
5
+ import type { IMenuPlatform, MenuOptions } from '../types';
6
+ import { BaseMenuPlatform } from './BaseMenuPlatform';
7
+
8
+ export class LinuxMenu extends BaseMenuPlatform implements IMenuPlatform {
9
+ private appMenu: Menu | null = null;
10
+ private trayMenu: Menu | null = null;
11
+
12
+ buildAndSetAppMenu(options?: MenuOptions): Menu {
13
+ const template = this.getAppMenuTemplate(options);
14
+ this.appMenu = Menu.buildFromTemplate(template);
15
+ Menu.setApplicationMenu(this.appMenu);
16
+ return this.appMenu;
17
+ }
18
+
19
+ buildContextMenu(type: string, data?: any): Menu {
20
+ let template: MenuItemConstructorOptions[];
21
+ switch (type) {
22
+ case 'chat': {
23
+ template = this.getChatContextMenuTemplate(data);
24
+ break;
25
+ }
26
+ case 'editor': {
27
+ template = this.getEditorContextMenuTemplate(data);
28
+ break;
29
+ }
30
+ default: {
31
+ template = this.getDefaultContextMenuTemplate();
32
+ }
33
+ }
34
+ return Menu.buildFromTemplate(template);
35
+ }
36
+
37
+ buildTrayMenu(): Menu {
38
+ const template = this.getTrayMenuTemplate();
39
+ this.trayMenu = Menu.buildFromTemplate(template);
40
+ return this.trayMenu;
41
+ }
42
+
43
+ refresh(options?: MenuOptions): void {
44
+ this.buildAndSetAppMenu(options);
45
+ }
46
+
47
+ // --- 私有方法:定义菜单模板和逻辑 ---
48
+
49
+ private getAppMenuTemplate(options?: MenuOptions): MenuItemConstructorOptions[] {
50
+ const showDev = isDev || options?.showDevItems;
51
+ const t = this.app.i18n.ns('menu');
52
+
53
+ const template: MenuItemConstructorOptions[] = [
54
+ {
55
+ label: t('file.title'),
56
+ submenu: [
57
+ {
58
+ click: () => this.app.browserManager.retrieveByIdentifier('settings').show(),
59
+ label: t('file.preferences'),
60
+ },
61
+ {
62
+ click: () => {
63
+ this.app.updaterManager.checkForUpdates({ manual: true });
64
+ },
65
+ label: t('common.checkUpdates') || '检查更新',
66
+ },
67
+ { type: 'separator' },
68
+ {
69
+ accelerator: 'Ctrl+W',
70
+ label: t('window.close'),
71
+ role: 'close',
72
+ },
73
+ {
74
+ accelerator: 'Ctrl+M',
75
+ label: t('window.minimize'),
76
+ role: 'minimize',
77
+ },
78
+ { type: 'separator' },
79
+ { label: t('file.quit'), role: 'quit' },
80
+ ],
81
+ },
82
+ {
83
+ label: t('edit.title'),
84
+ submenu: [
85
+ { accelerator: 'Ctrl+Z', label: t('edit.undo'), role: 'undo' },
86
+ { accelerator: 'Ctrl+Shift+Z', label: t('edit.redo'), role: 'redo' },
87
+ { type: 'separator' },
88
+ { accelerator: 'Ctrl+X', label: t('edit.cut'), role: 'cut' },
89
+ { accelerator: 'Ctrl+C', label: t('edit.copy'), role: 'copy' },
90
+ { accelerator: 'Ctrl+V', label: t('edit.paste'), role: 'paste' },
91
+ { type: 'separator' },
92
+ { accelerator: 'Ctrl+A', label: t('edit.selectAll'), role: 'selectAll' },
93
+ ],
94
+ },
95
+ {
96
+ label: t('view.title'),
97
+ submenu: [
98
+ { accelerator: 'Ctrl+0', label: t('view.resetZoom'), role: 'resetZoom' },
99
+ { accelerator: 'Ctrl+Plus', label: t('view.zoomIn'), role: 'zoomIn' },
100
+ { accelerator: 'Ctrl+-', label: t('view.zoomOut'), role: 'zoomOut' },
101
+ { type: 'separator' },
102
+ { accelerator: 'F11', label: t('view.toggleFullscreen'), role: 'togglefullscreen' },
103
+ ],
104
+ },
105
+ {
106
+ label: t('window.title'),
107
+ submenu: [
108
+ { label: t('window.minimize'), role: 'minimize' },
109
+ { label: t('window.close'), role: 'close' },
110
+ ],
111
+ },
112
+ {
113
+ label: t('help.title'),
114
+ submenu: [
115
+ {
116
+ click: async () => {
117
+ await shell.openExternal('https://lobehub.com');
118
+ },
119
+ label: t('help.visitWebsite'),
120
+ },
121
+ {
122
+ click: async () => {
123
+ await shell.openExternal('https://github.com/lobehub/lobe-chat');
124
+ },
125
+ label: t('help.githubRepo'),
126
+ },
127
+ { type: 'separator' },
128
+ {
129
+ click: () => {
130
+ const commonT = this.app.i18n.ns('common');
131
+ const dialogT = this.app.i18n.ns('dialog');
132
+
133
+ dialog.showMessageBox({
134
+ buttons: [commonT('actions.ok')],
135
+ detail: dialogT('about.detail'),
136
+ message: dialogT('about.message', {
137
+ appName: app.getName(),
138
+ appVersion: app.getVersion(),
139
+ }),
140
+ title: dialogT('about.title'),
141
+ type: 'info',
142
+ });
143
+ },
144
+ label: t('help.about'),
145
+ },
146
+ ],
147
+ },
148
+ ];
149
+
150
+ if (showDev) {
151
+ template.push({
152
+ label: t('dev.title'),
153
+ submenu: [
154
+ { accelerator: 'Ctrl+R', label: t('dev.reload'), role: 'reload' },
155
+ { accelerator: 'Ctrl+Shift+R', label: t('dev.forceReload'), role: 'forceReload' },
156
+ { accelerator: 'Ctrl+Shift+I', label: t('dev.devTools'), role: 'toggleDevTools' },
157
+ { type: 'separator' },
158
+ {
159
+ click: () => {
160
+ this.app.browserManager.retrieveByIdentifier('devtools').show();
161
+ },
162
+ label: t('dev.devPanel'),
163
+ },
164
+ ],
165
+ });
166
+ }
167
+
168
+ return template;
169
+ }
170
+
171
+ private getDefaultContextMenuTemplate(): MenuItemConstructorOptions[] {
172
+ const t = this.app.i18n.ns('menu');
173
+
174
+ return [
175
+ { label: t('edit.cut'), role: 'cut' },
176
+ { label: t('edit.copy'), role: 'copy' },
177
+ { label: t('edit.paste'), role: 'paste' },
178
+ { type: 'separator' },
179
+ { label: t('edit.selectAll'), role: 'selectAll' },
180
+ ];
181
+ }
182
+
183
+ private getChatContextMenuTemplate(data?: any): MenuItemConstructorOptions[] {
184
+ const t = this.app.i18n.ns('menu');
185
+ const commonT = this.app.i18n.ns('common');
186
+
187
+ const items: MenuItemConstructorOptions[] = [
188
+ { label: t('edit.copy'), role: 'copy' },
189
+ { label: t('edit.paste'), role: 'paste' },
190
+ { type: 'separator' },
191
+ { label: t('edit.selectAll'), role: 'selectAll' },
192
+ ];
193
+
194
+ if (data?.messageId) {
195
+ items.push(
196
+ { type: 'separator' },
197
+ {
198
+ click: () => {
199
+ console.log('尝试删除消息:', data.messageId);
200
+ },
201
+ label: commonT('actions.delete'),
202
+ },
203
+ );
204
+ }
205
+
206
+ return items;
207
+ }
208
+
209
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
210
+ private getEditorContextMenuTemplate(_data?: any): MenuItemConstructorOptions[] {
211
+ const t = this.app.i18n.ns('menu');
212
+
213
+ return [
214
+ { label: t('edit.cut'), role: 'cut' },
215
+ { label: t('edit.copy'), role: 'copy' },
216
+ { label: t('edit.paste'), role: 'paste' },
217
+ { type: 'separator' },
218
+ { label: t('edit.undo'), role: 'undo' },
219
+ { label: t('edit.redo'), role: 'redo' },
220
+ { type: 'separator' },
221
+ { label: t('edit.selectAll'), role: 'selectAll' },
222
+ ];
223
+ }
224
+
225
+ private getTrayMenuTemplate(): MenuItemConstructorOptions[] {
226
+ const t = this.app.i18n.ns('menu');
227
+ const appName = app.getName();
228
+
229
+ return [
230
+ {
231
+ click: () => this.app.browserManager.showMainWindow(),
232
+ label: t('tray.open', { appName }),
233
+ },
234
+ { type: 'separator' },
235
+ {
236
+ click: () => this.app.browserManager.retrieveByIdentifier('settings').show(),
237
+ label: t('file.preferences'),
238
+ },
239
+ { type: 'separator' },
240
+ { label: t('tray.quit'), role: 'quit' },
241
+ ];
242
+ }
243
+ }