From 38d1433a82d6c22c9bb6db681533c93e788e4cff Mon Sep 17 00:00:00 2001 From: viarotel Date: Sat, 28 Dec 2024 19:02:33 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E2=99=BB=EF=B8=8F=20Optimize=20device?= =?UTF-8?q?=20details=20performance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/exposes/adb/index.js | 26 +++----- package.json | 2 +- src/components/ControlBar/index.vue | 2 +- .../device/components/DevicePopover/index.vue | 63 ++++++++++++++----- src/pages/device/index.vue | 13 +--- 5 files changed, 61 insertions(+), 45 deletions(-) diff --git a/electron/exposes/adb/index.js b/electron/exposes/adb/index.js index a560c4ba..2b52b197 100644 --- a/electron/exposes/adb/index.js +++ b/electron/exposes/adb/index.js @@ -128,18 +128,12 @@ const tcpip = async (id, port = 5555) => client.getDevice(id).tcpip(port) const screencap = async (deviceId, options = {}) => { const { returnBase64 = false } = options - let fileStream = null - try { - const device = client.getDevice(deviceId) - fileStream = await device.screencap() - } - catch (error) { - console.warn(error?.message || error) - return false - } + const device = client.getDevice(deviceId) + + const fileStream = await device.screencap() if (!fileStream) { - return false + throw new Error('Failed to obtain screenshot data') } if (returnBase64) { @@ -292,17 +286,11 @@ async function connectCode(password, options = {}) { } async function battery(id) { - try { - const res = await deviceShell(id, 'dumpsys battery') + const res = await deviceShell(id, 'dumpsys battery') - const value = parseBatteryDump(res) + const value = parseBatteryDump(res) - return value - } - catch (error) { - console.warn(error?.message || error) - return {} - } + return value } function init() { diff --git a/package.json b/package.json index bd1aae18..a794ac88 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@antfu/eslint-config": "3.8.0", - "@devicefarmer/adbkit": "3.2.6", + "@devicefarmer/adbkit": "3.3.8", "@electron-toolkit/preload": "3.0.1", "@electron-toolkit/utils": "3.0.0", "@electron/remote": "2.1.2", diff --git a/src/components/ControlBar/index.vue b/src/components/ControlBar/index.vue index 0838d5b6..9a33203a 100644 --- a/src/components/ControlBar/index.vue +++ b/src/components/ControlBar/index.vue @@ -1,6 +1,6 @@