Skip to content

Commit

Permalink
v(1.1.1): automatically add "theme" to config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
face-hh committed Nov 11, 2023
1 parent b85cf2e commit 4eca21b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "texteditor",
"private": true,
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"scripts": {
"tauri": "tauri",
Expand Down
9 changes: 7 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,14 @@ fn get_theme() -> String {
let contents = fs::read_to_string(&json_path).expect("Failed to read configuration for theme.");

let json_contents: Value = serde_json::from_str(&contents).expect("Failed to parse JSON");
let res = &json_contents["theme"].as_str().unwrap();

res.to_string()
match json_contents["theme"].as_str() {
Some(res) => res.to_string(),
None => {
set_theme("themes/default.css".to_string());
"themes/default.css".to_string()
}
}
}

#[tauri::command]
Expand Down

0 comments on commit 4eca21b

Please sign in to comment.