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 = true; 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> { return this.impl.reqHallTheme(req); } }