- feat(codex): Add “Apply to VS Code/Remove from VS Code” button on current Codex provider card
- feat(tauri): Add commands to read/write VS Code settings.json with cross-variant detection (Code/Insiders/VSCodium/OSS) - fix(vscode): Use top-level keys “chatgpt.apiBase” and “chatgpt.config.preferred_auth_method” - fix(vscode): Handle empty settings.json (skip deletes, direct write) to avoid “Can not delete in empty document” - fix(windows): Make atomic writes robust by removing target before rename - ui(provider-list): Improve error surfacing when applying/removing - chore(types): Extend window.api typings and tauri-api wrappers for VS Code commands - deps: Add jsonc-parser
This commit is contained in:
@@ -242,6 +242,34 @@ export const tauriAPI = {
|
||||
console.error("打开应用配置文件夹失败:", error);
|
||||
}
|
||||
},
|
||||
|
||||
// VS Code: 获取 settings.json 状态
|
||||
getVSCodeSettingsStatus: async (): Promise<{ exists: boolean; path: string; error?: string }> => {
|
||||
try {
|
||||
return await invoke("get_vscode_settings_status");
|
||||
} catch (error) {
|
||||
console.error("获取 VS Code 设置状态失败:", error);
|
||||
return { exists: false, path: "", error: String(error) };
|
||||
}
|
||||
},
|
||||
|
||||
// VS Code: 读取 settings.json 文本
|
||||
readVSCodeSettings: async (): Promise<string> => {
|
||||
try {
|
||||
return await invoke("read_vscode_settings");
|
||||
} catch (error) {
|
||||
throw new Error(`读取 VS Code 设置失败: ${String(error)}`);
|
||||
}
|
||||
},
|
||||
|
||||
// VS Code: 写回 settings.json 文本(不自动创建)
|
||||
writeVSCodeSettings: async (content: string): Promise<boolean> => {
|
||||
try {
|
||||
return await invoke("write_vscode_settings", { content });
|
||||
} catch (error) {
|
||||
throw new Error(`写入 VS Code 设置失败: ${String(error)}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// 创建全局 API 对象,兼容现有代码
|
||||
|
||||
Reference in New Issue
Block a user