Skip to content

Commit 5cac1dc

Browse files
committed
# Changes to be committed:
# modified: bun.lock # modified: index.html # modified: package.json # modified: src-tauri/Cargo.lock # modified: src-tauri/Cargo.toml # deleted: src-tauri/src/fs.rs # deleted: src-tauri/src/hotkeys.rs # modified: src-tauri/src/lib.rs # new file: src-tauri/src/settings.rs # deleted: src-tauri/src/watcher.rs # deleted: src-tauri/src/window.rs # modified: src/SpotifyAuth/spotifyServer.ts # modified: src/ui/index.tsx # modified: src/ui/layouts/LayoutB.tsx # modified: src/ui/settingLib.ts # modified: src/ui/views/Boot.tsx #
1 parent 87636d5 commit 5cac1dc

16 files changed

Lines changed: 217 additions & 106 deletions

File tree

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
<body class="m-0 p-0 overflow-hidden">
1111
<div id="root"></div>
12-
1312
<script type="module" src="/src/main.tsx"></script>
1413
</body>
1514
</html>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@tauri-apps/api": "^2.8.0",
1515
"@tauri-apps/plugin-fs": "~2",
1616
"@tauri-apps/plugin-opener": "^2",
17+
"dotenv": "^17.2.3",
1718
"react": "^19.1.0",
1819
"react-dom": "^19.1.0",
1920
"spotify-web-api-node": "^5.0.2",

src-tauri/Cargo.lock

Lines changed: 38 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ crate-type = ["staticlib", "cdylib", "rlib"]
1818
tauri-build = { version = "2", features = [] }
1919

2020
[dependencies]
21-
tauri = { version = "2", features = [ "tray-icon" ] }
21+
tauri = { version = "2.8.5", features = [] }
2222
tauri-plugin-opener = "2"
23+
tauri-plugin-fs = "2"
2324
serde = { version = "1", features = ["derive"] }
2425
serde_json = "1"
25-
tauri-plugin-fs = "2"
26-
26+
dirs = "4.0"

src-tauri/src/fs.rs

Whitespace-only changes.

src-tauri/src/hotkeys.rs

Whitespace-only changes.

src-tauri/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
1+
mod settings;
22

3-
#[cfg_attr(mobile, tauri::mobile_entry_point)]
43
pub fn run() {
54
tauri::Builder::default()
65
.plugin(tauri_plugin_fs::init())
76
.plugin(tauri_plugin_opener::init())
7+
.invoke_handler(tauri::generate_handler![
8+
settings::read_settings,
9+
settings::write_settings
10+
])
811
.run(tauri::generate_context!())
912
.expect("error while running tauri application");
1013
}

src-tauri/src/settings.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::fs;
3+
use std::path::PathBuf;
4+
use dirs::config_dir;
5+
6+
#[derive(Serialize, Deserialize, Debug, Clone)]
7+
pub struct Settings {
8+
pub first_boot_done: bool,
9+
pub spotify: SpotifyTokens,
10+
pub layout: String,
11+
pub theme: String,
12+
}
13+
14+
#[derive(Serialize, Deserialize, Debug, Clone)]
15+
pub struct SpotifyTokens {
16+
pub access_token: Option<String>,
17+
pub refresh_token: Option<String>,
18+
}
19+
20+
impl Default for Settings {
21+
fn default() -> Self {
22+
Self {
23+
first_boot_done: false,
24+
spotify: SpotifyTokens { access_token: None, refresh_token: None },
25+
layout: "LayoutA".into(),
26+
theme: "dark".into(),
27+
}
28+
}
29+
}
30+
31+
fn get_settings_path() -> PathBuf {
32+
let mut path = config_dir().unwrap_or_else(|| PathBuf::from("."));
33+
path.push("spotify-mini-player");
34+
fs::create_dir_all(&path).ok(); // erstellt Ordner falls nicht da
35+
path.push("settings.json");
36+
path
37+
}
38+
39+
#[tauri::command]
40+
pub fn read_settings() -> Settings {
41+
let path = get_settings_path();
42+
if let Ok(raw) = fs::read_to_string(&path) {
43+
serde_json::from_str(&raw).unwrap_or_default()
44+
} else {
45+
Settings::default()
46+
}
47+
}
48+
49+
#[tauri::command]
50+
pub fn write_settings(settings: Settings) -> bool {
51+
let path = get_settings_path();
52+
fs::write(&path, serde_json::to_string_pretty(&settings).unwrap()).is_ok()
53+
}

src-tauri/src/watcher.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)