mirror of
https://github.com/viarotel-org/escrcpy.git
synced 2024-11-27 17:00:53 +01:00
perf: ⚗️ Experimental support for turning off screen controls
This commit is contained in:
parent
4be2cf4f14
commit
9555f58df5
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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', () => {})
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
<Scrollable ref="scrollableRef" class="flex-1 w-0 flex items-center">
|
||||
<component
|
||||
:is="item.component || 'div'"
|
||||
v-for="(item, index) in controlModel"
|
||||
v-for="(item, index) of controlModel"
|
||||
:key="index"
|
||||
class="flex-none"
|
||||
v-bind="{
|
||||
@ -32,7 +32,7 @@
|
||||
:disabled="device.$unauthorized"
|
||||
:title="$t(item.tips || item.label)"
|
||||
:loading="loading"
|
||||
@click="handleClick(item, trigger)"
|
||||
@click="handleClick(item, trigger || item.trigger)"
|
||||
>
|
||||
<template #icon>
|
||||
<svg-icon
|
||||
@ -120,8 +120,10 @@ export default {
|
||||
{
|
||||
label: 'device.control.turnScreenOff',
|
||||
elIcon: 'TurnOff',
|
||||
scrcpyCommand: '--turn-screen-off',
|
||||
tips: 'device.control.turnScreenOff.tips',
|
||||
trigger: () => {
|
||||
window.scrcpy.helper(this.device.id, '--turn-screen-off')
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'device.control.notification',
|
||||
|
@ -167,7 +167,7 @@
|
||||
"device.control.capture.success.message.title": "Screenshot Success",
|
||||
"device.control.reboot": "Reboot",
|
||||
"device.control.turnScreenOff": "Turn screen off",
|
||||
"device.control.turnScreenOff.tips": "Turn off the screen without affecting control",
|
||||
"device.control.turnScreenOff.tips": "Turn off the screen while maintaining control (Experimental): This action will create an EscrcpyHelper process; manually closing this process will reopen the screen.",
|
||||
"device.control.power": "Power",
|
||||
"device.control.power.tips": "Turn screen on/off",
|
||||
"device.control.notification": "Notification",
|
||||
|
@ -167,7 +167,7 @@
|
||||
"device.control.capture.success.message.title": "Скриншот успешно создан",
|
||||
"device.control.reboot": "Перезагрузить",
|
||||
"device.control.turnScreenOff": "Выключить экран",
|
||||
"device.control.turnScreenOff.tips": "Выключить экран без потери управления",
|
||||
"device.control.turnScreenOff.tips": "Отключение экрана с сохранением контроля (экспериментально): это действие создаст процесс EscrcpyHelper; при ручном завершении этого процесса экран снова включится.",
|
||||
"device.control.power": "Питание",
|
||||
"device.control.power.tips": "Включить/выключить экран",
|
||||
"device.control.notification": "Уведомление",
|
||||
|
@ -167,7 +167,7 @@
|
||||
"device.control.capture.success.message.title": "截屏成功",
|
||||
"device.control.reboot": "重启设备",
|
||||
"device.control.turnScreenOff": "关闭屏幕",
|
||||
"device.control.turnScreenOff.tips": "关闭屏幕而不影响控制",
|
||||
"device.control.turnScreenOff.tips": "关闭屏幕且保持控制(实验功能):此操作将创建一个 EscrcpyHelper 进程,手动关闭进程将重新打开屏幕。",
|
||||
"device.control.power": "电源键",
|
||||
"device.control.power.tips": "可以用来开启或关闭屏幕",
|
||||
"device.control.notification": "通知栏",
|
||||
|
@ -167,7 +167,7 @@
|
||||
"device.control.capture.success.message.title": "截圖成功",
|
||||
"device.control.reboot": "重啟裝置",
|
||||
"device.control.turnScreenOff": "關閉螢幕",
|
||||
"device.control.turnScreenOff.tips": "關閉螢幕而不影響控制",
|
||||
"device.control.turnScreenOff.tips": "關閉螢幕且保持控制(實驗功能):此操作將創建一個 EscrcpyHelper 進程,手動關閉該進程將重新打開螢幕。",
|
||||
"device.control.power": "電源鍵",
|
||||
"device.control.power.tips": "可以用來開啟或關閉螢幕",
|
||||
"device.control.notification": "通知欄",
|
||||
|
@ -67,7 +67,7 @@ function stringify(options) {
|
||||
// Process each option
|
||||
for (const [key, value] of Object.entries(options)) {
|
||||
// Skip null or undefined values
|
||||
if ([null, undefined, false].includes(value)) {
|
||||
if ([null, undefined, false, ''].includes(value)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -87,10 +87,10 @@ function stringify(options) {
|
||||
continue // 跳过空数组
|
||||
}
|
||||
value.forEach((item) => {
|
||||
if (item !== null && item !== undefined) {
|
||||
if (![null, undefined, false, ''].includes(item)) {
|
||||
const formattedValue = formatValue(item)
|
||||
if (formattedValue) {
|
||||
args.push(`${paramName} ${formattedValue}`)
|
||||
args.push(`${paramName}=${formattedValue}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user