小程序端此前**没有任何类型门禁**:tsc 不检查 .vue,而 9 个页面全是 .vue, npm run build:mp-weixin 只验语法不验类型。接入 vue-tsc 后立刻抓到 17 个错误, 其中两个是真 BUG: 1. me/index.vue:写 const user = authStore.user 之后又写 user.value —— Pinia setup store 对外已把 ref 解包,user.value 恒为 undefined ⇒ **头像上传成功后写回 store 的那行是空操作**(要等冷启动才显示新头像); 且直接取值是快照、丢掉响应式。改为 computed(() => authStore.user),模板无需改动。 2. api/index.ts:CompartmentDetail 漏了后端确实会返回的 temp (routes/h5.rs 的 COMPARTMENT_REALTIME_FIELDS 第 6 项,有单测守门) ⇒ compartment-detail 页读 data.temp 报 TS2339。已按后端契约补上。 其余 12 处是宿主全局 wx 未声明(@dcloudio/types 只声明跨端 uni), 在 env.d.ts 里**只声明实际用到的两个 API**(刻意不写 [k:string]:any, 否则等于把这一层检查关掉)。 顺带清理: - 删除死页面 pages/devices/index.vue(不在 pages.json、无任何跳转引用,grep 确认); - 删除仓控板「在线/离线」徽标:cabin_boards.status **全后端没有任何写入方** (生产库实测取值只有 0),该徽标恒定显示"离线",属对用户的谎报; 协议层面也没有"仓控板在线"这个概念(TCP 长连接的是柜控板,按 IMEI 标识)。 按「柜的就显示到柜子」+「不显示推不出来的状态」去掉,并在类型上加禁止说明。 已按仓库铁律自证门禁能失败:植入 export const probe: number = 'x' → exit 2;撤销 → exit 0。
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some Oxlint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Oxc
- @vitejs/plugin-react-swc uses SWC
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the Oxlint configuration
If you are developing a production application, we recommend enabling type-aware lint rules by installing oxlint-tsgolint and editing .oxlintrc.json:
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"options": {
"typeAware": true
},
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}
See the Oxlint rules documentation for the full list of rules and categories.