mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
feat: overhaul OpenClaw config panels with JSON5 round-trip write engine
- Add json-five crate for JSON5 serialization preserving comments and formatting - Rewrite openclaw_config.rs with comment-preserving JSON5 read/write engine - Add Tauri commands: get_openclaw_live_provider, write_openclaw_config_section - Redesign EnvPanel as full JSON editor with structured error handling - Add tools.profile selection (minimal/coding/messaging/full) to ToolsPanel - Add legacy timeout migration support to AgentsDefaultsPanel - Add OpenClawHealthBanner component for config validation warnings - Add supporting hooks, mutations, utility functions, and unit tests
This commit is contained in:
@@ -80,6 +80,9 @@ export function useProviderActions(activeApp: AppId) {
|
||||
const existingCatalog = (await openclawApi.getModelCatalog()) || {};
|
||||
const mergedCatalog = { ...existingCatalog, ...modelCatalog };
|
||||
await openclawApi.setModelCatalog(mergedCatalog);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: openclawKeys.health,
|
||||
});
|
||||
modelsRegistered = true;
|
||||
}
|
||||
|
||||
@@ -88,6 +91,9 @@ export function useProviderActions(activeApp: AppId) {
|
||||
const existingDefault = await openclawApi.getDefaultModel();
|
||||
if (!existingDefault?.primary) {
|
||||
await openclawApi.setDefaultModel(model);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: openclawKeys.health,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +115,7 @@ export function useProviderActions(activeApp: AppId) {
|
||||
}
|
||||
}
|
||||
},
|
||||
[addProviderMutation, activeApp, t],
|
||||
[addProviderMutation, activeApp, queryClient, t],
|
||||
);
|
||||
|
||||
// 更新供应商
|
||||
@@ -255,15 +261,26 @@ export function useProviderActions(activeApp: AppId) {
|
||||
};
|
||||
|
||||
try {
|
||||
await openclawApi.setDefaultModel(model);
|
||||
const outcome = await openclawApi.setDefaultModel(model);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: openclawKeys.defaultModel,
|
||||
});
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: openclawKeys.health,
|
||||
});
|
||||
toast.success(
|
||||
t("notifications.openclawDefaultModelSet", {
|
||||
defaultValue: "已设为默认模型",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
{
|
||||
closeButton: true,
|
||||
description: outcome.backupPath
|
||||
? t("openclaw.backupCreated", {
|
||||
path: outcome.backupPath,
|
||||
defaultValue: "Backup created: {{path}}",
|
||||
})
|
||||
: undefined,
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
const detail =
|
||||
|
||||
Reference in New Issue
Block a user