diff options
| author | 2026-01-15 16:57:04 +0800 | |
|---|---|---|
| committer | 2026-01-15 17:36:40 +0800 | |
| commit | bce23698b64d5bf2055786f903edc38a49076358 (patch) | |
| tree | 61d2c2dc3feb6c0bb17e77f0c46bbc345ee789de /ui/src/stores/settings.svelte.ts | |
| parent | fc6a787d84de70f8fc7ede782bc7c677a66c136e (diff) | |
| download | DropOut-bce23698b64d5bf2055786f903edc38a49076358.tar.gz DropOut-bce23698b64d5bf2055786f903edc38a49076358.zip | |
feat: Add custom background path handling and reactive URL conversion in SettingsState for enhanced user customization
Diffstat (limited to 'ui/src/stores/settings.svelte.ts')
| -rw-r--r-- | ui/src/stores/settings.svelte.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ui/src/stores/settings.svelte.ts b/ui/src/stores/settings.svelte.ts index cad466d..b85e5fb 100644 --- a/ui/src/stores/settings.svelte.ts +++ b/ui/src/stores/settings.svelte.ts @@ -1,4 +1,5 @@ import { invoke } from "@tauri-apps/api/core"; +import { convertFileSrc } from "@tauri-apps/api/core"; import { listen, type UnlistenFn } from "@tauri-apps/api/event"; import type { JavaCatalog, @@ -23,7 +24,18 @@ export class SettingsState { enable_visual_effects: true, active_effect: "constellation", theme: "dark", + custom_background_path: undefined, + log_upload_service: "paste.rs", + pastebin_api_key: undefined, }); + + // Convert background path to proper asset URL + get backgroundUrl(): string | undefined { + if (this.settings.custom_background_path) { + return convertFileSrc(this.settings.custom_background_path); + } + return undefined; + } javaInstallations = $state<JavaInstallation[]>([]); isDetectingJava = $state(false); @@ -131,6 +143,10 @@ export class SettingsState { this.settings.theme = "dark"; this.saveSettings(); } + // Ensure custom_background_path is reactive + if (!this.settings.custom_background_path) { + this.settings.custom_background_path = undefined; + } } catch (e) { console.error("Failed to load settings:", e); } @@ -138,6 +154,11 @@ export class SettingsState { async saveSettings() { try { + // Ensure we clean up any invalid paths before saving + if (this.settings.custom_background_path === "") { + this.settings.custom_background_path = undefined; + } + await invoke("save_settings", { config: this.settings }); uiState.setStatus("Settings saved!"); } catch (e) { |