diff --git a/electron/configs/index.js b/electron/configs/index.js index 622c1138..2509fc0e 100644 --- a/electron/configs/index.js +++ b/electron/configs/index.js @@ -1,4 +1,5 @@ import { resolve } from 'node:path' +import which from 'which' import { buildResolve, extraResolve } from '@electron/helpers/index.js' @@ -11,7 +12,14 @@ export const icoLogoPath = buildResolve('logo.ico') export const icnsLogoPath = buildResolve('logo.icns') export const adbPath - = process.platform === 'win32' ? extraResolve('core/adb.exe') : 'adb' + = process.platform === 'win32' + ? extraResolve('core/adb.exe') + : which.sync('adb', { nothrow: true }) export const scrcpyPath - = process.platform === 'win32' ? extraResolve('core/scrcpy.exe') : 'scrcpy' + = process.platform === 'win32' + ? extraResolve('core/scrcpy.exe') + : which.sync('scrcpy', { nothrow: true }) + +// console.log('adbPath', adbPath) +// console.log('scrcpyPath', scrcpyPath) diff --git a/electron/exposes/adbkit/index.js b/electron/exposes/adbkit/index.js index 45ea136d..74a6349f 100644 --- a/electron/exposes/adbkit/index.js +++ b/electron/exposes/adbkit/index.js @@ -4,7 +4,6 @@ import path from 'node:path' import fs from 'node:fs' import dayjs from 'dayjs' import { Adb } from '@devicefarmer/adbkit' -import _which from 'which' import appStore from '@electron/helpers/store.js' import { adbPath } from '@electron/configs/index.js' @@ -100,8 +99,6 @@ const install = async (id, path) => client.getDevice(id).install(path) const version = async () => client.version() -const which = async () => _which('adb') - const watch = async (callback) => { const tracker = await client.trackDevices() tracker.on('add', async (ret) => { @@ -147,7 +144,6 @@ export default () => { screencap, install, version, - which, watch, } } diff --git a/electron/exposes/scrcpy/index.js b/electron/exposes/scrcpy/index.js index 277585f4..90be7569 100644 --- a/electron/exposes/scrcpy/index.js +++ b/electron/exposes/scrcpy/index.js @@ -1,5 +1,4 @@ import { spawn } from 'node:child_process' -import _which from 'which' import appStore from '@electron/helpers/store.js' import { adbPath, scrcpyPath } from '@electron/configs/index.js' @@ -48,9 +47,6 @@ const shell = async (command, { stdout, stderr } = {}) => { }) } -const which = async () => _which('scrcpy') - export default () => ({ shell, - which, }) diff --git a/src/App.vue b/src/App.vue index 418ebd17..fce6be65 100644 --- a/src/App.vue +++ b/src/App.vue @@ -55,15 +55,14 @@ export default { return false } - try { - const adbWhichPath = await this.$adb.which() - console.log('adbWhichPath', adbWhichPath) - const scrcpyWhichPath = await this.$scrcpy.which() - console.log('scrcpyWhichPath', scrcpyWhichPath) + const { adbPath, scrcpyPath } = this.$electron?.configs || {} + + if (adbPath) { return false } - catch (error) { - console.warn(error?.message || error?.cause?.message) + + if (scrcpyPath) { + return false } this.$alert(