diff --git a/examples/client-mock/frontend/src/models/client.ts b/examples/client-mock/frontend/src/models/client.ts index 559f8de..61ac571 100644 --- a/examples/client-mock/frontend/src/models/client.ts +++ b/examples/client-mock/frontend/src/models/client.ts @@ -10,7 +10,7 @@ export const client = new HttpClient(serviceProto, { // Client Mock client.flows.preCallApiFlow.push(async v => { - // 有对应的 MockAPI 则 Mock,否则请求真实后端 + // Mock if exists, otherwise send request to server let mockApi = mockApis[v.apiName]; if (mockApi) { client.logger?.log('[MockReq]', v.apiName, v.req); diff --git a/examples/client-mock/frontend/src/models/mockApis.ts b/examples/client-mock/frontend/src/models/mockApis.ts index e4a829b..12f3276 100644 --- a/examples/client-mock/frontend/src/models/mockApis.ts +++ b/examples/client-mock/frontend/src/models/mockApis.ts @@ -1,15 +1,15 @@ -// 模拟后端,Mock API 请求 +// Mock API request, simulate server import { ApiReturn } from "tsrpc-browser"; import { ServiceType } from "../shared/protocols/serviceProto"; -// 临时存储数据 +// Storage test data for mock const data: { content: string, time: Date }[] = []; -// { 接口名: (req: 请求) => 响应 } +// { apiName: (req: ReqXXX) => ResXXX } export const mockApis: { [K in keyof ServiceType['api']]?: (req: ServiceType['api'][K]['req']) => ApiReturn | Promise> } = { @@ -23,9 +23,9 @@ export const mockApis: { }, GetData: async req => { - // 模拟 1 秒延时 + // simulate latency await new Promise(rs => { - setTimeout(rs, 1000); + setTimeout(rs, 500); }) return {