feat(web-console): rebuild intelligent cockpit sync interface

This commit is contained in:
vee
2026-08-18 13:24:36 +08:00
parent 344f662970
commit 9b24d5c8c9
30 changed files with 4100 additions and 12594 deletions
+21 -52
View File
@@ -1553,44 +1553,8 @@ const TWIN_THEME_PALETTES = {
lampEmissive: 0x16aaa1,
lampEdge: 0x096d67,
},
admin: {
accent: 0x315eaa,
accentStrong: 0x234785,
accentSoft: 0xe1e9fa,
sceneBackground: 0xe8eef8,
floor: 0xdfe6f3,
gridStrong: 0x7190c2,
gridSoft: 0xbdc9df,
fillLight: 0xa9bfe4,
vehicleOutline: 0x315eaa,
vehicleOccluded: 0x9eafd0,
seatShell: 0x315eaa,
seatInsert: 0xc9d8f2,
seatThermal: 0x91b2e4,
seatBolster: 0x234785,
seatStructure: 0x1d2f52,
seatEdge: 0x88a9df,
seatSeam: 0xe1e9fa,
glass: 0x477bc4,
glassEmissive: 0x1f427c,
glassEdge: 0x234f91,
glassGlow: 0x86b3ff,
roofClear: 0x7299d5,
roofDark: 0x1d3c72,
lamp: 0x315eaa,
lampEmissive: 0x5688dc,
lampEdge: 0x244a86,
},
};
function currentTwinThemeRole() {
if (document.body.dataset.module === "self-extension") return "user";
return document.body.dataset.demoRole === "admin"
|| sessionStorage.getItem("cognitive-agent.demo-role") === "admin"
? "admin"
: "user";
}
function createTwinGroundTexture(THREE, palette, size = 768) {
const textureCanvas = document.createElement("canvas");
textureCanvas.width = size;
@@ -1685,11 +1649,10 @@ function applyTwinGroundTheme(twin, palette) {
if (previousTexture && previousTexture !== nextTexture) previousTexture.dispose();
}
function applyTwinVehicleTheme(systems, role = currentTwinThemeRole()) {
function applyTwinVehicleTheme(systems) {
if (!systems) return;
const themeRole = role === "admin" ? "admin" : "user";
const palette = TWIN_THEME_PALETTES[themeRole];
systems.themeRole = themeRole;
const palette = TWIN_THEME_PALETTES.user;
systems.themeRole = "user";
systems.themePalette = palette;
systems.colors.roofClear.setHex(palette.roofClear);
systems.colors.roofDark.setHex(palette.roofDark);
@@ -1774,13 +1737,10 @@ function applyTwinSeatTheme(model, palette) {
});
}
function applyTwinSceneTheme(twin, role = currentTwinThemeRole()) {
function applyTwinSceneTheme(twin) {
if (!twin) return;
const themeRole = document.body.dataset.module === "self-extension"
? "user"
: role === "admin" ? "admin" : "user";
const palette = TWIN_THEME_PALETTES[themeRole];
applyTwinVehicleTheme(twin.vehicleSystems, themeRole);
const palette = TWIN_THEME_PALETTES.user;
applyTwinVehicleTheme(twin.vehicleSystems);
twin.scene.background.setHex(palette.sceneBackground);
if (twin.scene.fog?.color) twin.scene.fog.color.setHex(palette.sceneBackground);
applyTwinGroundTheme(twin, palette);
@@ -1797,11 +1757,11 @@ function applyTwinSceneTheme(twin, role = currentTwinThemeRole()) {
}
}));
// Controllable glass and lamp entities use stronger semantic variants from
// the same role palette after the neutral vehicle outline pass above.
applyTwinVehicleTheme(twin.vehicleSystems, themeRole);
// the same palette after the neutral vehicle outline pass above.
applyTwinVehicleTheme(twin.vehicleSystems);
const canvas = twin.renderer?.domElement;
if (canvas) {
canvas.dataset.themeRole = themeRole;
canvas.dataset.themeRole = "user";
canvas.dataset.themeAccent = `#${palette.accent.toString(16).padStart(6, "0")}`;
}
}
@@ -3942,9 +3902,6 @@ function initSeatTwin() {
pointer: { x: 0, y: 0 },
};
applyTwinSceneTheme(state.seatTwin);
window.addEventListener("cognitive-agent:demo-role-change", (event) => {
applyTwinSceneTheme(state.seatTwin, event.detail?.role);
});
window.addEventListener("cognitive-agent:module-change", () => {
applyTwinSceneTheme(state.seatTwin);
});
@@ -6495,6 +6452,7 @@ async function submitRequest(event) {
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
utterance,
client_type: "web_console",
provider: state.provider,
conversation_id: state.conversationId,
vehicle_id: state.vehicleId || state.runtime?.default_vehicle_id,
@@ -6657,6 +6615,17 @@ window.CognitiveAgentConsole = {
getResult() {
return state.result;
},
applySyncedResult(result, { utterance = "" } = {}) {
if (!result || typeof result !== "object") return false;
if (result.conversation_id) {
state.conversationId = String(result.conversation_id);
sessionStorage.setItem("cognitive-agent.conversation-id", state.conversationId);
}
const input = $("#utterance");
if (input && utterance && document.activeElement !== input) input.value = String(utterance);
renderResult(result);
return true;
},
notify(message) {
showToast(String(message));
},