refactor(mp): request.ts 模块级状态收编 + AbortSignal + Analytics 受控

- 提取 ConcurrencyLimiter 类(并发限制 8,可 reset)
- 提取 ResponseCache 类(GET 缓存 + 去重 + patientId 绑定)
- 新增 resetForTesting() 测试隔离函数
- api.get/post/put/delete 支持 AbortSignal 请求取消
- app.tsx Analytics 定时器改为 useDidShow/useDidHide 控制后台暂停
- 测试文件接入 resetForTesting()

构建通过,测试 74/75(1 个预存失败)。
This commit is contained in:
iven
2026-05-15 06:58:37 +08:00
parent 1fd2c7a533
commit 6d151bbfb1
4 changed files with 175 additions and 85 deletions

View File

@@ -23,12 +23,12 @@ vi.mock('@/utils/secure-storage', () => ({
}));
import Taro from '@tarojs/taro';
import { api, clearRequestCache } from '@/services/request';
import { api, clearRequestCache, resetForTesting } from '@/services/request';
describe('request module', () => {
beforeEach(() => {
vi.clearAllMocks();
clearRequestCache();
resetForTesting();
});
describe('api.get', () => {