优化后端

This commit is contained in:
Miayui
2026-09-11 17:56:56 +08:00
parent 7eed11b774
commit 812e67422d
7299 changed files with 1744959 additions and 112 deletions
+73 -19
View File
@@ -373,6 +373,19 @@
if (new Set(["driver", "passenger", "rear"]).has(target) && temperature !== null) {
return command("空调温度", `ac temp ${target} ${temperature}`);
}
const vehicleZones = new Set([
"vehicle",
"front-row",
"rear-row",
"rear-left",
"rear-right",
]);
if (vehicleZones.has(target) && temperature !== null) {
return command(
"空调温度",
`Climate_Control_064_04(${target}=${temperature}°C)`,
);
}
}
if (capability === "climate.set_control_mode") {
const mode = String(parameters.mode ?? parameters.control_mode ?? "");
@@ -466,6 +479,22 @@
const level = boundedInteger(parameters.brightness_level, 1, 5);
if (level !== null) return command("氛围灯", `light ambient brightness ${level}`);
}
if (capability === "ambient_light.set_illumination") {
const color = String(parameters.color_hex || "").trim().toUpperCase();
const brightness = boundedInteger(parameters.brightness_pct, 0, 100);
if (/^#[0-9A-F]{6}$/.test(color) && brightness !== null) {
return command(
"氛围灯颜色与亮度",
`Ambient_RGB_Control_32B_2B(color=${color}, brightness=${brightness}%)`,
);
}
}
if (capability === "ambient_light.set_mode") {
const mode = String(parameters.mode || "").trim();
if (new Set(["camping", "rest", "cinema", "meditation", "romantic", "off", "on"]).has(mode)) {
return command("氛围灯模式", `Ambient_Mode_Control_496_04(mode=${mode})`);
}
}
if (capability === "roof.set_shade_motion") {
const motion = String(parameters.motion || "");
if (new Set(["open", "close", "half", "stop"]).has(motion)) {
@@ -526,13 +555,39 @@
|| telemetry.feedback_observed === true
|| telemetry.physical_effect_confirmed === true
);
const failureMessage = String(execution?.message || "").trim();
const executionFailed = execution?.status === "failed"
|| telemetry.verification_status === "failed_or_blocked";
const safetyBlocked = executionFailed && !submitted && (
/no fresh valid 0x41a shade position/i.test(failureMessage)
|| /refusing (?:blind )?motion/i.test(failureMessage)
|| /thermal protection/i.test(failureMessage)
);
const deliveryState = safetyBlocked
? "blocked"
: executionFailed
? "failed"
: submitted
? "submitted"
: "not_submitted";
const deliveryLabel = safetyBlocked
? "安全阻止"
: executionFailed
? "执行失败"
: submitted
? "下发"
: "未下发";
const deliveryDetail = /no fresh valid 0x41a shade position/i.test(failureMessage)
? "未收到遮阳帘 CAN1 / 0x41A 实时位置,无法判断移动方向,系统已阻止盲动"
: failureMessage;
const transportLabel = capability === "infrared.emit"
? "红外 TCP"
: result.control_transport === "wireless_mqtt" ? "无线 CAN" : "有线 CAN";
return {
deliveryState: submitted ? "submitted" : "not_submitted",
deliveryLabel: submitted ? "下发" : "未下发",
deliveryState,
deliveryLabel,
deliveryTransport: transportLabel,
...(deliveryDetail ? { deliveryDetail } : {}),
};
};
const commands = [];
@@ -816,7 +871,7 @@
<span>
<b class="v2-can-command-channel">${escapeHtml(item.channel)}</b>
${item.parseSource ? `<b class="v2-can-command-source" data-parse-source="${escapeHtml(item.parseSource)}">${parsedCommandSourceLabel(item.parseSource)}</b>` : ""}
<b class="v2-can-command-delivery" data-delivery-state="${escapeHtml(item.deliveryState)}" title="${escapeHtml(`${item.deliveryTransport} · ${item.deliveryLabel}`)}">${escapeHtml(item.deliveryLabel)}</b>
<b class="v2-can-command-delivery" data-delivery-state="${escapeHtml(item.deliveryState)}" title="${escapeHtml([item.deliveryTransport, item.deliveryLabel, item.deliveryDetail].filter(Boolean).join(" · "))}">${escapeHtml(item.deliveryLabel)}</b>
<i class="v2-can-command-category">${escapeHtml(item.category)}</i>
</span>
<div class="v2-can-command-layer v2-can-command-semantic">
@@ -1083,20 +1138,16 @@
return operation;
}
function buildModuleSwitcher(mainPanel) {
function buildModuleSwitcher(mainPanel, modeRail) {
const switcher = make("nav", "v2-module-switcher", "");
switcher.id = "v2ModuleSwitcher";
switcher.dataset.unifiedSync = "true";
switcher.setAttribute("aria-label", "智能座舱远程控制与同步状态");
switcher.setAttribute("aria-label", "页面板块展开与收起");
switcher.innerHTML = `
<div class="v2-unified-brand">
<span class="v2-unified-brand-mark"><i data-lucide="waypoints"></i></span>
<div><h1>511工程-智能座舱</h1></div>
</div>
<div class="v2-remote-control-state"><i data-lucide="radio-tower"></i><span>网页控制链路</span><strong>已启用</strong></div>
<div class="v2-unified-live"><i></i><span>LIVE</span><b id="v2SyncClock">--:--:--</b></div>
<nav class="v2-panel-control-dock" id="v2PanelControlDock" aria-label="页面板块展开与收起"></nav>`;
mainPanel.prepend(switcher);
const modeRailBar = $(".mode-rail-bar", modeRail);
if (modeRailBar) modeRailBar.prepend(switcher);
else mainPanel.prepend(switcher);
const panelDock = $("#v2PanelControlDock", switcher);
const sidebarToggle = $("#v2SidebarToggle");
if (panelDock && sidebarToggle) panelDock.append(sidebarToggle);
@@ -1231,6 +1282,11 @@
return text;
}
function ambientPowerState() {
const value = $('[data-domain-panel="ambient_light"]')?.dataset.ambientPower;
return value === "on" || value === "off" ? value : "unknown";
}
function selectedTransportHasConnection() {
const selected = $('.vehicle-transport-options [data-control-transport][aria-pressed="true"]')
|| $('.vehicle-transport-options [data-control-transport].active');
@@ -1340,15 +1396,15 @@
rows: () => {
const [frontBrightness, rearBrightness] = splitReadout("#ambientBrightness");
const [frontColor, rearColor] = splitReadout("#ambientColorIndex");
const rawPower = normalizeDeviceReadout(readText("#ambientPower"));
const power = rawPower === "-" ? "-" : /OFF|关闭/.test(rawPower) ? "关闭" : "开启";
const powerState = ambientPowerState();
const power = powerState === "on" ? "开启" : powerState === "off" ? "关闭" : "-";
return [["开关状态", power], ["前排亮度", frontBrightness], ["前排颜色", frontColor], ["后排亮度", rearBrightness], ["后排颜色", rearColor]];
},
controls: () => {
const [frontBrightness, rearBrightness] = splitReadout("#ambientBrightness");
const [frontColor, rearColor] = splitReadout("#ambientColorIndex");
return [
selectControl("power", "开关状态", /OFF|关闭/.test(readText("#ambientPower")) ? "off" : "on", toggleOptions),
selectControl("power", "开关状态", ambientPowerState() === "off" ? "off" : "on", toggleOptions),
rangeControl("brightness", "全车亮度", frontBrightness === "-" ? rearBrightness : frontBrightness, 1, 5, 1, " 级"),
selectControl("color", "全车颜色", String(clampControlNumber(frontColor === "-" ? rearColor : frontColor, 1, 127, 1)), colorIndexOptions),
];
@@ -2141,9 +2197,7 @@
const sidebar = $(".v2-sidebar");
const sidebarFooter = $(".v2-sidebar-footer", sidebar);
const syncSidebar = make("section", "v2-sync-sidebar", `
<div class="v2-sync-sidebar-overview">
<div class="v2-sync-sidebar-heading"><h2>511工程-智能座舱</h2></div>
</div>
<div class="v2-sync-sidebar-overview"></div>
<section class="v2-sync-log" aria-labelledby="v2SyncLogTitle">
<header><div><h3 id="v2SyncLogTitle">运行日志 / 同步记录</h3></div><select id="v2LogFilter" aria-label="筛选同步日志"><option value="all">全部</option><option value="task">任务</option><option value="sync">同步</option><option value="extension">外设</option><option value="device">设备</option></select></header>
<ol id="v2SyncLogList" aria-live="polite"></ol>
@@ -2679,7 +2733,7 @@
requestHeader,
gestureDrawer,
);
buildModuleSwitcher(mainPanel);
buildModuleSwitcher(mainPanel, modeRail);
buildOutput(mainPanel, modeRail);
buildSyncControlLayer();
bindEvents();