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