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, }) }