协议修改
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { ApiResponse } from "../client/types";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import type { ICommonService } from "./ICommonService";
|
||||
import { ConfigManager, ConfigId } from "../../manager/ConfigManager";
|
||||
import { GlobalConfig } from "../../config/GlobalConfig";
|
||||
|
||||
export class MockCommonService implements ICommonService {
|
||||
private delay(ms = 160) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||||
private ok<T>(data: T): ApiResponse<T> {
|
||||
return ({ code: proto.cs.EnmRetCode.SUCCESS, data } as unknown) as ApiResponse<T>;
|
||||
}
|
||||
|
||||
// 获取配置
|
||||
async reqResConfig(req: proto.cs.ICSGetResConfigReq): Promise<ApiResponse<proto.cs.ICSGetResConfigRes>> {
|
||||
// 延时
|
||||
await this.delay();
|
||||
|
||||
let data = "";
|
||||
const resName = req.resName;
|
||||
if (resName === "global_config") {
|
||||
// 全局配置
|
||||
data = this.getGlobalConfig();
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
const res: proto.cs.ICSGetResConfigRes = { data };
|
||||
return this.ok(res);
|
||||
}
|
||||
|
||||
// 全局配置
|
||||
private getGlobalConfig(): string {
|
||||
|
||||
const configData = ConfigManager.I.getDataById<GlobalConfig>(ConfigId.Global);
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user