修改:协议和配置表

This commit is contained in:
chen wei bo
2025-09-08 15:11:11 +08:00
parent 5821bc17ae
commit 826e52d019
47 changed files with 12826 additions and 4127 deletions
@@ -4,10 +4,8 @@ import type { IAuthService } from "./IAuthService";
export class MockAuthService implements IAuthService {
private delay(ms = 180) { return new Promise<void>(r => setTimeout(r, ms)); }
// 项目里 ApiResponse 结构若固定(code/message 等),把 ok()/err() 调整为你的真实结构即可
private ok<T>(data: T): ApiResponse<T> {
return ({ ok: true, data } as unknown) as ApiResponse<T>;
return ({ code: proto.cs.EnmRetCode.SUCCESS, data } as unknown) as ApiResponse<T>;
}
// private err<T = unknown>(message = "mock login error"): ApiResponse<T> {
// return ({ ok: false, error: { message } } as unknown) as ApiResponse<T>;
@@ -15,18 +13,29 @@ export class MockAuthService implements IAuthService {
// 登录
async login(req: proto.cs.ICSLoginReq): Promise<ApiResponse<proto.cs.ICSLoginRes>> {
// 延时
await this.delay(150);
const name = req?.platType === "guest" ? `guest_${(req?.userId ?? "uid").toString().slice(-6)}` : "tester";
// 注意:protobufjs 会把 int64 表达为 number/Long。这里用「秒」级时间戳更常见
const isGuest = req?.platType === "guest";
const userId = req?.userId ?? "uid";
const name = isGuest ? `guest_${userId.toString().slice(-6)}` : "tester";
// 过期时间(秒级时间戳,7天后过期)
const expireSeconds = Math.floor(Date.now() / 1000) + 7 * 24 * 3600;
// 你的生成器通常会把 refresh_token 转成 refreshTokencamelCase
// 模拟用户ID
const accId = Math.floor(Math.random() * 1000000);
// 模拟 CDN 前缀
const cdn = "https://cdn.mockserver.com/";
const res: proto.cs.ICSLoginRes = {
name,
token: `mock_token_${Date.now()}`,
refreshToken: `mock_refresh_${Date.now()}`,
expire: expireSeconds,
accId,
cdn,
};
return this.ok(res);