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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user