refactor: improve error handling and code formatting

- Enhanced error messages in Rust backend to include file paths
- Improved provider switching error handling with detailed messages
- Added MCP button placeholder in UI (functionality TODO)
- Applied code formatting across frontend components
- Extended error notification duration to 6s for better readability
This commit is contained in:
Jason
2025-10-08 21:22:56 +08:00
parent 6afc436946
commit e9833e9a57
20 changed files with 335 additions and 237 deletions

View File

@@ -150,7 +150,9 @@ export const tauriAPI = {
},
// 选择配置目录(可选默认路径)
selectConfigDirectory: async (defaultPath?: string): Promise<string | null> => {
selectConfigDirectory: async (
defaultPath?: string,
): Promise<string | null> => {
try {
// 后端参数为 snake_casedefault_path
return await invoke("pick_directory", { default_path: defaultPath });
@@ -384,7 +386,9 @@ export const tauriAPI = {
// theirs: 导入导出与文件对话框
// 导出配置到文件
exportConfigToFile: async (filePath: string): Promise<{
exportConfigToFile: async (
filePath: string,
): Promise<{
success: boolean;
message: string;
filePath: string;
@@ -398,7 +402,9 @@ export const tauriAPI = {
},
// 从文件导入配置
importConfigFromFile: async (filePath: string): Promise<{
importConfigFromFile: async (
filePath: string,
): Promise<{
success: boolean;
message: string;
backupId?: string;
@@ -415,7 +421,9 @@ export const tauriAPI = {
saveFileDialog: async (defaultName: string): Promise<string | null> => {
try {
// 后端参数为 snake_casedefault_name
const result = await invoke<string | null>("save_file_dialog", { default_name: defaultName });
const result = await invoke<string | null>("save_file_dialog", {
default_name: defaultName,
});
return result;
} catch (error) {
console.error("打开保存对话框失败:", error);