23 lines
898 B
TypeScript
23 lines
898 B
TypeScript
import type { ApiResponse } from "../client/types";
|
|||
|
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||
|
|
import type { IChatService } from "./IChatService";
|
||
|
|
|
||
|
|
export class MockChatService implements IChatService {
|
||
|
|
private delay(ms = 160) { return new Promise<void>(r => setTimeout(r, ms)); }
|
||
|
|
|
||
|
|
// 按你们项目的 ApiResponse 结构调整这里即可
|
||
|
|
private ok<T>(data: T): ApiResponse<T> {
|
||
|
|
return ({ ok: true, data } as unknown) as ApiResponse<T>;
|
||
|
|
}
|
||
|
|
// private err<T = unknown>(message = "mock buyChat error"): ApiResponse<T> {
|
||
|
|
// return ({ ok: false, error: { message } } as unknown) as ApiResponse<T>;
|
||
|
|
// }
|
||
|
|
|
||
|
|
async reqBuyChat(_req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>> {
|
||
|
|
await this.delay();
|
||
|
|
// CSBuyChatRes 在 proto 中为空消息,这里返回 {}
|
||
|
|
const res: proto.cs.ICSBuyChatRes = {};
|
||
|
|
return this.ok(res);
|
||
|
|
}
|
||
|
|
}
|