From 656100cb76e032e05d6cd936c3d2644ef64be039 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Fri, 20 Dec 2024 11:44:57 -0500 Subject: [PATCH] refactor: remove platform-specific tauri conf Merge windows back to main tauri config. The reason I separated them was because I need decoration: true on mac and false on windows and linux. Now I use tauri rust API to set decorations to false for win and linux. --- apps/desktop/src-tauri/src/setup/window.rs | 18 ++++++++++----- apps/desktop/src-tauri/tauri.conf.json | 18 ++++++++++++++- apps/desktop/src-tauri/tauri.linux.conf.json | 22 ------------------- apps/desktop/src-tauri/tauri.macos.conf.json | 20 ----------------- .../desktop/src-tauri/tauri.windows.conf.json | 22 ------------------- 5 files changed, 29 insertions(+), 71 deletions(-) delete mode 100644 apps/desktop/src-tauri/tauri.linux.conf.json delete mode 100644 apps/desktop/src-tauri/tauri.macos.conf.json delete mode 100644 apps/desktop/src-tauri/tauri.windows.conf.json diff --git a/apps/desktop/src-tauri/src/setup/window.rs b/apps/desktop/src-tauri/src/setup/window.rs index 402111e..5ab5165 100644 --- a/apps/desktop/src-tauri/src/setup/window.rs +++ b/apps/desktop/src-tauri/src/setup/window.rs @@ -55,11 +55,17 @@ impl WindowExt for WebviewWindow { pub fn setup_window(app: &AppHandle) { #[cfg(target_os = "macos")] { - app.get_webview_window("main") - .unwrap() - .set_transparent_titlebar(true, true); - app.get_webview_window("splashscreen") - .unwrap() - .set_transparent_titlebar(true, true); + let main_win = app.get_webview_window("main").unwrap(); + main_win.set_transparent_titlebar(true, true); + let splashscreen_win = app.get_webview_window("splashscreen").unwrap(); + splashscreen_win.set_transparent_titlebar(true, true); + } + #[cfg(not(target_os = "macos"))] + { + // on linux or windows, set decorations to false + let main_win = app.get_webview_window("main").unwrap(); + main_win + .set_decorations(false) + .expect("Failed to set decorations"); } } diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index ef42742..e5ca9a9 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -13,7 +13,23 @@ "macOSPrivateApi": true, "security": { "csp": null - } + }, + "windows": [ + { + "hiddenTitle": true, + "url": "/app", + "title": "Kunkun", + "width": 800, + "visible": false, + "height": 600, + "decorations": true + }, + { + "url": "/splashscreen", + "visible": false, + "label": "splashscreen" + } + ] }, "bundle": { "createUpdaterArtifacts": true, diff --git a/apps/desktop/src-tauri/tauri.linux.conf.json b/apps/desktop/src-tauri/tauri.linux.conf.json deleted file mode 100644 index 884a812..0000000 --- a/apps/desktop/src-tauri/tauri.linux.conf.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "identifier": "sh.kunkun.desktop", - "app": { - "windows": [ - { - "hiddenTitle": true, - "url": "/app", - "title": "Kunkun", - "width": 800, - "height": 600, - "visible": false, - "decorations": false - }, - { - "url": "/splashscreen", - "label": "splashscreen", - "visible": false, - "decorations": false - } - ] - } -} diff --git a/apps/desktop/src-tauri/tauri.macos.conf.json b/apps/desktop/src-tauri/tauri.macos.conf.json deleted file mode 100644 index 46a8df7..0000000 --- a/apps/desktop/src-tauri/tauri.macos.conf.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "identifier": "sh.kunkun.desktop", - "app": { - "windows": [ - { - "hiddenTitle": true, - "url": "/app", - "title": "Kunkun", - "width": 800, - "visible": false, - "height": 600 - }, - { - "url": "/splashscreen", - "visible": false, - "label": "splashscreen" - } - ] - } -} diff --git a/apps/desktop/src-tauri/tauri.windows.conf.json b/apps/desktop/src-tauri/tauri.windows.conf.json deleted file mode 100644 index 884a812..0000000 --- a/apps/desktop/src-tauri/tauri.windows.conf.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "identifier": "sh.kunkun.desktop", - "app": { - "windows": [ - { - "hiddenTitle": true, - "url": "/app", - "title": "Kunkun", - "width": 800, - "height": 600, - "visible": false, - "decorations": false - }, - { - "url": "/splashscreen", - "label": "splashscreen", - "visible": false, - "decorations": false - } - ] - } -}