协议修改
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { ApiResponse } from "../client/types";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import type { ICommonService } from "./ICommonService";
|
||||
import { HttpCommonService } from "./HttpCommonService";
|
||||
import { MockCommonService } from "./MockCommonService";
|
||||
|
||||
// 模拟开关
|
||||
const USE_MOCK = true;
|
||||
|
||||
export class CommonService implements ICommonService {
|
||||
private static _I: CommonService | null = null;
|
||||
public static get I(): CommonService {
|
||||
if (!CommonService._I) CommonService._I = new CommonService();
|
||||
return CommonService._I;
|
||||
}
|
||||
|
||||
private impl: ICommonService;
|
||||
|
||||
private constructor() {
|
||||
this.impl = USE_MOCK ? new MockCommonService() : new HttpCommonService();
|
||||
}
|
||||
|
||||
/** 运行期切换 */
|
||||
public switch(useMock: boolean) {
|
||||
this.impl = useMock ? new MockCommonService() : new HttpCommonService();
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
public async reqResConfig(req: proto.cs.ICSGetResConfigReq): Promise<ApiResponse<proto.cs.ICSGetResConfigRes>> {
|
||||
return this.impl.reqResConfig(req);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user