增加环境配置

This commit is contained in:
chen wei bo
2025-08-15 14:30:09 +08:00
parent f928e7fabe
commit e64327bf09
15 changed files with 269 additions and 16 deletions
@@ -1,4 +1,3 @@
import { HttpManager, HttpMethod } from "../transport/HttpManager";
import { JsonCodec } from "../codec/JsonCodec";
import { ProtoCodec } from "../codec/ProtoCodec";
@@ -6,6 +5,7 @@ import type { Endpoint } from "./endpoints";
import { ApiCode, type ApiResponse } from "./types";
import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManager";
import { LoginData } from "db://assets/Scripts/chat18x/data/LoginData";
import { AppConfig } from "db://assets/Scripts/chat18x/config/env/appConfig";
export class ApiClient {
private static _I: ApiClient | null = null;
@@ -14,8 +14,7 @@ export class ApiClient {
return ApiClient._I;
}
private constructor(private http = HttpManager.I) {}
// TODO
private get baseUrl() { return "http://43.139.27.67:8081" }
private get baseUrl() { return AppConfig.I.getHttpBase() }
private get token() { return DataManager.I.getDataById<LoginData>(DataId.Login).getToken();}
public async call<Req, Res>(ep: Endpoint<Req, Res>, req: Req): Promise<ApiResponse<Res>> {
@@ -6,9 +6,8 @@ export type CodecKind = "json" | "proto";
export interface Endpoint<Req, Res> {
path: string;
method: HttpMethod;
codec: CodecKind;
reqType?: Type; // codec=proto 时必填
resType?: Type; // codec=proto 时必填
needsAuth?: boolean;
lock?: boolean;
codec: CodecKind; // 编解码类型,"json", "proto"
reqType?: Type; // codec=proto 时必填
resType?: Type; // codec=proto 时必填
needsAuth?: boolean; // 是否需要token
}