-
- {{ formattedVoltage }}V {{ temperature }}°C
+
+
+ 剩余电量
+ {{ batteryChargeCounter }}mAh
+
+
+ 当前电流
+ {{ formattedBatteryCurrent }}mA
+
+
+ 电池电压
+ {{ formattedVoltage }}V
+
+
+ 电池温度
+ {{ temperature }}°C
+
+
+ 电池健康
+ {{ batteryHealth }}%
+
@@ -36,6 +52,18 @@ const props = defineProps({
type: Number,
required: true,
},
+ batteryHealth: {
+ type: Number,
+ required: true,
+ },
+ batteryChargeCounter: {
+ type: Number,
+ required: true,
+ },
+ batteryCurrent: {
+ type: Number,
+ required: true,
+ },
});
const batteryLevelStyle = computed(() => {
@@ -47,6 +75,10 @@ const batteryLevelStyle = computed(() => {
const formattedVoltage = computed(() => {
return isNaN(props.voltage) ? '0.000' : props.voltage.toFixed(3);
});
+
+const formattedBatteryCurrent = computed(() => {
+ return props.batteryCurrent > 0 ? `+${props.batteryCurrent}` : props.batteryCurrent;
+});
diff --git a/src/components/Device/DeviceBasicInfo.vue b/src/components/Device/DeviceBasicInfo.vue
index 9acdc37..da090ad 100644
--- a/src/components/Device/DeviceBasicInfo.vue
+++ b/src/components/Device/DeviceBasicInfo.vue
@@ -6,8 +6,8 @@
品牌
{{ deviceInfo.brand }}
-
连接状态
-
{{ deviceInfo.type }}
+
root 状态
+
{{ deviceInfo.rootState }}
型号
@@ -43,16 +43,24 @@
显示密度
{{ deviceInfo.screenDensity }}
闪存类型
-
{{ storageType }}
+
{{ deviceInfo.storageType }}
+
+
+
IP 地址
+
{{ deviceInfo.ipAddress || '-' }}
主板 ID
{{ deviceInfo.board || '-' }}
-
平台
+
硬件平台
{{ deviceInfo.hardware }}
+
+
序列号
+
{{ deviceInfo.serialNumber }}
+
编译版本
{{ deviceInfo.fingerPrint }}
@@ -78,32 +86,42 @@ const props = defineProps({
// 计算属性:Bootloader 状态
const bootloaderStatus = computed(() => {
- // 这里可以添加实际的 bootloader 状态检测逻辑
- return 'locked';
+ if (['green'].includes(props.deviceInfo.bootloader)) {
+ return 'locked';
+ }
+ return 'unlocked';
});
// 计算属性:A/B 分区状态
const abPartitionStatus = computed(() => {
- // 这里可以添加实际的 A/B 分区检测逻辑
- return 'A-Only设备';
+ switch (props.deviceInfo.abPartition) {
+ case '_a':
+ return 'Slot A';
+ case '_b':
+ return 'Slot B';
+ default:
+ return 'Unknown';
+ }
});
+
+const formatSeconds = (seconds) => {
+ const parts = [];
+ const d = Math.floor(seconds / 86400);
+ const h = Math.floor(seconds % 86400 / 3600);
+ const m = Math.floor(seconds % 3600 / 60);
+ const s = Math.floor(seconds % 60);
+
+ if (d) parts.push(d + '天');
+ if (h) parts.push(h + '小时');
+ if (m) parts.push(m + '分');
+ if (s || !parts.length) parts.push(s + '秒');
+
+ return parts.join('');
+};
// 计算属性:开机时间
const uptime = computed(() => {
- // 这里可以添加实际的开机时间计算逻辑
- return '0天6时44分44秒';
-});
-
-// 计算属性:存储类型
-const storageType = computed(() => {
- // 这里可以添加实际的存储类型检测逻辑
- return 'UFS';
-});
-
-// 计算属性:内核版本
-const kernelVersion = computed(() => {
- // 这里可以添加实际的内核版本获取逻辑
- return '49.537-UOTAN-PE14-STABLE+';
+ return formatSeconds(props.deviceInfo.uptime);
});
diff --git a/src/components/Device/DeviceInfo.vue b/src/components/Device/DeviceInfo.vue
index 8b4b0e9..13e69d2 100644
--- a/src/components/Device/DeviceInfo.vue
+++ b/src/components/Device/DeviceInfo.vue
@@ -45,15 +45,20 @@ const deviceInfo = ref({
batteryPercentage: 0,
voltage: 0,
temperature: 0,
+ batteryHealth: 0,
+ batteryChargeCounter: 0,
+ batteryCurrent: 0,
+ oemLockedState: '',
bootloader: '',
abPartition: '',
uptime: '',
storageType: '',
kernelVersion: '',
+ rootState: 'none',
});
async function executeShellCommand(device: Adb, command: string): Promise
{
- const subprocess = await device.subprocess.shell(command);
+ const subprocess = await device.subprocess.shellProtocol!.spawn(command);
const reader = subprocess.stdout.getReader();
let result = '';
let done = false;
@@ -70,7 +75,7 @@ async function executeShellCommand(device: Adb, command: string): Promise /dev/null 2>&1 && echo rooted || echo none'
+ ),
};
}
@@ -322,6 +338,9 @@ onMounted(async () => {
:batteryPercentage="deviceInfo.batteryPercentage"
:voltage="deviceInfo.voltage"
:temperature="deviceInfo.temperature"
+ :batteryHealth="deviceInfo.batteryHealth"
+ :batteryChargeCounter="deviceInfo.batteryChargeCounter"
+ :batteryCurrent="deviceInfo.batteryCurrent"
/>
diff --git a/src/components/Device/DeviceShell.vue b/src/components/Device/DeviceShell.vue
index 475fcb4..af2f6e7 100644
--- a/src/components/Device/DeviceShell.vue
+++ b/src/components/Device/DeviceShell.vue
@@ -2,9 +2,9 @@
import { ref, onMounted } from 'vue';
import { encodeUtf8 } from '@yume-chan/adb';
import client from '../Scrcpy/adb-client';
-import { Terminal } from 'xterm';
-import { FitAddon } from 'xterm-addon-fit';
-import 'xterm/css/xterm.css';
+import { Terminal } from '@xterm/xterm';
+import { FitAddon } from '@xterm/addon-fit';
+import '@xterm/xterm/css/xterm.css';
const term = ref
(null);
@@ -61,13 +61,13 @@ async function startTerminal() {
return;
}
- const process = await client.device?.subprocess.shell();
+ const process = await client.device?.subprocess.shellProtocol!.pty();
if (!process) {
console.error('获取 subprocess 失败');
return;
}
- process.stdout
+ process.output
.pipeTo(
new WritableStream({
write(chunk) {
@@ -79,7 +79,7 @@ async function startTerminal() {
console.error('输出流错误:', error);
});
- const writer = process.stdin.getWriter();
+ const writer = process.input.getWriter();
terminal.onData((data) => {
const buffer = encodeUtf8(data);
writer.write(buffer).catch((error) => {
diff --git a/src/components/Device/NavigationBar.vue b/src/components/Device/NavigationBar.vue
index 37202e8..a60a974 100644
--- a/src/components/Device/NavigationBar.vue
+++ b/src/components/Device/NavigationBar.vue
@@ -1,9 +1,10 @@
-