aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/stores/settings.svelte.ts
diff options
context:
space:
mode:
authorNatsuu <natsukawa247@outlook.com>2026-01-14 03:41:18 +0000
committerNatsuu <natsukawa247@outlook.com>2026-01-14 03:41:18 +0000
commit64b939e6ac0b196d18ee183a37a40b0bf7927a80 (patch)
tree54b366819e9f3fd8694092c0053dd5e706da59f9 /ui/src/stores/settings.svelte.ts
parent8aeadd2c2203540b93eabc6ba53b7b4ceaff7eb7 (diff)
downloadDropOut-64b939e6ac0b196d18ee183a37a40b0bf7927a80.tar.gz
DropOut-64b939e6ac0b196d18ee183a37a40b0bf7927a80.zip
refactor: split App.svelte into components
Diffstat (limited to 'ui/src/stores/settings.svelte.ts')
-rw-r--r--ui/src/stores/settings.svelte.ts56
1 files changed, 56 insertions, 0 deletions
diff --git a/ui/src/stores/settings.svelte.ts b/ui/src/stores/settings.svelte.ts
new file mode 100644
index 0000000..a1f687c
--- /dev/null
+++ b/ui/src/stores/settings.svelte.ts
@@ -0,0 +1,56 @@
+import { invoke } from "@tauri-apps/api/core";
+import type { LauncherConfig, JavaInstallation } from "../types";
+import { uiState } from "./ui.svelte";
+
+export class SettingsState {
+ settings = $state<LauncherConfig>({
+ min_memory: 1024,
+ max_memory: 2048,
+ java_path: "java",
+ width: 854,
+ height: 480,
+ });
+ javaInstallations = $state<JavaInstallation[]>([]);
+ isDetectingJava = $state(false);
+
+ async loadSettings() {
+ try {
+ this.settings = await invoke("get_settings");
+ } catch (e) {
+ console.error("Failed to load settings:", e);
+ }
+ }
+
+ async saveSettings() {
+ try {
+ await invoke("save_settings", { config: this.settings });
+ uiState.setStatus("Settings saved!");
+ } catch (e) {
+ console.error("Failed to save settings:", e);
+ uiState.setStatus("Error saving settings: " + e);
+ }
+ }
+
+ async detectJava() {
+ this.isDetectingJava = true;
+ try {
+ this.javaInstallations = await invoke("detect_java");
+ if (this.javaInstallations.length === 0) {
+ uiState.setStatus("No Java installations found");
+ } else {
+ uiState.setStatus(`Found ${this.javaInstallations.length} Java installation(s)`);
+ }
+ } catch (e) {
+ console.error("Failed to detect Java:", e);
+ uiState.setStatus("Error detecting Java: " + e);
+ } finally {
+ this.isDetectingJava = false;
+ }
+ }
+
+ selectJava(path: string) {
+ this.settings.java_path = path;
+ }
+}
+
+export const settingsState = new SettingsState();