english rem

This commit is contained in:
King Wang 2021-06-30 00:14:55 +08:00
parent a5779bd4d0
commit c3aa1f918e
2 changed files with 6 additions and 6 deletions

View File

@ -10,7 +10,7 @@ export const client = new HttpClient(serviceProto, {
// Client Mock // Client Mock
client.flows.preCallApiFlow.push(async v => { client.flows.preCallApiFlow.push(async v => {
// 有对应的 MockAPI 则 Mock否则请求真实后端 // Mock if exists, otherwise send request to server
let mockApi = mockApis[v.apiName]; let mockApi = mockApis[v.apiName];
if (mockApi) { if (mockApi) {
client.logger?.log('[MockReq]', v.apiName, v.req); client.logger?.log('[MockReq]', v.apiName, v.req);

View File

@ -1,15 +1,15 @@
// 模拟后端Mock API 请求 // Mock API request, simulate server
import { ApiReturn } from "tsrpc-browser"; import { ApiReturn } from "tsrpc-browser";
import { ServiceType } from "../shared/protocols/serviceProto"; import { ServiceType } from "../shared/protocols/serviceProto";
// 临时存储数据 // Storage test data for mock
const data: { const data: {
content: string, content: string,
time: Date time: Date
}[] = []; }[] = [];
// { 接口名: (req: 请求) => 响应 } // { apiName: (req: ReqXXX) => ResXXX }
export const mockApis: { export const mockApis: {
[K in keyof ServiceType['api']]?: (req: ServiceType['api'][K]['req']) => ApiReturn<ServiceType['api'][K]['res']> | Promise<ApiReturn<ServiceType['api'][K]['res']>> [K in keyof ServiceType['api']]?: (req: ServiceType['api'][K]['req']) => ApiReturn<ServiceType['api'][K]['res']> | Promise<ApiReturn<ServiceType['api'][K]['res']>>
} = { } = {
@ -23,9 +23,9 @@ export const mockApis: {
}, },
GetData: async req => { GetData: async req => {
// 模拟 1 秒延时 // simulate latency
await new Promise(rs => { await new Promise(rs => {
setTimeout(rs, 1000); setTimeout(rs, 500);
}) })
return { return {