|
1 | 1 | <script> |
2 | 2 | import { onMount, createEventDispatcher } from 'svelte'; |
3 | 3 | import { FolderOpen, RotateCcw, Fingerprint, Play, RefreshCw, Plus, Trash2, XCircle, Copy, Database, HardDrive, Download, AlertTriangle, Loader2 } from 'lucide-svelte'; |
4 | | - import { GetActiveApps, CheckAppInstalled, GetAppDataPath, ResetApp, GenerateNewID, LaunchApp, OpenAppFolder, GetSessions, KillApp, ResetAddonData, GetApp, GetPlatformInfo, GetLogs } from '../../wailsjs/go/main/App.js'; |
| 4 | + import { GetActiveApps, CheckAppInstalled, GetAppDataPath, ResetApp, ResetAccountOnly, GenerateNewID, LaunchApp, OpenAppFolder, GetSessions, KillApp, ResetAddonData, GetApp, GetPlatformInfo, GetLogs } from '../../wailsjs/go/main/App.js'; |
5 | 5 | import { confirm } from './ConfirmModal.svelte'; |
6 | 6 | import { toast } from './Toast.svelte'; |
7 | 7 | import { settings } from './stores/settings.js'; |
|
12 | 12 | let loadingKill = false; |
13 | 13 | let loadingAddon = false; |
14 | 14 | let loadingLaunch = false; |
| 15 | + let showResetModeModal = false; |
15 | 16 |
|
16 | 17 | export let logs = []; |
17 | 18 | export let globalRunningAppsStatus = {}; |
|
216 | 217 | } |
217 | 218 |
|
218 | 219 | async function handleReset() { |
| 220 | + if (!selectedApp || loadingReset || !selectedApp.dataPath) return; |
| 221 | + showResetModeModal = true; |
| 222 | + } |
| 223 | +
|
| 224 | + async function handleFullReset() { |
| 225 | + showResetModeModal = false; |
219 | 226 | await handleResetWithOverride(false); |
220 | 227 | } |
221 | 228 |
|
| 229 | + async function handleRemoveAccountOnly() { |
| 230 | + showResetModeModal = false; |
| 231 | + if (!selectedApp || loadingReset) return; |
| 232 | +
|
| 233 | + if ($settings.confirmBeforeReset) { |
| 234 | + const confirmed = await confirm({ |
| 235 | + title: 'Remove Account Only', |
| 236 | + message: `Remove account files for ${selectedApp.display_name}?\n\nThis will remove:\n- User/globalStorage/state.vscdb\n- User/globalStorage/state.vscdb.backup\n- User/globalStorage/storage.json\n\nAuto-backup will NOT be created.`, |
| 237 | + confirmText: 'Remove Account', |
| 238 | + cancelText: 'Cancel', |
| 239 | + danger: true |
| 240 | + }); |
| 241 | + if (!confirmed) return; |
| 242 | + } |
| 243 | +
|
| 244 | + loadingReset = true; |
| 245 | + log(`[RemoveAccount] Starting ${selectedApp.display_name}...`); |
| 246 | + try { |
| 247 | + await ResetAccountOnly(selectedApp.app_name); |
| 248 | + log(`[RemoveAccount] ${selectedApp.display_name} complete!`); |
| 249 | + toast.success('Account data removed successfully', 3000); |
| 250 | + await loadApps(); |
| 251 | + } catch (e) { |
| 252 | + log(`[RemoveAccount] Error: ${e}`); |
| 253 | + toast.error(`Remove account failed: ${e}`, 5000); |
| 254 | + } finally { |
| 255 | + loadingReset = false; |
| 256 | + } |
| 257 | + } |
| 258 | +
|
222 | 259 | async function handleNewID() { |
223 | 260 | if (!selectedApp || loadingNewID) return; |
224 | 261 |
|
|
638 | 675 | </div> |
639 | 676 | </div> |
640 | 677 | </div> |
| 678 | +
|
| 679 | +{#if showResetModeModal} |
| 680 | + <div |
| 681 | + class="fixed inset-0 bg-black/70 backdrop-blur-sm flex items-center justify-center z-[210]" |
| 682 | + role="dialog" |
| 683 | + aria-modal="true" |
| 684 | + on:click|self={() => showResetModeModal = false} |
| 685 | + > |
| 686 | + <div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] w-full max-w-lg p-6 shadow-2xl"> |
| 687 | + <h3 class="text-lg font-semibold text-[var(--text-primary)] mb-2">Choose Reset Mode</h3> |
| 688 | + <p class="text-sm text-[var(--text-secondary)] mb-5"> |
| 689 | + Select which reset operation to run for <span class="text-[var(--text-primary)] font-medium">{selectedApp?.display_name}</span>. |
| 690 | + </p> |
| 691 | +
|
| 692 | + <div class="space-y-3"> |
| 693 | + <button |
| 694 | + class="w-full p-4 rounded-lg border border-[var(--border)] bg-[var(--bg-elevated)] hover:border-[var(--danger)]/60 hover:bg-[var(--danger)]/10 transition-colors text-left" |
| 695 | + on:click={handleFullReset} |
| 696 | + > |
| 697 | + <div class="flex items-center gap-2 mb-1"> |
| 698 | + <RotateCcw size={16} class="text-[var(--danger)]" /> |
| 699 | + <span class="font-semibold text-[var(--text-primary)]">Full Reset</span> |
| 700 | + </div> |
| 701 | + <p class="text-xs text-[var(--text-secondary)]"> |
| 702 | + Delete app data folder and addon folders. Auto-backup follows current setting. |
| 703 | + </p> |
| 704 | + </button> |
| 705 | +
|
| 706 | + <button |
| 707 | + class="w-full p-4 rounded-lg border border-[var(--border)] bg-[var(--bg-elevated)] hover:border-[var(--warning)]/60 hover:bg-[var(--warning)]/10 transition-colors text-left" |
| 708 | + on:click={handleRemoveAccountOnly} |
| 709 | + > |
| 710 | + <div class="flex items-center gap-2 mb-1"> |
| 711 | + <Trash2 size={16} class="text-[var(--warning)]" /> |
| 712 | + <span class="font-semibold text-[var(--text-primary)]">Remove Account Only</span> |
| 713 | + </div> |
| 714 | + <p class="text-xs text-[var(--text-secondary)]"> |
| 715 | + Remove only known account files: <code>User/globalStorage/state.vscdb</code>, <code>state.vscdb.backup</code>, and <code>storage.json</code>. |
| 716 | + </p> |
| 717 | + </button> |
| 718 | + </div> |
| 719 | +
|
| 720 | + <div class="flex justify-end mt-6"> |
| 721 | + <button |
| 722 | + class="px-4 py-2 rounded-lg font-medium bg-[var(--bg-hover)] hover:bg-[var(--border)] border border-[var(--border)] text-[var(--text-secondary)] transition-all" |
| 723 | + on:click={() => showResetModeModal = false} |
| 724 | + > |
| 725 | + Cancel |
| 726 | + </button> |
| 727 | + </div> |
| 728 | + </div> |
| 729 | + </div> |
| 730 | +{/if} |
0 commit comments