From b52a4dcfd1f5b58fae199f14f8bb8c543f9de3b3 Mon Sep 17 00:00:00 2001 From: ModStart Date: Sun, 15 Dec 2024 10:14:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=8A=95=E5=B1=8F?= =?UTF-8?q?=E6=97=B6=E9=BB=98=E8=AE=A4=E8=B0=83=E7=94=A8=E5=86=85=E7=BD=AE?= =?UTF-8?q?=20adb=20=EF=BC=8C=E9=81=BF=E5=85=8D=E6=89=BE=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=20adb=20=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + electron/mapi/adb/render.ts | 8 ++++---- electron/mapi/scrcpy/render.ts | 27 ++++++++++++++++++--------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/changelog.md b/changelog.md index 8d9394d4..e6250716 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ - 新增:调试窗口统一管理,方便查看调试信息 - 优化:Mac 打包增加自建证书,避免安装提示被损坏问题 - 优化:跨页面调用方式优化 +- 优化:投屏时默认调用内置 adb ,避免找不到 adb 路径问题 ## v0.2.0 diff --git a/electron/mapi/adb/render.ts b/electron/mapi/adb/render.ts index 08d1c3f8..058cb169 100644 --- a/electron/mapi/adb/render.ts +++ b/electron/mapi/adb/render.ts @@ -72,10 +72,10 @@ const adbShell = async (command: string, deviceId?: string) => { } const adbSpawnShell = async (command: string, option?: { - stdout?: Function, - stderr?: Function, - success?: Function, - error?: Function, + stdout?: (data: string, process: any) => void, + stderr?: (data: string, process: any) => void, + success?: (process: any) => void, + error?: (msg: string, exitCode: number, process: any) => void, } | null, deviceId?: string) => { const adbPath = await getBinPath() if (deviceId) { diff --git a/electron/mapi/scrcpy/render.ts b/electron/mapi/scrcpy/render.ts index 4eee6e75..22112aaf 100644 --- a/electron/mapi/scrcpy/render.ts +++ b/electron/mapi/scrcpy/render.ts @@ -5,6 +5,7 @@ import Config from "../config/render"; import {extraResolve} from "../../lib/env"; import {Apps} from "../app"; import fs from "node:fs"; +import {ADB} from "../adb/render"; const exec = util.promisify(_exec) @@ -40,10 +41,13 @@ const shell = async (command: string) => { } const spawnShell = async (command: string, option: { - stdout?: Function, - stderr?: Function, - success?: Function, - error?: Function, + stdout?: (data: string, process: any) => void, + stderr?: (data: string, process: any) => void, + success?: (process: any) => void, + error?: (msg: string, exitCode: number, process: any) => void, + cwd?: string, + outputEncoding?: string, + env?: Record, } | null = null) => { const scrcpyPath = await getBinPath() // console.log('spawnShell', `"${scrcpyPath}" ${command}`) @@ -55,19 +59,24 @@ const mirror = async ( option: { title?: string, args?: string, - stdout?: Function, - stderr?: Function, - success?: Function, - error?: Function, + stdout?: (data: string, process: any) => void, + stderr?: (data: string, process: any) => void, + success?: (process: any) => void, + error?: (msg: string, exitCode: number, process: any) => void, + env?: Record, }, ) => { - option = option || {} + option = Object.assign({ + env: {}, + }, option) + option.env['ADB'] = await ADB.getBinPath() // console.log('mirror', serial, option.args) return spawnShell(`--serial="${serial}" --window-title="${option.title}" ${option.args}`, { stdout: option.stdout, stderr: option.stderr, success: option.success, error: option.error, + env: option.env, }) }