From e8495b973088fc95c301433f582104e72b2b2845 Mon Sep 17 00:00:00 2001 From: lony2003 <35906997+lony2003@users.noreply.github.com> Date: Fri, 14 Jun 2024 09:27:52 +0800 Subject: [PATCH] fix copy in macos and disguise this app to be edge, which pretends edge protcol --- README.md | 2 ++ README_zh_CN.md | 2 ++ electron/main.js | 41 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ad40e7..5d44879 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Modified By Team Fangkehou. You can try the new copilot website by microsoft to get the original experence of BingGPT: https://copilot.microsoft.com/ +> __if you like this app, please give me a Star. Thanks!__ + ## Install Please go to [Releases page of this repository](https://github.com/fangkehou-team/BingGPT/releases) to get the latest build. diff --git a/README_zh_CN.md b/README_zh_CN.md index f1f2bab..a576528 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -26,6 +26,8 @@ 微软现已推出网页版Copilot,推荐体验!https://copilot.microsoft.com/ +> __如果你喜欢这个项目,请给这个项目点一个Star,秋梨膏!__ + ## 安装 请前往 [Releases 页面](https://github.com/fangkehou-team/BingGPT/releases) 获取最新版本 diff --git a/electron/main.js b/electron/main.js index 2a4eb7a..28fb5cd 100644 --- a/electron/main.js +++ b/electron/main.js @@ -46,7 +46,7 @@ function getWrapperUrl() { return VITE_DEV_SERVER_URL; } else { return urlUtil.format({ - protocol: 'file', + protocol: 'edge', slashes: true, pathname: path.join(process.env.DIST, 'index.html') }) @@ -97,9 +97,38 @@ function createWindow() { // Get always on top settings const alwaysOnTop = config.get('alwaysOnTop') mainWindow.setAlwaysOnTop(alwaysOnTop) - - // Hide main menu (Windows) + + // darwin表示macOS,针对macOS的设置 process.platform === 'darwin' + if (process.platform === 'darwin') { + const template = [{ + label: '我的应用', + submenu: [ + { label: '关于', accelerator: 'CmdOrCtrl+I', role: 'about' }, + { type: 'separator' }, + { label: '隐藏', role: 'hide' }, + { label: '隐藏其他', role: 'hideOthers' }, + { type: 'separator' }, + { label: '服务', role: 'services' }, + { label: '退出', accelerator: 'Command+Q',role: 'quit' } + ] + }, + { + label: '编辑', + submenu: [ + { label: '复制', accelerator: 'CmdOrCtrl+C', role: 'copy' }, + { label: '粘贴', accelerator: 'CmdOrCtrl+V', role: 'paste' }, + { label: '剪切', accelerator: 'CmdOrCtrl+X', role: 'cut' }, + { label: '撤销', accelerator: 'CmdOrCtrl+Z', role: 'undo' }, + { label: '重做', accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' }, + { label: '全选', accelerator: 'CmdOrCtrl+A', role: 'selectAll' } + ] + }] + const menu = Menu.buildFromTemplate(template) + Menu.setApplicationMenu(menu) + } else { + // windows及linux系统 Hide main menu Menu.setApplicationMenu(Menu.buildFromTemplate([])) + } // Create context menu contextMenu({ window: mainWindow.webContents, @@ -408,6 +437,12 @@ function createWindow() { } app.whenReady().then(() => { + + protocol.handle('edge', (request) => { + const filePath = request.url.slice('edge://'.length) + return net.fetch(url.pathToFileURL(path.join(__dirname, filePath)).toString()) + }) + autoUpdater.autoDownload = false; autoUpdater.autoInstallOnAppQuit = true;