Files
18xchat/assets/Scripts/chat18x/network/services/ThemeService.ts
T

33 lines
1021 B
TypeScript
Raw Normal View History

2025-08-27 17:33:51 +08:00
import type { ApiResponse } from "../client/types";
2025-08-29 16:39:41 +08:00
import proto from "db://assets/Scripts/proto/proto.pb.js";
import type { IThemeService } from "./IThemeService";
import { HttpThemeService } from "./HttpThemeService";
import { MockThemeService } from "./MockThemeService";
2025-08-27 17:33:51 +08:00
2025-08-29 16:39:41 +08:00
// 模拟开关
2025-09-09 10:30:46 +08:00
const USE_MOCK = false;
2025-08-29 16:39:41 +08:00
export class ThemeService implements IThemeService {
2025-08-27 17:33:51 +08:00
private static _I: ThemeService | null = null;
public static get I(): ThemeService {
if (!ThemeService._I) ThemeService._I = new ThemeService();
return ThemeService._I;
}
2025-08-29 16:39:41 +08:00
private impl: IThemeService;
private constructor() {
this.impl = USE_MOCK ? new MockThemeService() : new HttpThemeService();
}
/** 运行期切换 */
public switch(useMock: boolean) {
this.impl = useMock ? new MockThemeService() : new HttpThemeService();
}
2025-08-27 17:33:51 +08:00
// 获取大厅分类列表
public async reqHallTheme(req: proto.cs.ICSHallThemeReq): Promise<ApiResponse<proto.cs.ICSHallThemeRes>> {
2025-08-29 16:39:41 +08:00
return this.impl.reqHallTheme(req);
2025-08-27 17:33:51 +08:00
}
}