mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-06 16:31:12 +08:00
feat: add CLI settings export/import functionality
- Implemented exportSettings and importSettings APIs for CLI settings. - Added hooks useExportSettings and useImportSettings for managing export/import operations in the frontend. - Updated SettingsPage to include buttons for exporting and importing CLI settings. - Enhanced backend to handle export and import requests, including validation and conflict resolution. - Introduced new data structures for exported settings and import options. - Updated localization files to support new export/import features. - Refactored CLI tool configurations to remove hardcoded model defaults, allowing dynamic model retrieval.
This commit is contained in:
@@ -16,11 +16,15 @@ import {
|
||||
fetchCliToolStatus,
|
||||
fetchCcwInstallations,
|
||||
upgradeCcwInstallation,
|
||||
exportSettings,
|
||||
importSettings,
|
||||
type ChineseResponseStatus,
|
||||
type WindowsPlatformStatus,
|
||||
type CodexCliEnhancementStatus,
|
||||
type CcwInstallStatus,
|
||||
type CcwInstallationManifest,
|
||||
type ExportedSettings,
|
||||
type ImportOptions,
|
||||
} from '../lib/api';
|
||||
|
||||
// Query key factory
|
||||
@@ -32,6 +36,7 @@ export const systemSettingsKeys = {
|
||||
aggregatedStatus: () => [...systemSettingsKeys.all, 'aggregatedStatus'] as const,
|
||||
cliToolStatus: () => [...systemSettingsKeys.all, 'cliToolStatus'] as const,
|
||||
ccwInstallations: () => [...systemSettingsKeys.all, 'ccwInstallations'] as const,
|
||||
exportSettings: () => [...systemSettingsKeys.all, 'exportSettings'] as const,
|
||||
};
|
||||
|
||||
const STALE_TIME = 60 * 1000; // 1 minute
|
||||
@@ -285,3 +290,39 @@ export function useUpgradeCcwInstallation() {
|
||||
error: mutation.error,
|
||||
};
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// Settings Export/Import Hooks
|
||||
// ========================================
|
||||
|
||||
export function useExportSettings() {
|
||||
const mutation = useMutation({
|
||||
mutationFn: exportSettings,
|
||||
});
|
||||
|
||||
return {
|
||||
exportSettings: mutation.mutateAsync,
|
||||
isPending: mutation.isPending,
|
||||
error: mutation.error,
|
||||
};
|
||||
}
|
||||
|
||||
export function useImportSettings() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: ({ data, options }: { data: ExportedSettings; options?: ImportOptions }) =>
|
||||
importSettings(data, options),
|
||||
onSuccess: () => {
|
||||
// Invalidate all system settings queries to refresh the UI
|
||||
queryClient.invalidateQueries({ queryKey: systemSettingsKeys.all });
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
importSettings: (data: ExportedSettings, options?: ImportOptions) =>
|
||||
mutation.mutateAsync({ data, options }),
|
||||
isPending: mutation.isPending,
|
||||
error: mutation.error,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user