refactor: 移除 VSCode 设置中的配置项,使用预配置的默认值
This commit is contained in:
22
package.json
22
package.json
@ -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",
|
||||
|
||||
@ -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 };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user