/** * 配置管理 * 后端地址已预配置,用户无需手动设置 */ import * as vscode from "vscode"; /** 配置项接口 */ export interface IccoderConfig { /** 后端服务地址 */ backendUrl: string; /** 请求超时时间(毫秒) */ timeout: number; /** 用户ID(临时使用,后续对接认证) */ userId: string; } /** 默认配置(预配置,不暴露给用户) */ const DEFAULT_CONFIG: IccoderConfig = { backendUrl: "http://192.168.1.108:2233", timeout: 60000, userId: "default-user", }; /** * 获取配置项 * 直接返回预配置的值,用户无需手动配置 */ export function getConfig(): IccoderConfig { return { ...DEFAULT_CONFIG }; } /** * 获取后端 API 地址 */ export function getApiUrl(path: string): string { const { backendUrl } = getConfig(); // 确保 URL 格式正确 const baseUrl = backendUrl.endsWith("/") ? backendUrl.slice(0, -1) : backendUrl; const apiPath = path.startsWith("/") ? path : `/${path}`; return `${baseUrl}${apiPath}`; }