feat(大屏): 设备绑定流 — 永久设备ID+待绑定页(连接码)+MQTT绑定确认

- config.getDeviceId:首启生成并持久化永久设备ID,作为 MQTT client_id(稳定可控)。
- tenant.js 改设备绑定:registerDevice/requestBindCode/applyBound(存 token+tenant)/isDeviceBound。
- mqtt.js:client_id=device_id;订阅 bind/<dev>(未绑定确认)+command/tick(租户)。
- main.jsx:未绑定→BindScreen(注册+取8位码+监听绑定频道, 绑定后 reload);已绑定→App。
- BindScreen:展示 8 位连接码+设备ID+等待园区端绑定。yarn build 通过。
This commit is contained in:
Pine
2026-08-24 20:14:15 +08:00
parent 225c22ad62
commit 4257db2e26
5 changed files with 101 additions and 36 deletions
+4 -4
View File
@@ -1,8 +1,8 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import TenantLogin from "./components/TenantLogin";
import { isAuthed } from "./utils/tenant";
import BindScreen from "./components/BindScreen.jsx";
import { isDeviceBound } from "./utils/tenant";
import ErrorBoundary from "./components/ErrorBoundary";
import { ThemeProvider } from "@appica/ui-react/providers/theme-provider";
import { getApiBase } from "./config";
@@ -82,8 +82,8 @@ bootstrapRuntimeConfig().then(() => {
<React.StrictMode>
<ErrorBoundary>
<ThemeProvider>
{/* 多租户:未登录大屏 → 登录页登录(帐密 → 长效 tenant token,localStorage 持久) */}
{isAuthed() ? <App /> : <TenantLogin />}
{/* 多租户:未绑定大屏 → 待绑定页(连接码+二维码);已绑定 → 大屏应用 */}
{isDeviceBound() ? <App /> : <BindScreen />}
</ThemeProvider>
</ErrorBoundary>
</React.StrictMode>,