From bce23698b64d5bf2055786f903edc38a49076358 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Thu, 15 Jan 2026 16:57:04 +0800 Subject: feat: Add custom background path handling and reactive URL conversion in SettingsState for enhanced user customization --- ui/src/stores/settings.svelte.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ui') 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([]); 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) { -- cgit v1.2.3-70-g09d2