From 9555f58df5f1c4bc4a263ddf586c605785a094ef Mon Sep 17 00:00:00 2001 From: viarotel Date: Mon, 28 Oct 2024 11:26:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E2=9A=97=EF=B8=8F=20Experimental=20sup?= =?UTF-8?q?port=20for=20turning=20off=20screen=20controls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/configs/index.js | 12 ++---------- electron/exposes/scrcpy/index.js | 19 ++++++++++++------- electron/ipc/shortcuts/index.js | 9 +-------- .../Device/components/ControlBar/index.vue | 8 +++++--- src/locales/languages/en-US.json | 2 +- src/locales/languages/ru-RU.json | 2 +- src/locales/languages/zh-CN.json | 2 +- src/locales/languages/zh-TW.json | 2 +- src/utils/command/index.js | 6 +++--- 9 files changed, 27 insertions(+), 35 deletions(-) diff --git a/electron/configs/index.js b/electron/configs/index.js index bc0e946..9d1ec02 100644 --- a/electron/configs/index.js +++ b/electron/configs/index.js @@ -24,14 +24,6 @@ export const trayPath export const logPath = process.env.LOG_PATH export function getLogoPath() { - let icon = logoPath - - if (process.platform === 'win32') { - icon = icoLogoPath - } - else if (process.platform === 'darwin') { - icon = icnsLogoPath - } - - return logoPath + const icon = logoPath + return icon } diff --git a/electron/exposes/scrcpy/index.js b/electron/exposes/scrcpy/index.js index 5d11ffa..18aea9d 100644 --- a/electron/exposes/scrcpy/index.js +++ b/electron/exposes/scrcpy/index.js @@ -9,7 +9,7 @@ let adbkit const exec = util.promisify(_exec) -async function shell(command, { stdout, stderr } = {}) { +async function shell(command, { stdout, stderr, ...options } = {}) { const spawnPath = appStore.get('common.scrcpyPath') || scrcpyPath const ADB = appStore.get('common.adbPath') || adbPath const args = command.split(' ') @@ -18,6 +18,7 @@ async function shell(command, { stdout, stderr } = {}) { env: { ...process.env, ADB }, shell: true, encoding: 'utf8', + ...options, }) scrcpyProcess.stdout.on('data', (data) => { @@ -168,13 +169,17 @@ async function mirrorGroup(serial, { openNum = 1, ...options } = {}) { return Promise.allSettled(results) } -async function control(serial, { command, exec = true, ...options } = {}) { - const currentShell = exec ? execShell : shell - +async function helper( + serial, + command = '', + { hiddenWindow = false, ...options } = {}, +) { const stringCommand = commandHelper.stringify(command) - return currentShell( - `--serial="${serial}" --no-video --no-audio ${stringCommand}`, + return execShell( + `--serial="${serial}" --window-title="EscrcpyHelper" ${ + hiddenWindow ? '--window-x=-300 --window-y=-300' : '' + } --no-video --no-audio --mouse=disabled ${stringCommand}`, options, ) } @@ -189,6 +194,6 @@ export default (options = {}) => { mirror, record, mirrorGroup, - control, + helper, } } diff --git a/electron/ipc/shortcuts/index.js b/electron/ipc/shortcuts/index.js index e0c4d90..15d20c9 100644 --- a/electron/ipc/shortcuts/index.js +++ b/electron/ipc/shortcuts/index.js @@ -1,12 +1,5 @@ // import { globalShortcut } from 'electron' export default (mainWindow) => { - // mainWindow.on('focus', () => { - // globalShortcut.register('CommandOrControl+F', (event) => { - // mainWindow.webContents.send('focus-on-search') - // }) - // }) - // mainWindow.on('blur', () => { - // globalShortcut.unregister('CommandOrControl+F') - // }) + // globalShortcut.register('Alt+O', () => {}) } diff --git a/src/components/Device/components/ControlBar/index.vue b/src/components/Device/components/ControlBar/index.vue index 65dc233..8eeed6a 100644 --- a/src/components/Device/components/ControlBar/index.vue +++ b/src/components/Device/components/ControlBar/index.vue @@ -16,7 +16,7 @@