@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.
- package/.env.desktop +1 -2
- package/.github/workflows/{release-desktop.yml → desktop-pr-build.yml} +59 -137
- package/.github/workflows/release-desktop-beta.yml +194 -0
- package/CHANGELOG.md +42 -0
- package/apps/desktop/.i18nrc.js +31 -0
- package/apps/desktop/Development.md +47 -0
- package/apps/desktop/README.md +6 -0
- package/apps/desktop/build/Icon-beta.icns +0 -0
- package/apps/desktop/build/Icon-nightly.icns +0 -0
- package/apps/desktop/build/Icon.icns +0 -0
- package/apps/desktop/build/entitlements.mac.plist +12 -0
- package/apps/desktop/build/favicon.ico +0 -0
- package/apps/desktop/build/icon-beta.png +0 -0
- package/apps/desktop/build/icon-dev.png +0 -0
- package/apps/desktop/build/icon-nightly.ico +0 -0
- package/apps/desktop/build/icon-nightly.png +0 -0
- package/apps/desktop/build/icon.ico +0 -0
- package/apps/desktop/build/icon.png +0 -0
- package/apps/desktop/dev-app-update.yml +6 -0
- package/apps/desktop/electron-builder.js +92 -0
- package/apps/desktop/electron.vite.config.ts +40 -0
- package/apps/desktop/package.json +72 -0
- package/apps/desktop/pnpm-workspace.yaml +5 -0
- package/apps/desktop/resources/error.html +136 -0
- package/apps/desktop/resources/locales/ar/common.json +32 -0
- package/apps/desktop/resources/locales/ar/dialog.json +31 -0
- package/apps/desktop/resources/locales/ar/menu.json +70 -0
- package/apps/desktop/resources/locales/bg-BG/common.json +32 -0
- package/apps/desktop/resources/locales/bg-BG/dialog.json +31 -0
- package/apps/desktop/resources/locales/bg-BG/menu.json +70 -0
- package/apps/desktop/resources/locales/de-DE/common.json +32 -0
- package/apps/desktop/resources/locales/de-DE/dialog.json +31 -0
- package/apps/desktop/resources/locales/de-DE/menu.json +70 -0
- package/apps/desktop/resources/locales/en-US/common.json +32 -0
- package/apps/desktop/resources/locales/en-US/dialog.json +31 -0
- package/apps/desktop/resources/locales/en-US/menu.json +70 -0
- package/apps/desktop/resources/locales/es-ES/common.json +32 -0
- package/apps/desktop/resources/locales/es-ES/dialog.json +31 -0
- package/apps/desktop/resources/locales/es-ES/menu.json +70 -0
- package/apps/desktop/resources/locales/fa-IR/common.json +32 -0
- package/apps/desktop/resources/locales/fa-IR/dialog.json +31 -0
- package/apps/desktop/resources/locales/fa-IR/menu.json +70 -0
- package/apps/desktop/resources/locales/fr-FR/common.json +32 -0
- package/apps/desktop/resources/locales/fr-FR/dialog.json +31 -0
- package/apps/desktop/resources/locales/fr-FR/menu.json +70 -0
- package/apps/desktop/resources/locales/it-IT/common.json +32 -0
- package/apps/desktop/resources/locales/it-IT/dialog.json +31 -0
- package/apps/desktop/resources/locales/it-IT/menu.json +70 -0
- package/apps/desktop/resources/locales/ja-JP/common.json +32 -0
- package/apps/desktop/resources/locales/ja-JP/dialog.json +31 -0
- package/apps/desktop/resources/locales/ja-JP/menu.json +70 -0
- package/apps/desktop/resources/locales/ko-KR/common.json +32 -0
- package/apps/desktop/resources/locales/ko-KR/dialog.json +31 -0
- package/apps/desktop/resources/locales/ko-KR/menu.json +70 -0
- package/apps/desktop/resources/locales/nl-NL/common.json +32 -0
- package/apps/desktop/resources/locales/nl-NL/dialog.json +31 -0
- package/apps/desktop/resources/locales/nl-NL/menu.json +70 -0
- package/apps/desktop/resources/locales/pl-PL/common.json +32 -0
- package/apps/desktop/resources/locales/pl-PL/dialog.json +31 -0
- package/apps/desktop/resources/locales/pl-PL/menu.json +70 -0
- package/apps/desktop/resources/locales/pt-BR/common.json +32 -0
- package/apps/desktop/resources/locales/pt-BR/dialog.json +31 -0
- package/apps/desktop/resources/locales/pt-BR/menu.json +70 -0
- package/apps/desktop/resources/locales/ru-RU/common.json +32 -0
- package/apps/desktop/resources/locales/ru-RU/dialog.json +31 -0
- package/apps/desktop/resources/locales/ru-RU/menu.json +70 -0
- package/apps/desktop/resources/locales/tr-TR/common.json +32 -0
- package/apps/desktop/resources/locales/tr-TR/dialog.json +31 -0
- package/apps/desktop/resources/locales/tr-TR/menu.json +70 -0
- package/apps/desktop/resources/locales/vi-VN/common.json +32 -0
- package/apps/desktop/resources/locales/vi-VN/dialog.json +31 -0
- package/apps/desktop/resources/locales/vi-VN/menu.json +70 -0
- package/apps/desktop/resources/locales/zh-CN/common.json +32 -0
- package/apps/desktop/resources/locales/zh-CN/dialog.json +31 -0
- package/apps/desktop/resources/locales/zh-CN/menu.json +70 -0
- package/apps/desktop/resources/locales/zh-TW/common.json +32 -0
- package/apps/desktop/resources/locales/zh-TW/dialog.json +31 -0
- package/apps/desktop/resources/locales/zh-TW/menu.json +70 -0
- package/apps/desktop/resources/splash.html +88 -0
- package/apps/desktop/scripts/i18nWorkflow/const.ts +18 -0
- package/apps/desktop/scripts/i18nWorkflow/genDefaultLocale.ts +35 -0
- package/apps/desktop/scripts/i18nWorkflow/genDiff.ts +57 -0
- package/apps/desktop/scripts/i18nWorkflow/index.ts +35 -0
- package/apps/desktop/scripts/i18nWorkflow/utils.ts +54 -0
- package/apps/desktop/scripts/pglite-server.ts +14 -0
- package/apps/desktop/src/common/routes.ts +78 -0
- package/apps/desktop/src/main/appBrowsers.ts +47 -0
- package/apps/desktop/src/main/const/dir.ts +29 -0
- package/apps/desktop/src/main/const/env.ts +3 -0
- package/apps/desktop/src/main/const/store.ts +22 -0
- package/apps/desktop/src/main/controllers/AuthCtr.ts +390 -0
- package/apps/desktop/src/main/controllers/BrowserWindowsCtr.ts +95 -0
- package/apps/desktop/src/main/controllers/DevtoolsCtr.ts +9 -0
- package/apps/desktop/src/main/controllers/LocalFileCtr.ts +380 -0
- package/apps/desktop/src/main/controllers/MenuCtr.ts +29 -0
- package/apps/desktop/src/main/controllers/RemoteServerConfigCtr.ts +335 -0
- package/apps/desktop/src/main/controllers/RemoteServerSyncCtr.ts +321 -0
- package/apps/desktop/src/main/controllers/ShortcutCtr.ts +19 -0
- package/apps/desktop/src/main/controllers/SystemCtr.ts +93 -0
- package/apps/desktop/src/main/controllers/UpdaterCtr.ts +43 -0
- package/apps/desktop/src/main/controllers/UploadFileCtr.ts +34 -0
- package/apps/desktop/src/main/controllers/_template.ts +9 -0
- package/apps/desktop/src/main/controllers/index.ts +58 -0
- package/apps/desktop/src/main/core/App.ts +370 -0
- package/apps/desktop/src/main/core/Browser.ts +345 -0
- package/apps/desktop/src/main/core/BrowserManager.ts +154 -0
- package/apps/desktop/src/main/core/I18nManager.ts +185 -0
- package/apps/desktop/src/main/core/IoCContainer.ts +12 -0
- package/apps/desktop/src/main/core/MenuManager.ts +64 -0
- package/apps/desktop/src/main/core/ShortcutManager.ts +173 -0
- package/apps/desktop/src/main/core/StoreManager.ts +89 -0
- package/apps/desktop/src/main/core/UpdaterManager.ts +321 -0
- package/apps/desktop/src/main/index.ts +5 -0
- package/apps/desktop/src/main/locales/default/common.ts +34 -0
- package/apps/desktop/src/main/locales/default/dialog.ts +33 -0
- package/apps/desktop/src/main/locales/default/index.ts +11 -0
- package/apps/desktop/src/main/locales/default/menu.ts +72 -0
- package/apps/desktop/src/main/locales/resources.ts +35 -0
- package/apps/desktop/src/main/menus/impls/BaseMenuPlatform.ts +10 -0
- package/apps/desktop/src/main/menus/impls/linux.ts +243 -0
- package/apps/desktop/src/main/menus/impls/macOS.ts +360 -0
- package/apps/desktop/src/main/menus/impls/windows.ts +226 -0
- package/apps/desktop/src/main/menus/index.ts +34 -0
- package/apps/desktop/src/main/menus/types.ts +28 -0
- package/apps/desktop/src/main/modules/fileSearch/impl/macOS.ts +577 -0
- package/apps/desktop/src/main/modules/fileSearch/index.ts +23 -0
- package/apps/desktop/src/main/modules/fileSearch/type.ts +27 -0
- package/apps/desktop/src/main/modules/updater/configs.ts +22 -0
- package/apps/desktop/src/main/modules/updater/utils.ts +33 -0
- package/apps/desktop/src/main/services/fileSearchSrv.ts +35 -0
- package/apps/desktop/src/main/services/fileSrv.ts +255 -0
- package/apps/desktop/src/main/services/index.ts +9 -0
- package/apps/desktop/src/main/shortcuts/config.ts +18 -0
- package/apps/desktop/src/main/shortcuts/index.ts +1 -0
- package/apps/desktop/src/main/types/fileSearch.ts +51 -0
- package/apps/desktop/src/main/types/store.ts +14 -0
- package/apps/desktop/src/main/utils/file-system.ts +15 -0
- package/apps/desktop/src/main/utils/logger.ts +44 -0
- package/apps/desktop/src/main/utils/next-electron-rsc.ts +383 -0
- package/apps/desktop/src/preload/electronApi.ts +18 -0
- package/apps/desktop/src/preload/index.ts +14 -0
- package/apps/desktop/src/preload/invoke.ts +10 -0
- package/apps/desktop/src/preload/routeInterceptor.ts +162 -0
- package/apps/desktop/tsconfig.json +21 -0
- package/changelog/v1.json +14 -0
- package/package.json +1 -1
- package/packages/electron-client-ipc/src/events/remoteServer.ts +11 -4
- package/packages/electron-client-ipc/src/types/dataSync.ts +15 -0
- package/packages/electron-client-ipc/src/types/index.ts +2 -1
- package/packages/electron-client-ipc/src/types/proxyTRPCRequest.ts +21 -0
- package/packages/electron-server-ipc/src/const.ts +3 -3
- package/packages/electron-server-ipc/src/ipcClient.test.ts +7 -6
- package/packages/electron-server-ipc/src/ipcClient.ts +17 -8
- package/packages/electron-server-ipc/src/ipcServer.ts +7 -3
- package/scripts/electronWorkflow/setDesktopVersion.ts +60 -43
- package/src/app/[variants]/(main)/_layout/Desktop/index.tsx +1 -1
- package/src/components/Analytics/Desktop.tsx +19 -0
- package/src/components/Analytics/index.tsx +3 -0
- package/src/database/core/db-adaptor.ts +4 -1
- package/src/database/core/electron.ts +317 -0
- package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Mode.tsx → features/ElectronTitlebar/Connection/ConnectionMode.tsx} +24 -21
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Option.tsx +3 -5
- package/src/{app/[variants]/(main)/_layout/Desktop/ElectronTitlebar/Connection/Sync.tsx → features/ElectronTitlebar/Connection/RemoteStatus.tsx} +10 -7
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/index.tsx +4 -4
- package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateModal.tsx +2 -1
- package/src/libs/trpc/client/async.ts +6 -0
- package/src/libs/trpc/client/edge.ts +6 -0
- package/src/libs/trpc/client/helpers/desktopRemoteRPCFetch.ts +72 -0
- package/src/libs/trpc/client/index.ts +1 -0
- package/src/libs/trpc/client/lambda.ts +10 -1
- package/src/libs/trpc/client/tools.ts +6 -0
- package/src/server/globalConfig/index.ts +0 -3
- package/src/server/modules/ElectronIPCClient/index.ts +3 -1
- package/src/server/routers/desktop/index.ts +2 -0
- package/src/server/routers/desktop/mcp.ts +47 -0
- package/src/server/routers/lambda/user.ts +38 -23
- package/src/server/routers/tools/mcp.ts +0 -6
- package/src/services/electron/remoteServer.ts +4 -4
- package/src/services/mcp.ts +17 -7
- package/src/services/upload.ts +9 -0
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +11 -2
- package/src/store/chat/slices/builtinTool/actions/localFile.ts +110 -53
- package/src/store/electron/actions/sync.ts +20 -19
- package/src/store/electron/initialState.ts +3 -3
- package/src/store/electron/selectors/sync.ts +6 -3
- package/src/store/electron/store.ts +2 -0
- package/src/store/file/slices/upload/action.ts +11 -3
- package/src/store/tool/selectors/tool.ts +10 -1
- package/src/utils/fetch/headers.ts +27 -0
- package/src/utils/fetch/index.ts +2 -0
- package/src/utils/fetch/request.ts +28 -0
- package/packages/electron-client-ipc/src/types/remoteServer.ts +0 -8
- /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/Connection/Waiting.tsx +0 -0
- /package/src/{app/[variants]/(main)/_layout/Desktop → features}/ElectronTitlebar/UpdateNotification.tsx +0 -0
- /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,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,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
|
+
}
|