From a84c775fa1ca507f551c4b0a1499d40d9bc2aedd Mon Sep 17 00:00:00 2001 From: viarotel Date: Wed, 23 Oct 2024 17:46:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Support=20to=20close=20the?= =?UTF-8?q?=20device=20screen=20when=20controlling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control/electron/helpers/index.js | 5 +++-- .../Device/components/ControlBar/index.vue | 17 +++++++++++++---- src/components/Device/index.vue | 2 +- src/locales/languages/en-US.json | 8 +++++--- src/locales/languages/ru-RU.json | 6 ++++-- src/locales/languages/zh-CN.json | 2 ++ src/locales/languages/zh-TW.json | 2 ++ src/utils/command/index.js | 7 +++++-- 8 files changed, 35 insertions(+), 14 deletions(-) diff --git a/control/electron/helpers/index.js b/control/electron/helpers/index.js index 1c047336..1549fda4 100644 --- a/control/electron/helpers/index.js +++ b/control/electron/helpers/index.js @@ -10,8 +10,9 @@ export function initControlWindow(mainWindow) { const controlWindow = new BrowserWindow({ icon: getLogoPath(), - width: 500, - minWidth: 500, + parent: mainWindow, + width: 700, + minWidth: 700, height: 28, maxHeight: 28, frame: false, diff --git a/src/components/Device/components/ControlBar/index.vue b/src/components/Device/components/ControlBar/index.vue index 26e424b9..65dc233e 100644 --- a/src/components/Device/components/ControlBar/index.vue +++ b/src/components/Device/components/ControlBar/index.vue @@ -117,6 +117,12 @@ export default { elIcon: 'Back', command: 'input keyevent 4', }, + { + label: 'device.control.turnScreenOff', + elIcon: 'TurnOff', + scrcpyCommand: '--turn-screen-off', + tips: 'device.control.turnScreenOff.tips', + }, { label: 'device.control.notification', elIcon: 'Notification', @@ -203,13 +209,16 @@ export default { this.$refs.scrollableRef.scrollForward() }, handleClick(row, trigger) { - if (row?.command) { - this.$adb.deviceShell(this.device.id, row.command) + if (trigger) { + trigger(row) return false } - if (trigger) { - trigger(row) + if (row?.command) { + this.$adb.deviceShell(this.device.id, row.command) + } + else if (row?.scrcpyCommand) { + this.$scrcpy.control(this.device.id, { command: row.scrcpyCommand }) } }, }, diff --git a/src/components/Device/index.vue b/src/components/Device/index.vue index 550459d6..0751aaa4 100644 --- a/src/components/Device/index.vue +++ b/src/components/Device/index.vue @@ -86,7 +86,7 @@