From 3b1dce6d67b03d3e5bf28c9081d99de4769d0287 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 10 Jan 2026 15:47:43 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=87=E7=AD=BE=E9=A1=B5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=9B=B4=E5=A4=9A=E8=8F=9C=E5=8D=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将原浏览器打开按钮替换为更多菜单按钮 - 添加 more.svg 图标并调整样式 - 实现 webTabShowMenu 通信接口及菜单框架 --- electron/electron.js | 56 +++++++++++++++++++++++ electron/render/tabs/assets/css/style.css | 22 +++++---- electron/render/tabs/index.html | 10 ++-- 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/electron/electron.js b/electron/electron.js index 7b837590b..50c8086eb 100644 --- a/electron/electron.js +++ b/electron/electron.js @@ -1958,6 +1958,62 @@ ipcMain.on('webTabExternal', (event) => { event.returnValue = "ok" }) +/** + * 内置浏览器 - 显示更多菜单 + */ +ipcMain.on('webTabShowMenu', (event, args) => { + const windowId = args?.windowId + const windowData = windowId ? webTabWindows.get(windowId) : null + const webTabWindow = windowData?.window + + if (!webTabWindow || webTabWindow.isDestroyed()) { + event.returnValue = "ok" + return + } + + const item = currentWebTabInWindow(windowId) + const currentUrl = item?.view?.webContents?.getURL() || '' + + const menuTemplate = [ + { + label: '重新加载', + click: () => { + // TODO: 实现重新加载 + } + }, + { + label: '复制链接地址', + click: () => { + // TODO: 实现复制链接 + } + }, + { + label: '默认浏览器打开', + click: () => { + // TODO: 实现默认浏览器打开 + } + }, + { type: 'separator' }, + { + label: '将标签页移至新窗口', + click: () => { + // TODO: 实现移至新窗口 + } + }, + { type: 'separator' }, + { + label: '打印', + click: () => { + // TODO: 实现打印 + } + } + ] + + const menu = Menu.buildFromTemplate(menuTemplate) + menu.popup({ window: webTabWindow }) + event.returnValue = "ok" +}) + /** * 内置浏览器 - 打开开发者工具 */ diff --git a/electron/render/tabs/assets/css/style.css b/electron/render/tabs/assets/css/style.css index 487ebbeab..7a3d08e0c 100644 --- a/electron/render/tabs/assets/css/style.css +++ b/electron/render/tabs/assets/css/style.css @@ -135,11 +135,12 @@ body { content: none; } -/* 浏览器打开 */ -.nav-browser { +/* 更多菜单 */ +.nav-more { flex-shrink: 0; display: flex; align-items: center; + justify-content: center; height: 40px; padding: 0 14px; margin: 0 2px; @@ -148,14 +149,15 @@ body { -webkit-app-region: none; } -.nav-browser span { - display: inline-block; +.nav-more svg { width: 18px; height: 18px; - background-size: 94%; - background-position: center; - background-repeat: no-repeat; - background-image: url(../image/link/light_selected.svg); + color: #000000; + opacity: 0.7; +} + +.nav-more:hover svg { + opacity: 1; } /* 图标 */ @@ -390,8 +392,8 @@ body.darwin.full-screen .nav { background-image: var(--tab-icon-image, url(../image/earth/dark_selected.svg)); } - .nav-browser span { - background-image: url(../image/link/dark_selected.svg); + .nav-more svg { + color: #C7C7C7; } .tab-icon::before { diff --git a/electron/render/tabs/index.html b/electron/render/tabs/index.html index 1dfcb6e56..b11ce276e 100644 --- a/electron/render/tabs/index.html +++ b/electron/render/tabs/index.html @@ -29,8 +29,8 @@
- @@ -513,10 +513,10 @@ }, /** - * 打开浏览器 + * 显示更多菜单 */ - onBrowser() { - this.sendMessage('webTabExternal') + onShowMenu() { + this.sendMessage('webTabShowMenu', {windowId: this.windowId, tabId: this.activeId}) }, /**