fix:修复所有的包导入错误问题

This commit is contained in:
2026-06-09 18:30:49 +08:00
parent 6e64ed35f4
commit 016bc6fd2c
13 changed files with 69 additions and 44 deletions
+69
View File
@@ -0,0 +1,69 @@
/**
* API 配置管理
*
* 通过环境变量配置后端服务地址与超时时间。
* 原始 Dart: lib/core/net/service_manager.dart
*/
export type AppEnv = "development" | "test" | "production";
export interface ApiConfig {
/** 后端 API 基础 URL(含协议) */
baseUrl: string;
/** WebSocket 基础 URL */
wsUrl: string;
/** 连接超时(ms */
connectTimeout: number;
/** 接收超时(ms */
receiveTimeout: number;
/** 发送超时(ms */
sendTimeout: number;
}
/**
* 超时常量
*/
export class TimeoutConstants {
private constructor() {}
static readonly shortTimeout = 30000;
static readonly longTimeout = 60000;
}
/**
* 解析当前环境
*/
export function getAppEnv(): AppEnv {
const env = process.env.NEXT_PUBLIC_APP_ENV;
if (env === "production" || env === "test") return env;
return "development";
}
/**
* 获取当前 API 配置
*/
export function getApiConfig(): ApiConfig {
const baseUrl =
process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://172.16.48.49:3002";
const wsUrl =
process.env.NEXT_PUBLIC_WS_BASE_URL ?? "ws://172.16.48.49:3002";
const connectTimeout = Number.parseInt(
process.env.NEXT_PUBLIC_API_CONNECT_TIMEOUT ?? "30000",
10
);
const receiveTimeout = Number.parseInt(
process.env.NEXT_PUBLIC_API_RECEIVE_TIMEOUT ?? "60000",
10
);
const sendTimeout = Number.parseInt(
process.env.NEXT_PUBLIC_API_SEND_TIMEOUT ?? "30000",
10
);
return {
baseUrl,
wsUrl,
connectTimeout,
receiveTimeout,
sendTimeout,
};
}