Files
18xchat/assets/Scripts/chat18x/network/services/CommonService.ts
T
xionglijia e3c77d354e Squashed commit of the following:
commit 8d3548006d
Author: chen wei bo <1025839511@qq.com>
Date:   Fri Sep 12 16:00:29 2025 +0800

    更新语言表

commit 0d66f72c61
Author: chen wei bo <1025839511@qq.com>
Date:   Fri Sep 12 15:19:32 2025 +0800

    支付相关

commit 8372d3b489
Author: chen wei bo <1025839511@qq.com>
Date:   Fri Sep 12 11:29:11 2025 +0800

    登录之后获取全局数据
2025-09-15 11:57:21 +08:00

33 lines
1.0 KiB
TypeScript

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 = false;
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);
}
}