From 6040a85e6265cf1a550220cea87fa253cdc9d7e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rik=20Levente?= <33373714+Levminer@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:01:19 +0200 Subject: [PATCH] linux fixes --- platforms/core/src/settings.rs | 32 ++++++++++++++++++----- platforms/core/tauri.conf.json | 6 +---- platforms/core/tauri.windows.conf.json | 12 +++++++++ platforms/interface/app/layout/app.svelte | 4 +++ 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 platforms/core/tauri.windows.conf.json diff --git a/platforms/core/src/settings.rs b/platforms/core/src/settings.rs index e1019a5..fd7db73 100644 --- a/platforms/core/src/settings.rs +++ b/platforms/core/src/settings.rs @@ -1,5 +1,4 @@ use serde::{Deserialize, Serialize}; -use std::path::Path; use uuid::Uuid; const fn default_string() -> String { @@ -49,6 +48,25 @@ pub struct Settings { pub version: Option, } +#[cfg(target_os = "windows")] +fn get_settings_path() -> std::path::PathBuf { + std::path::PathBuf::from("C:\\ProgramData\\Cores") +} + +#[cfg(not(target_os = "windows"))] +fn get_settings_path() -> std::path::PathBuf { + use directories::BaseDirs; + + match BaseDirs::new() { + Some(base_dirs) => { + return base_dirs.config_dir().to_path_buf(); + } + None => { + return std::path::PathBuf::from("/"); + } + }; +} + fn check_if_settings_exits() { let sample_settings = Settings { version: Some(1), @@ -62,7 +80,7 @@ fn check_if_settings_exits() { license_activated: "".to_string(), }; - let program_data = Path::new("C:\\ProgramData"); + let program_data = get_settings_path(); // Check if folder exists if !program_data.join("Cores").exists() { @@ -95,11 +113,12 @@ pub fn get_settings() -> Settings { println!("Getting settings"); - let program_data = Path::new("C:\\ProgramData"); + let program_data = get_settings_path(); check_if_settings_exits(); - let file = std::fs::read_to_string(program_data.join("Cores").join("settings.json")).expect("Failed to read settings file"); + let file = std::fs::read_to_string(program_data.join("Cores").join("settings.json")) + .expect("Failed to read settings file"); let settings: Result = serde_json::from_str(&file); match settings { @@ -120,11 +139,12 @@ pub fn get_settings() -> Settings { #[tauri::command] pub fn set_settings(settings: String) { - let program_data = Path::new("C:\\ProgramData"); + let program_data = get_settings_path(); println!("Setting settings"); check_if_settings_exits(); - std::fs::write(program_data.join("Cores").join("settings.json"), settings).expect("Failed to write settings file"); + std::fs::write(program_data.join("Cores").join("settings.json"), settings) + .expect("Failed to write settings file"); } diff --git a/platforms/core/tauri.conf.json b/platforms/core/tauri.conf.json index f41a1ca..62a186f 100644 --- a/platforms/core/tauri.conf.json +++ b/platforms/core/tauri.conf.json @@ -23,11 +23,7 @@ "minWidth": 600, "minHeight": 500, "maximized": true, - "theme": "Dark", - "transparent": true, - "windowEffects": { - "effects": ["mica"] - } + "theme": "Dark" } ], "security": { diff --git a/platforms/core/tauri.windows.conf.json b/platforms/core/tauri.windows.conf.json new file mode 100644 index 0000000..27f7d34 --- /dev/null +++ b/platforms/core/tauri.windows.conf.json @@ -0,0 +1,12 @@ +{ + "app": { + "windows": [ + { + "transparent": true, + "windowEffects": { + "effects": ["mica"] + } + } + ] + } +} diff --git a/platforms/interface/app/layout/app.svelte b/platforms/interface/app/layout/app.svelte index f8c9514..272c14d 100644 --- a/platforms/interface/app/layout/app.svelte +++ b/platforms/interface/app/layout/app.svelte @@ -94,6 +94,10 @@ const setBackgroundColor = async () => { const systemInfo: SystemInfo = await invoke("system_info") + if (systemInfo.osName !== "Windows") { + document.querySelector("body").style.background = "#0a0a0a" + } + if (systemInfo.osName === "Windows" && systemInfo.osVersion < "10.0.22000") { document.querySelector("body").style.background = "#0a0a0a" }