Skip to content

Commit

Permalink
优化:投屏时默认调用内置 adb ,避免找不到 adb 路径问题
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Dec 15, 2024
1 parent 296fccb commit b52a4dc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- 新增:调试窗口统一管理,方便查看调试信息
- 优化:Mac 打包增加自建证书,避免安装提示被损坏问题
- 优化:跨页面调用方式优化
- 优化:投屏时默认调用内置 adb ,避免找不到 adb 路径问题

## v0.2.0

Expand Down
8 changes: 4 additions & 4 deletions electron/mapi/adb/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 18 additions & 9 deletions electron/mapi/scrcpy/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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<string, any>,
} | null = null) => {
const scrcpyPath = await getBinPath()
// console.log('spawnShell', `"${scrcpyPath}" ${command}`)
Expand All @@ -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<string, any>,
},
) => {
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,
})
}

Expand Down

0 comments on commit b52a4dc

Please sign in to comment.