33 lines
1021 B
TypeScript
33 lines
1021 B
TypeScript
import type { ApiResponse } from "../client/types";
|
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|
import type { IThemeService } from "./IThemeService";
|
|
import { HttpThemeService } from "./HttpThemeService";
|
|
import { MockThemeService } from "./MockThemeService";
|
|
|
|
// 模拟开关
|
|
const USE_MOCK = false;
|
|
|
|
export class ThemeService implements IThemeService {
|
|
private static _I: ThemeService | null = null;
|
|
public static get I(): ThemeService {
|
|
if (!ThemeService._I) ThemeService._I = new ThemeService();
|
|
return ThemeService._I;
|
|
}
|
|
|
|
private impl: IThemeService;
|
|
|
|
private constructor() {
|
|
this.impl = USE_MOCK ? new MockThemeService() : new HttpThemeService();
|
|
}
|
|
|
|
/** 运行期切换 */
|
|
public switch(useMock: boolean) {
|
|
this.impl = useMock ? new MockThemeService() : new HttpThemeService();
|
|
}
|
|
|
|
// 获取大厅分类列表
|
|
public async reqHallTheme(req: proto.cs.ICSHallThemeReq): Promise<ApiResponse<proto.cs.ICSHallThemeRes>> {
|
|
return this.impl.reqHallTheme(req);
|
|
}
|
|
}
|