示例工程 22-theming-and-native-appearance
22-theming-and-native-appearance/demo-01-theme-resolve/README.md
# demo-01-theme-resolve
主题来源的纯逻辑:`system` 跟随系统,`light` / `dark` 覆盖;损坏的存储回退到 `system`。
## 运行
```bash
pnpm --filter @tutorial/22-theming-and-native-appearance-demo-01-theme-resolve start
```
## 验证
```bash
pnpm --filter @tutorial/22-theming-and-native-appearance-demo-01-theme-resolve smoke
# {"evt":"smoke","ok":true,"cases":[true,false,true,false],"parsed":["dark","system","system","system"]}
```
## 说明
- 判断颜色只看 `shouldUseDarkColors`,不要在组件里重复写 `source === "dark"`。
- 存储解析必须校验枚举;`{ source: "blue" }` 与字符串都应回退。
- 三个来源循环用于「按一次切换」按钮,不用于持久化判断。
## 已知限制
- 不监听系统变化;真实应用由 `nativeTheme.updated` 驱动。