feat: 添加后端服务地址自定义配置功能
- 在设置面板添加后端服务地址配置项 - 支持保存、加载和重置自定义配置 - 配置持久化存储,重启后保留 - 添加 SSE 请求日志用于验证配置
This commit is contained in:
@ -29,6 +29,9 @@ export interface IccoderConfig {
|
||||
serviceTier: ServiceTier;
|
||||
}
|
||||
|
||||
/** 自定义配置缓存 */
|
||||
let customConfig: Partial<IccoderConfig> | null = null;
|
||||
|
||||
/** 环境配置 */
|
||||
const ENV_CONFIG: Record<Environment, IccoderConfig> = {
|
||||
/** 本地开发环境 - 通过 Gateway 路由 */
|
||||
@ -38,7 +41,7 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
|
||||
loginUrl: "http://localhost/login",
|
||||
timeout: 300000,
|
||||
userId: "default-user",
|
||||
serviceTier: "max", // 默认使用 max
|
||||
serviceTier: "max",
|
||||
},
|
||||
/** 测试服务器环境 - 通过 Gateway 路由 */
|
||||
test: {
|
||||
@ -60,6 +63,13 @@ const ENV_CONFIG: Record<Environment, IccoderConfig> = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置自定义配置
|
||||
*/
|
||||
export function setCustomConfig(config: Partial<IccoderConfig>) {
|
||||
customConfig = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前环境
|
||||
*/
|
||||
@ -71,7 +81,14 @@ export function getCurrentEnv(): Environment {
|
||||
* 获取配置项
|
||||
*/
|
||||
export function getConfig(): IccoderConfig {
|
||||
return { ...ENV_CONFIG[CURRENT_ENV] };
|
||||
const baseConfig = { ...ENV_CONFIG[CURRENT_ENV] };
|
||||
|
||||
// 合并自定义配置(空字符串表示使用默认)
|
||||
if (customConfig?.backendUrl && customConfig.backendUrl !== '') {
|
||||
baseConfig.backendUrl = customConfig.backendUrl;
|
||||
}
|
||||
|
||||
return baseConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user