Add Restore Default Claude CLI button to settings page
Co-authored-by: simon-ami <102378134+simon-ami@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ window.Components.claudeConfig = () => ({
|
||||
configPath: '', // Dynamic path from backend
|
||||
models: [],
|
||||
loading: false,
|
||||
restoring: false,
|
||||
gemini1mSuffix: false,
|
||||
|
||||
// Model fields that may contain Gemini model names
|
||||
@@ -141,5 +142,27 @@ window.Components.claudeConfig = () => ({
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
async restoreDefaultClaudeConfig() {
|
||||
this.restoring = true;
|
||||
const password = Alpine.store('global').webuiPassword;
|
||||
try {
|
||||
const { response, newPassword } = await window.utils.request('/api/claude/config/restore', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}, password);
|
||||
if (newPassword) Alpine.store('global').webuiPassword = newPassword;
|
||||
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
Alpine.store('global').showToast(Alpine.store('global').t('claudeConfigRestored'), 'success');
|
||||
|
||||
// Reload the config to reflect the changes
|
||||
await this.fetchConfig();
|
||||
} catch (e) {
|
||||
Alpine.store('global').showToast(Alpine.store('global').t('restoreConfigFailed') + ': ' + e.message, 'error');
|
||||
} finally {
|
||||
this.restoring = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,7 +157,10 @@ document.addEventListener('alpine:init', () => {
|
||||
accountsReloaded: "Accounts reloaded",
|
||||
reloadFailed: "Reload failed",
|
||||
claudeConfigSaved: "Claude configuration saved",
|
||||
claudeConfigRestored: "Claude CLI restored to defaults",
|
||||
saveConfigFailed: "Failed to save configuration",
|
||||
restoreConfigFailed: "Failed to restore configuration",
|
||||
restoreDefault: "Restore Default",
|
||||
claudeActive: "Claude Active",
|
||||
claudeEmpty: "Claude Empty",
|
||||
geminiActive: "Gemini Active",
|
||||
@@ -406,7 +409,10 @@ document.addEventListener('alpine:init', () => {
|
||||
accountsReloaded: "账号配置已重载",
|
||||
reloadFailed: "重载失败",
|
||||
claudeConfigSaved: "Claude 配置已保存",
|
||||
claudeConfigRestored: "Claude CLI 已恢复默认设置",
|
||||
saveConfigFailed: "保存配置失败",
|
||||
restoreConfigFailed: "恢复配置失败",
|
||||
restoreDefault: "恢复默认",
|
||||
claudeActive: "Claude 活跃",
|
||||
claudeEmpty: "Claude 耗尽",
|
||||
geminiActive: "Gemini 活跃",
|
||||
|
||||
@@ -523,7 +523,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end pt-2">
|
||||
<div class="flex justify-end pt-2 gap-3">
|
||||
<button class="btn btn-sm btn-ghost border border-space-border/50 hover:border-red-500/30 hover:bg-red-500/5 text-gray-400 hover:text-red-400 px-6 gap-2"
|
||||
@click="restoreDefaultClaudeConfig" :disabled="restoring">
|
||||
<svg x-show="!restoring" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
||||
</svg>
|
||||
<span x-show="!restoring" x-text="$store.global.t('restoreDefault')">Restore Default</span>
|
||||
<span x-show="restoring" class="loading loading-spinner loading-xs"></span>
|
||||
</button>
|
||||
<button class="btn btn-sm bg-neon-purple hover:bg-purple-600 border-none text-white px-6 gap-2"
|
||||
@click="saveClaudeConfig" :disabled="loading">
|
||||
<svg x-show="!loading" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
|
||||
Reference in New Issue
Block a user