fix: 修复AI询问时选项点击后选中状态丢失的问题

- 添加 answeredQuestions Map 存储已回答问题的状态
- 在重新渲染时恢复选中状态和 answered 类
- 已回答的问题自动隐藏输入框并禁用点击事件
- 确保用户选择在页面更新时保持显示
This commit is contained in:
Roe-xin
2025-12-24 10:01:53 +08:00
parent 5c2ea0f15c
commit 10f0877a5e
9 changed files with 1763 additions and 1258 deletions

View File

@ -2,7 +2,7 @@
* 配置管理
* 从 VSCode 设置读取配置项
*/
import * as vscode from 'vscode';
import * as vscode from "vscode";
/** 配置项接口 */
export interface IccoderConfig {
@ -16,21 +16,21 @@ export interface IccoderConfig {
/** 默认配置 */
const DEFAULT_CONFIG: IccoderConfig = {
backendUrl: 'http://localhost:8080',
backendUrl: "http://localhost:8080",
timeout: 60000,
userId: 'default-user'
userId: "default-user",
};
/**
* 获取配置项
*/
export function getConfig(): IccoderConfig {
const config = vscode.workspace.getConfiguration('icCoder');
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)
backendUrl: config.get<string>("backendUrl", DEFAULT_CONFIG.backendUrl),
timeout: config.get<number>("timeout", DEFAULT_CONFIG.timeout),
userId: config.get<string>("userId", DEFAULT_CONFIG.userId),
};
}
@ -40,7 +40,9 @@ export function getConfig(): IccoderConfig {
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}`;
const baseUrl = backendUrl.endsWith("/")
? backendUrl.slice(0, -1)
: backendUrl;
const apiPath = path.startsWith("/") ? path : `/${path}`;
return `${baseUrl}${apiPath}`;
}