访客模式: - 未登录用户可见首页(轮播图+健康资讯+登录引导)和"我的"页面 - 健康和消息 tab 显示 GuestGuard 登录拦截 - 登录页增加"暂不登录,先看看"跳过入口 - 401 拦截器增加 hasToken 检查,避免访客被重定向到登录页 - 退出登录后 reLaunch 到首页而非登录页 长辈模式: - 新增 stores/ui.ts 管理显示模式(标准/长辈) - 长辈模式放大字体 ×1.3、间距 ×1.2、按钮加大 - "我的 → 账号 → 长辈模式"切换页 - 设置持久化到 Storage 修复: - Health/Messages 页面 Hooks 顺序违规(条件 return 在 hooks 之间) 导致访客模式下页面白屏,所有 hooks 移到条件判断之前 工程: - scripts/mpsync.sh/ps1 自动清理残留 DevTools 进程 - project.config.json 默认关闭域名校验
31 lines
889 B
TypeScript
31 lines
889 B
TypeScript
import { useEffect, PropsWithChildren } from 'react';
|
|
import Taro from '@tarojs/taro';
|
|
import ErrorBoundary from './components/ErrorBoundary';
|
|
import { flushEvents } from './services/analytics';
|
|
import { useAuthStore } from './stores/auth';
|
|
import { useUIStore } from './stores/ui';
|
|
import './app.scss';
|
|
|
|
function App({ children }: PropsWithChildren<Record<string, unknown>>) {
|
|
const restoreAuth = useAuthStore((s) => s.restore);
|
|
const restoreUI = useUIStore((s) => s.restore);
|
|
|
|
useEffect(() => {
|
|
restoreAuth();
|
|
restoreUI();
|
|
const timer = setInterval(() => {
|
|
flushEvents();
|
|
}, 30000);
|
|
const onHide = () => { flushEvents(); };
|
|
Taro.eventCenter.on('appHide', onHide);
|
|
return () => {
|
|
clearInterval(timer);
|
|
Taro.eventCenter.off('appHide', onHide);
|
|
};
|
|
}, []);
|
|
|
|
return <ErrorBoundary>{children}</ErrorBoundary>;
|
|
}
|
|
|
|
export default App;
|