mirror of
https://gitee.com/viarotel-org/escrcpy.git
synced 2024-11-30 02:08:59 +08:00
perf: ♻️ Optimization gnirehtet and scrcpy
This commit is contained in:
parent
2d02aaa17c
commit
9cf800c2a0
@ -26,6 +26,7 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
|
||||
|
||||
console.log('gnirehtet.shell.spawnPath', spawnPath)
|
||||
console.log('gnirehtet.shell.adbPath', adbPath)
|
||||
console.log('gnirehtet.shell.command', command)
|
||||
|
||||
const gnirehtetProcess = spawn(`"${spawnPath}"`, args, {
|
||||
env: { ...process.env, ADB, GNIREHTET_APK },
|
||||
@ -37,7 +38,7 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
|
||||
const stringData = data.toString()
|
||||
|
||||
if (debug) {
|
||||
console.log('gnirehtetProcess.stdout.data:', stringData)
|
||||
console.log(`${command}.gnirehtet.process.stdout.data:`, stringData)
|
||||
}
|
||||
|
||||
if (stdout) {
|
||||
@ -49,7 +50,7 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
|
||||
const stringData = data.toString()
|
||||
|
||||
if (debug) {
|
||||
console.error('gnirehtetProcess.stderr.data:', stringData)
|
||||
console.error(`${command}.gnirehtet.process.stderr.data:`, stringData)
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
@ -59,6 +60,8 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
gnirehtetProcess.on('close', (code) => {
|
||||
console.log(`${command}.gnirehtet.process.close.code`, code)
|
||||
|
||||
if (code === 0) {
|
||||
resolve()
|
||||
}
|
||||
@ -73,10 +76,10 @@ const shell = async (command, { debug = false, stdout, stderr } = {}) => {
|
||||
})
|
||||
}
|
||||
|
||||
const install = deviceId => shell(`install ${deviceId}`)
|
||||
const start = deviceId => shell(`start ${deviceId}`)
|
||||
const stop = deviceId => shell(`stop ${deviceId}`)
|
||||
const tunnel = deviceId => shell(`tunnel ${deviceId}`)
|
||||
const install = deviceId => shell(`install "${deviceId}"`)
|
||||
const start = deviceId => shell(`start "${deviceId}"`)
|
||||
const stop = deviceId => shell(`stop "${deviceId}"`)
|
||||
const tunnel = deviceId => shell(`tunnel "${deviceId}"`)
|
||||
|
||||
const installed = async (deviceId) => {
|
||||
const res = await adbkit.isInstalled(deviceId, 'com.genymobile.gnirehtet')
|
||||
@ -93,10 +96,9 @@ const stopRelayProcess = () => {
|
||||
relayProcess?.kill()
|
||||
relayProcess = null
|
||||
}
|
||||
|
||||
const relay = async (args) => {
|
||||
if (relayProcess) {
|
||||
return relayProcess
|
||||
}
|
||||
stopRelayProcess()
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
shell('relay', {
|
||||
@ -109,11 +111,9 @@ const relay = async (args) => {
|
||||
resolve(process)
|
||||
},
|
||||
stderr: (error) => {
|
||||
stopRelayProcess()
|
||||
reject(error)
|
||||
},
|
||||
})?.catch((error) => {
|
||||
stopRelayProcess()
|
||||
}).catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
|
@ -298,11 +298,11 @@ export default {
|
||||
|
||||
const savePath = this.getRecordPath(row)
|
||||
try {
|
||||
const command = `--serial=${row.id} --window-title=${
|
||||
const command = `--serial="${row.id}" --window-title="${
|
||||
row.$remark ? `${row.$remark}-` : ''
|
||||
}${row.$name}-${row.id}-🎥${this.$t(
|
||||
'device.record.progress',
|
||||
)}... --record=${savePath} ${this.scrcpyArgs(row.id)}`
|
||||
)}..." --record="${savePath}" ${this.scrcpyArgs(row.id)}`
|
||||
|
||||
console.log('handleRecord.command', command)
|
||||
|
||||
@ -338,9 +338,9 @@ export default {
|
||||
|
||||
try {
|
||||
await this.$scrcpy.shell(
|
||||
`--serial=${row.id} --window-title=${
|
||||
`--serial="${row.id}" --window-title="${
|
||||
row.$remark ? `${row.$remark}-` : ''
|
||||
}${row.$name}-${row.id} ${this.scrcpyArgs(row.id)}`,
|
||||
}${row.$name}-${row.id}" ${this.scrcpyArgs(row.id)}`,
|
||||
{ stdout: this.onStdout },
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user