优化前端,优化前端指令,优化自定义控制

This commit is contained in:
minghanchen
2026-08-24 09:40:16 +08:00
parent fff7657fea
commit 8d05815773
130 changed files with 5543 additions and 2206 deletions
+40 -2
View File
@@ -359,6 +359,9 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
if path.startswith("/api/self-repair/"):
self._handle_self_repair_post(path)
return
if path.startswith("/api/mode-profiles/"):
self._handle_mode_profile_post(path)
return
if path != "/api/requests":
self._json({"error": "not_found"}, HTTPStatus.NOT_FOUND)
return
@@ -519,6 +522,35 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
HTTPStatus.BAD_REQUEST,
)
def _handle_mode_profile_post(self, path: str) -> None:
mode_id = path.removeprefix("/api/mode-profiles/").strip()
if not mode_id:
self._json(
{"error": "invalid_request", "message": "模式编号不能为空。"},
HTTPStatus.BAD_REQUEST,
)
return
try:
payload = self._read_json_body(max_bytes=16 * 1024)
result = self.service.save_mode_profile_card(
mode_id,
str(payload.get("name", "")),
str(payload.get("instruction", "")),
str(payload.get("source_request_id", "")),
str(payload.get("vehicle_id", "")) or None,
)
self._json(result, HTTPStatus.OK)
except KeyError:
self._json(
{"error": "not_found", "message": "未找到需要编辑的模式卡片。"},
HTTPStatus.NOT_FOUND,
)
except (ValueError, json.JSONDecodeError) as exc:
self._json(
{"error": "invalid_request", "message": str(exc)},
HTTPStatus.BAD_REQUEST,
)
def _handle_extension_post(self, path: str) -> None:
action_map = {
"/api/extension/gscu/learn": "learn",
@@ -1234,12 +1266,18 @@ def main() -> None:
)
else:
print(f"Cabin orchestration demo: http://{args.host}:{args.port}", flush=True)
hardware = SeatDemoHandler.service.hardware_settings
hardware_execution_ready = any(
(
SeatDemoHandler.service.hardware_settings.configured,
SeatDemoHandler.service.vehicle_can_settings.configured,
SeatDemoHandler.service.vehicle_mqtt_settings.configured,
)
)
print(
"Execution modes: dry_run + simulated_hardware "
f"({'enabled' if SeatDemoHandler.service.simulated_hardware_enabled else 'locked'}) "
"+ hardware "
f"({'configured' if hardware.configured else 'locked'})",
f"({'configured' if hardware_execution_ready else 'locked'})",
flush=True,
)
try: