fix bug of saving

This commit is contained in:
锦恢 2025-06-01 16:48:14 +08:00
parent e4e626cd4e
commit 6ab0c789b4
4 changed files with 36 additions and 8 deletions

View File

@ -8,6 +8,7 @@
- 解决 issue#21 最后一个标签页关闭并恢复默认页面。
- 解决 issue#22 工具模块UI异常现在 openmcp 支持解析 pydantic 进行 typing 的 python mcp 了。
- 优化对象输入框,现在对象输入框具有语法高亮和受限度的自动补全了。
- 对于 trae 的所有默认主题进行额外支持。
## [main] 0.1.1
- 修复 SSH 连接 Ubuntu 的情况下的部分 bug

View File

@ -176,9 +176,10 @@ export class MacroColor {
// 额外支持 trae 的默认主题
const sidebarColorString = this.rootStyles.getPropertyValue('--sidebar');
if (sidebarColorString === backgroundColorString) {
// trae 默认主题的特点sidebarColorString 和 backgroundColorString 一样
// 把 默认主题的特点sidebarColorString 的颜色加深一些
const newSidebarColor = this.theme === 'dark' ? '#252a38' : '#edeff2';
document.documentElement.style.setProperty('--sidebar', newSidebarColor);
pinkLog('修改 sidebar 颜色为' + newSidebarColor);
document.documentElement.style.setProperty('--sidebar', 'var(--vscode-icube-colorBg2)');
}
}

View File

@ -68,6 +68,19 @@ export function getConnectionConfig() {
let connection;
try {
connection = JSON.parse(rawConnectionString) as IConnectionConfig;
// 对连接信息进行校验
if (!connection.items) {
connection = { items: [] };
}
connection.items = connection.items.filter(item => {
if (Array.isArray(item) && item.length === 0) {
return false;
}
return true;
});
} catch (error) {
connection = { items: [] };
}
@ -110,6 +123,19 @@ export function getWorkspaceConnectionConfig() {
let connection;
try {
connection = JSON.parse(rawConnectionString) as IConnectionConfig;
// 对连接信息进行校验
if (!connection.items) {
connection = { items: [] };
}
connection.items = connection.items.filter(item => {
if (Array.isArray(item) && item.length === 0) {
return false;
}
return true;
});
} catch (error) {
connection = { items: [] };
}
@ -169,7 +195,7 @@ export function saveWorkspaceConnectionConfig(workspace: string) {
const workspacePath = getWorkspacePath();
for (let item of connectionConfig.items) {
const connections = Array.isArray(item)? item : [item];
const connections = Array.isArray(item) ? item : [item];
for (let connection of connections) {
const connectionType = (connection.type || connection.connectionType).toUpperCase() as ConnectionType;
connection.type = undefined;
@ -283,7 +309,7 @@ export function getWorkspaceConnectionConfigItemByPath(absPath: string) {
const normaliseAbsPath = absPath.replace(/\\/g, '/');
for (let item of workspaceConnectionConfig.items) {
const nItem = Array.isArray(item)? item[0] : item;
const nItem = Array.isArray(item) ? item[0] : item;
const filePath = normaliseConnectionFilePath(nItem, workspacePath);
if (filePath === normaliseAbsPath) {
@ -303,7 +329,7 @@ export function getInstalledConnectionConfigItemByPath(absPath: string) {
const normaliseAbsPath = absPath.replace(/\\/g, '/');
for (let item of installedConnectionConfig.items) {
const nItem = Array.isArray(item)? item[0] : item;
const nItem = Array.isArray(item) ? item[0] : item;
const filePath = (nItem.filePath || '').replace(/\\/g, '/');
if (filePath === normaliseAbsPath) {

View File

@ -51,7 +51,7 @@ export class McpWorkspaceConnectProvider implements vscode.TreeDataProvider<Conn
const item = await acquireUserCustomConnection();
if (!item) {
if (item.length === 0) {
return;
}