refactor: 移除 VSCode 设置中的配置项,使用预配置的默认值

This commit is contained in:
Roe-xin
2025-12-31 10:42:53 +08:00
parent b662d25c9c
commit ef2159f1bd
2 changed files with 5 additions and 30 deletions

View File

@ -70,27 +70,7 @@
"id": "iccoder",
"label": "IC Coder"
}
],
"configuration": {
"title": "IC Coder",
"properties": {
"icCoder.backendUrl": {
"type": "string",
"default": "http://192.168.1.108:2233",
"description": "后端服务地址"
},
"icCoder.timeout": {
"type": "number",
"default": 60000,
"description": "请求超时时间(毫秒)"
},
"icCoder.userId": {
"type": "string",
"default": "default-user",
"description": "用户ID临时配置"
}
}
}
]
},
"scripts": {
"vscode:prepublish": "pnpm run package",

View File

@ -1,6 +1,6 @@
/**
* 配置管理
* 从 VSCode 设置读取配置项
* 后端地址已预配置,用户无需手动设置
*/
import * as vscode from "vscode";
@ -14,7 +14,7 @@ export interface IccoderConfig {
userId: string;
}
/** 默认配置 */
/** 默认配置(预配置,不暴露给用户) */
const DEFAULT_CONFIG: IccoderConfig = {
backendUrl: "http://192.168.1.108:2233",
timeout: 60000,
@ -23,15 +23,10 @@ const DEFAULT_CONFIG: IccoderConfig = {
/**
* 获取配置项
* 直接返回预配置的值,用户无需手动配置
*/
export function getConfig(): IccoderConfig {
const config = vscode.workspace.getConfiguration("icCoder");
return {
backendUrl: config.get<string>("backendUrl", DEFAULT_CONFIG.backendUrl),
timeout: config.get<number>("timeout", DEFAULT_CONFIG.timeout),
userId: config.get<string>("userId", DEFAULT_CONFIG.userId),
};
return { ...DEFAULT_CONFIG };
}
/**