feat: 分发包改为字节码,并补上 MuMu 探测和下载列表滚动
This commit is contained in:
+40
-6
@@ -470,6 +470,15 @@ function deviceLabel(item: Device) {
|
||||
return `${item.model} · ${item.serial} · ${mark}`;
|
||||
}
|
||||
|
||||
function applyDeviceList(list: Device[]) {
|
||||
devices.value = list;
|
||||
const stillThere = devices.value.some((item) => item.serial === serial.value && item.state === "device");
|
||||
if (!stillThere) {
|
||||
const ready = devices.value.filter((item) => item.state === "device");
|
||||
serial.value = ready.length === 1 ? ready[0].serial : null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDevices() {
|
||||
error.value = "";
|
||||
devicesBusy.value = true;
|
||||
@@ -479,12 +488,7 @@ async function loadDevices() {
|
||||
if (!response.ok) {
|
||||
throw new Error(payload.detail || "读取设备失败");
|
||||
}
|
||||
devices.value = payload.devices || [];
|
||||
const stillThere = devices.value.some((item) => item.serial === serial.value && item.state === "device");
|
||||
if (!stillThere) {
|
||||
const ready = devices.value.filter((item) => item.state === "device");
|
||||
serial.value = ready.length === 1 ? ready[0].serial : null;
|
||||
}
|
||||
applyDeviceList(payload.devices || []);
|
||||
} catch (exc) {
|
||||
devices.value = [];
|
||||
serial.value = null;
|
||||
@@ -494,6 +498,29 @@ async function loadDevices() {
|
||||
}
|
||||
}
|
||||
|
||||
async function probeMumu() {
|
||||
error.value = "";
|
||||
devicesBusy.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/adb/probe-mumu", { method: "POST" });
|
||||
const payload = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(payload.detail || "没有连上 MuMu");
|
||||
}
|
||||
applyDeviceList(payload.devices || []);
|
||||
const ready = devices.value.filter((item) => item.state === "device");
|
||||
if (!ready.length) {
|
||||
const ports = Array.isArray(payload.ports) ? payload.ports.join("、") : "";
|
||||
throw new Error(ports ? `已尝试连接 MuMu 端口 ${ports},但设备还不可用。请在模拟器里允许调试后再探测。` : "没有连上 MuMu");
|
||||
}
|
||||
} catch (exc) {
|
||||
if (!devices.value.length) serial.value = null;
|
||||
error.value = exc instanceof Error ? exc.message : "没有连上 MuMu";
|
||||
} finally {
|
||||
devicesBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(method, (value) => {
|
||||
error.value = "";
|
||||
if (value === "adb") loadDevices();
|
||||
@@ -854,6 +881,7 @@ onUnmounted(stopLive);
|
||||
placeholder="请选择设备"
|
||||
/>
|
||||
<n-button :loading="devicesBusy" @click="loadDevices">刷新</n-button>
|
||||
<n-button :loading="devicesBusy" @click="probeMumu">探测 MuMu</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-text v-if="method === 'guest'" class="hint" depth="3">将注册一个新的游客账号,并读取它的个人信息。</n-text>
|
||||
@@ -943,6 +971,12 @@ html { color-scheme: dark; }
|
||||
.shell .main-pane .n-layout-content > .n-layout-scroll-container {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.shell .main-pane .n-layout-content > .n-layout-scroll-container > * {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
.sider { height: 100%; min-height: 100%; display: flex; flex-direction: column; box-sizing: border-box; padding: 12px 8px; }
|
||||
.user-nav {
|
||||
|
||||
Reference in New Issue
Block a user