From d25714a43f0676ab35204d6b4bc7564464eeb3c2 Mon Sep 17 00:00:00 2001 From: viarotel Date: Mon, 13 Jan 2025 17:27:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=F0=9F=91=B7=20Added=20edge=20hiding=20?= =?UTF-8?q?function=20switch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/helpers/store.js | 2 +- electron/main.js | 17 ++++++++++------- src/components/PreferenceForm/index.vue | 2 +- src/locales/languages/en-US.json | 3 +++ src/locales/languages/ru-RU.json | 3 +++ src/locales/languages/zh-CN.json | 3 +++ src/locales/languages/zh-TW.json | 3 +++ src/store/preference/model/common/index.js | 8 ++++++++ 8 files changed, 32 insertions(+), 9 deletions(-) diff --git a/electron/helpers/store.js b/electron/helpers/store.js index 7ef5ed8..45767fd 100644 --- a/electron/helpers/store.js +++ b/electron/helpers/store.js @@ -2,7 +2,7 @@ import Store from 'electron-store' import { isEqual, set } from 'lodash-es' import { createProxy } from './index.js' -const appStore = new Store() +const appStore = new Store({ watch: true }) // 如果没有数据则手动设置值,以保证配置文件生成成功 if (isEqual(appStore.store, {})) { diff --git a/electron/main.js b/electron/main.js index bbffed2..835dc3b 100644 --- a/electron/main.js +++ b/electron/main.js @@ -84,12 +84,20 @@ function createWindow() { remote.enable(mainWindow.webContents) remote.initialize() - new Edger(mainWindow) - mainWindow.on('ready-to-show', () => { mainWindow.show() }) + mainWindow.webContents.setWindowOpenHandler((details) => { + shell.openExternal(details.url) + return { action: 'deny' } + }) + + const edgeHidden = appStore.get('common.edgeHidden') + if(edgeHidden) { + new Edger(mainWindow) + } + ;['resize', 'move'].forEach((eventName) => { mainWindow.on(eventName, () => { if(mainWindow.isMaximized()) { @@ -103,11 +111,6 @@ function createWindow() { }) }) - mainWindow.webContents.setWindowOpenHandler((details) => { - shell.openExternal(details.url) - return { action: 'deny' } - }) - loadPage(mainWindow) ipc(mainWindow) diff --git a/src/components/PreferenceForm/index.vue b/src/components/PreferenceForm/index.vue index ac0c88b..14715ca 100644 --- a/src/components/PreferenceForm/index.vue +++ b/src/components/PreferenceForm/index.vue @@ -46,7 +46,7 @@ diff --git a/src/locales/languages/en-US.json b/src/locales/languages/en-US.json index 1cf1bb2..8deb534 100644 --- a/src/locales/languages/en-US.json +++ b/src/locales/languages/en-US.json @@ -269,6 +269,9 @@ "preferences.common.auto-connect.placeholder": "When enabled, the software will attempt to automatically connect to historical devices upon startup.", "preferences.common.auto-mirror.name": "Auto Mirror", "preferences.common.auto-mirror.placeholder": "When enabled, devices in the device list will automatically execution the mirror.", + "preferences.common.edgeHidden.name": "Auto-hide Main Panel", + "preferences.common.edgeHidden.placeholder": "When enabled, the main panel will automatically hide when mouse moves near screen edge", + "preferences.common.edgeHidden.tips": "Note: Changes require application restart to take effect", "preferences.video.name": "Video", "preferences.video.disable-video.name": "Disable Video Forwarding", diff --git a/src/locales/languages/ru-RU.json b/src/locales/languages/ru-RU.json index fe10b0a..849aba2 100644 --- a/src/locales/languages/ru-RU.json +++ b/src/locales/languages/ru-RU.json @@ -269,6 +269,9 @@ "preferences.common.auto-connect.placeholder": "При включении программа попытается автоматически подключиться к историческим устройствам при запуске.", "preferences.common.auto-mirror.name": "Автозеркалирование", "preferences.common.auto-mirror.placeholder": "При включении устройства в списке устройств будут автоматически зеркалироваться.", + "preferences.common.edgeHidden.name": "Автоскрытие главной панели", + "preferences.common.edgeHidden.placeholder": "При включении главная панель будет автоматически скрываться, когда курсор приближается к краю экрана", + "preferences.common.edgeHidden.tips": "Примечание: Изменения вступят в силу после перезапуска приложения", "preferences.video.name": "Видео", "preferences.video.disable-video.name": "Отключить передачу видео", diff --git a/src/locales/languages/zh-CN.json b/src/locales/languages/zh-CN.json index cd2a9de..f042e26 100644 --- a/src/locales/languages/zh-CN.json +++ b/src/locales/languages/zh-CN.json @@ -269,6 +269,9 @@ "preferences.common.auto-connect.placeholder": "启用后,该软件将在启动时尝试自动连接到历史无线设备", "preferences.common.auto-mirror.name": "自动执行镜像", "preferences.common.auto-mirror.placeholder": "启用后,设备列表中的设备将自动运行镜像", + "preferences.common.edgeHidden.name": "主面板贴边隐藏", + "preferences.common.edgeHidden.placeholder": "启用后,当鼠标靠近屏幕边缘离开面板时,主面板将自动隐藏。", + "preferences.common.edgeHidden.tips": "注意:更改此选项后,需要重启应用才能生效", "preferences.video.name": "视频控制", "preferences.video.disable-video.name": "禁用视频转发", diff --git a/src/locales/languages/zh-TW.json b/src/locales/languages/zh-TW.json index dac576e..1898071 100644 --- a/src/locales/languages/zh-TW.json +++ b/src/locales/languages/zh-TW.json @@ -269,6 +269,9 @@ "preferences.common.auto-connect.placeholder": "啟用後,該軟體將在啟動時嘗試自動連接到歷史無線裝置", "preferences.common.auto-mirror.name": "自動執行鏡像", "preferences.common.auto-mirror.placeholder": "啟用後,裝置列表中的裝置將自動執行鏡像", + "preferences.common.edgeHidden.name": "主面板貼邊隱藏", + "preferences.common.edgeHidden.placeholder": "啟用後,當滑鼠靠近螢幕邊緣離開面板時,主面板將自動隱藏", + "preferences.common.edgeHidden.tips": "注意:更改此選項後,需要重啟應用程式才能生效", "preferences.video.name": "影片控制", "preferences.video.disable-video.name": "停用影片轉發", diff --git a/src/store/preference/model/common/index.js b/src/store/preference/model/common/index.js index 83bbe97..953aaf1 100644 --- a/src/store/preference/model/common/index.js +++ b/src/store/preference/model/common/index.js @@ -161,6 +161,14 @@ export default { value: undefined, placeholder: 'preferences.common.floatControl.placeholder', }, + edgeHidden: { + label: 'preferences.common.edgeHidden.name', + field: 'edgeHidden', + type: 'Switch', + value: undefined, + placeholder: 'preferences.common.edgeHidden.placeholder', + tips: 'preferences.common.edgeHidden.tips', + }, debug: { label: 'preferences.common.debug.name', field: 'debug',