aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/stores/settings.svelte.ts
diff options
context:
space:
mode:
authorBegonia, HE <163421589+BegoniaHe@users.noreply.github.com>2026-01-14 05:16:31 +0100
committerGitHub <noreply@github.com>2026-01-14 05:16:31 +0100
commitf8790b62643cba62b8f329e93e5e3566394441d7 (patch)
treef3be16274ad1203e2f8ae4aeffeaf1102c580f4d /ui/src/stores/settings.svelte.ts
parentf093d2a310627aa3ee5a2820339f8a18bd251e81 (diff)
parente8e139c07d05e2f29f04906019dff5f3c520f8cc (diff)
downloadDropOut-f8790b62643cba62b8f329e93e5e3566394441d7.tar.gz
DropOut-f8790b62643cba62b8f329e93e5e3566394441d7.zip
Merge branch 'main' into feat/download-java-rt
Diffstat (limited to 'ui/src/stores/settings.svelte.ts')
-rw-r--r--ui/src/stores/settings.svelte.ts57
1 files changed, 57 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..989172c
--- /dev/null
+++ b/ui/src/stores/settings.svelte.ts
@@ -0,0 +1,57 @@
+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 {
+ const result = await invoke<LauncherConfig>("get_settings");
+ this.settings = result;
+ } 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();