同步移动端工程、设备控制改进与发布资料
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
} from "../current-display-playback.js";
|
||||
|
||||
const statusEls = {
|
||||
mobile: document.getElementById("topbar-mobile"),
|
||||
orientation: document.getElementById("status-orientation"),
|
||||
brightness: document.getElementById("status-brightness"),
|
||||
currentContent: document.getElementById("topbar-current-content"),
|
||||
@@ -760,9 +761,22 @@ export async function refreshDeviceStorage() {
|
||||
}
|
||||
}
|
||||
|
||||
let lastMobileSession = null;
|
||||
|
||||
export async function refreshStatus({ source = "manual" } = {}) {
|
||||
try {
|
||||
const data = await apiJson("/api/status");
|
||||
const mobile = data.mobile;
|
||||
if (statusEls.mobile) {
|
||||
statusEls.mobile.textContent = mobile?.connected
|
||||
? `手机:${mobile.client_name || "已连接"}`
|
||||
: (mobile?.available === false ? "手机蓝牙暂不可用" : "手机未连接");
|
||||
const session = `${data.service?.instance_id || ""}:${mobile?.generation || 0}`;
|
||||
if (mobile?.connected && lastMobileSession !== null && session !== lastMobileSession) {
|
||||
announce(`${mobile.client_name || "手机"}已连接`);
|
||||
}
|
||||
lastMobileSession = session;
|
||||
}
|
||||
syncCurrentDisplayDialogStatus(data);
|
||||
statusEls.orientation.textContent = `${data.state.orientation}°`;
|
||||
showDeviceBrightness(data.state);
|
||||
|
||||
@@ -263,6 +263,20 @@ function applyOtaStatus(status) {
|
||||
otaProgressGroup.hidden = true;
|
||||
setOtaFeedback("");
|
||||
}
|
||||
if (job?.phase !== "failed") {
|
||||
const recovery = status?.kernel_recovery;
|
||||
if (recovery?.state === "pending") {
|
||||
setOtaFeedback("应用更新完成;正在进行一次候选内核恢复重启…", "pending");
|
||||
} else if (recovery?.state === "succeeded") {
|
||||
setOtaFeedback("候选内核与 CPU 调频策略已恢复。", "ready");
|
||||
} else if (recovery?.state === "failed") {
|
||||
setOtaFeedback(`内核恢复失败:${recovery.reason || "请查看设备诊断"}`, "error");
|
||||
} else if (recovery?.state === "requires_package") {
|
||||
setOtaFeedback("应用已更新;内核材料缺失或损坏,需要专用修复包。", "error");
|
||||
} else if (recovery?.state === "ready") {
|
||||
setOtaFeedback("当前设备运行原内核,性能模式不可用;下次 OTA 将尝试轻量恢复。", "error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +295,7 @@ async function pollOtaUntilFinished() {
|
||||
const status = await fetchOtaStatus();
|
||||
if (disconnected) setOtaFeedback("设备服务已恢复,正在确认更新结果…", "pending");
|
||||
applyOtaStatus(status);
|
||||
if (!status.active) return;
|
||||
if (!status.active && status.kernel_recovery?.state !== "pending") return;
|
||||
} catch {
|
||||
disconnected = true;
|
||||
setOtaFeedback("设备正在切换软件版本,等待服务恢复…", "pending");
|
||||
@@ -297,7 +311,7 @@ async function loadOtaStatus() {
|
||||
try {
|
||||
const status = await fetchOtaStatus();
|
||||
applyOtaStatus(status);
|
||||
if (status.active) pollOtaUntilFinished();
|
||||
if (status.active || status.kernel_recovery?.state === "pending") pollOtaUntilFinished();
|
||||
} catch (error) {
|
||||
otaCurrentVersion.textContent = "读取失败";
|
||||
otaFeatureUpdatedAt.textContent = "读取失败";
|
||||
|
||||
Reference in New Issue
Block a user