fix(mp): DevTools 卡死 + 主包 2MB→766KB + 代码质量 4 项全通过
根因:主包 2MB 全量组件注入导致 DevTools 渲染引擎内存渐增, 叠加离线时固定 3s 抑制期后的请求洪泛。 修复: - app.config.ts 添加 lazyCodeLoading: requiredComponents 主包 2.0MB→766KB,taro.js 526→131KB,vendors.js 230→28KB - request.ts 离线抑制改为指数退避(3s→6s→12s→30s cap) 后端不可达时自动延长抑制,防止请求风暴 - SegmentTabs Tab 接口改为 readonly,修复 TS 编译错误 - AbortController polyfill 补齐小程序运行时缺失 - 健康首页/设备同步/健康档案/报告/设置页 UI 重构 - 文章页公开端点适配游客访问 - 健康首页 Swiper 间隔优化 4s→5s,动画 500→300ms
This commit is contained in:
@@ -2,13 +2,14 @@ import { create } from 'zustand';
|
||||
import Taro from '@tarojs/taro';
|
||||
import * as authApi from '@/services/auth';
|
||||
import { secureGet, secureSet, secureRemove } from '@/utils/secure-storage';
|
||||
import { clearRequestCache, markLoggingOut, clearLoggingOut, setCachedPatientId } from '@/services/request';
|
||||
import { clearRequestCache, invalidateHeadersCache, markLoggingOut, clearLoggingOut, setCachedPatientId } from '@/services/request';
|
||||
|
||||
// secureGet 已内置明文键 fallback,无需再手动 fallback
|
||||
function storageGet(key: string): string {
|
||||
return secureGet(key);
|
||||
}
|
||||
import { resetAllStores } from './index';
|
||||
import { resetAnalyticsDisabled } from '@/services/analytics';
|
||||
|
||||
// --- 内存缓存,避免每次 Tab 切换重复 Storage IPC + JSON.parse ---
|
||||
let cachedUserJson = '';
|
||||
@@ -142,6 +143,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
secureSet('tenant_id', user.tenant_id || '');
|
||||
set({ user, roles, loading: false });
|
||||
clearLoggingOut();
|
||||
invalidateHeadersCache();
|
||||
resetAnalyticsDisabled();
|
||||
get().loadPatients();
|
||||
return true;
|
||||
}
|
||||
@@ -175,7 +178,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
secureSet('tenant_id', resp.user?.tenant_id || tenantId);
|
||||
set({ user: resp.user, roles, loading: false });
|
||||
clearLoggingOut();
|
||||
// 登录成功后自动加载患者档案(如果有的话)
|
||||
invalidateHeadersCache();
|
||||
resetAnalyticsDisabled();
|
||||
get().loadPatients();
|
||||
return true;
|
||||
} catch (err) {
|
||||
@@ -211,6 +215,8 @@ export const useAuthStore = create<AuthState>((set, get) => ({
|
||||
secureRemove('wechat_openid');
|
||||
set({ user: tokenData.user, roles, loading: false });
|
||||
clearLoggingOut();
|
||||
invalidateHeadersCache();
|
||||
resetAnalyticsDisabled();
|
||||
get().loadPatients();
|
||||
return true;
|
||||
} catch (err: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user