25 lines
815 B
TypeScript
25 lines
815 B
TypeScript
import { ApiClient } from "../client/ApiClient";
|
|
import type { Endpoint } from "../client/endpoints";
|
|
import type { ApiResponse } from "../client/types";
|
|
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
|
|
|
export class AuthService {
|
|
private static _I: AuthService | null = null;
|
|
public static get I(): AuthService {
|
|
if (!AuthService._I) AuthService._I = new AuthService();
|
|
return AuthService._I;
|
|
}
|
|
private constructor(private api = ApiClient.I) {}
|
|
|
|
// 登录
|
|
public async login(req: proto.ProtoMsg.ILoginReq): Promise<ApiResponse<proto.ProtoMsg.ILoginRsp>> {
|
|
let epData: Endpoint<proto.ProtoMsg.ILoginReq, proto.ProtoMsg.ILoginRsp> = {
|
|
path: "login",
|
|
method: "POST",
|
|
codec: "json",
|
|
needsAuth: false
|
|
};
|
|
return this.api.call(epData, req);
|
|
}
|
|
}
|