From 49749c4dcf65dc8437c266693d907b3340eb223b Mon Sep 17 00:00:00 2001 From: roiii Date: Tue, 3 Dec 2024 15:54:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20=E5=8E=9F=E7=94=9F=20MacOs=20?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=8F=20(#215)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roy Co-authored-by: Akirami <66513481+A-kirami@users.noreply.github.com> --- src-tauri/src/lib.rs | 21 +++++++++++++++++++-- src-tauri/tauri.conf.json | 10 ---------- src/components/AppSidebar.vue | 5 ++--- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 56017265..2fdbe33a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,4 +1,4 @@ -use tauri::Manager; +use tauri::{Manager, WebviewUrl, WebviewWindowBuilder}; mod command; mod server; @@ -8,8 +8,25 @@ mod utils; pub fn run() { tauri::Builder::default() .setup(|app| { + let win_builder = WebviewWindowBuilder::new(app, "main", WebviewUrl::default(),) + .title("Matcha",) + .min_inner_size(620.0, 540.0,) + .inner_size(1080.0, 720.0,) + .center(); + + #[cfg(not(target_os = "macos"))] + let win_builder = win_builder.decorations(false,).transparent(true,); + + #[cfg(target_os = "macos")] + let win_builder = win_builder + .decorations(true,) + .hidden_title(true,) + .title_bar_style(tauri::TitleBarStyle::Overlay,); + + let window = win_builder.build().unwrap(); + #[cfg(dev)] - app.get_webview_window("main",).unwrap().open_devtools(); + window.open_devtools(); let cache_path = app.handle().path().app_cache_dir().unwrap(); let port: u16 = 8720; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 75837706..2266aa8b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -12,16 +12,6 @@ "app": { "macOSPrivateApi": true, "windows": [ - { - "title": "Matcha", - "height": 720, - "width": 1080, - "minHeight": 540, - "minWidth": 620, - "center": true, - "decorations": false, - "transparent": true - } ], "security": { "csp": null diff --git a/src/components/AppSidebar.vue b/src/components/AppSidebar.vue index 9247b55c..d6b54950 100644 --- a/src/components/AppSidebar.vue +++ b/src/components/AppSidebar.vue @@ -8,13 +8,12 @@ const isMacOs = $computed(() => unref(osType) === 'macos')