From 5820d0fa12d4854f7cb40f8a08899e99256c83e4 Mon Sep 17 00:00:00 2001 From: Bryan Lee <38807139+liby@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:22:33 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BB=8E=20`tauri.conf.json`=20?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=20`windows`=20=E9=85=8D=E7=BD=AE=E7=94=A8?= =?UTF-8?q?=E4=BB=A5=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/main.rs | 22 ++++++++++++++++++---- src-tauri/tauri.conf.json | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3fec2ba..d83af69 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,3 +1,6 @@ +use std::fs::File; +use tauri_utils::config::{Config, WindowConfig}; + fn main() -> wry::Result<()> { use wry::{ application::{ @@ -34,15 +37,26 @@ fn main() -> wry::Result<()> { menu_bar_menu.add_submenu("App", true, first_menu); + let config_file = File::open("./tauri.conf.json").unwrap(); + let config: Config = serde_json::from_reader(config_file).unwrap(); + let WindowConfig { + url, + width, + height, + resizable, + transparent, + .. + } = &config.tauri.windows[0]; + let event_loop = EventLoop::new(); let window = WindowBuilder::new() - .with_resizable(true) - .with_titlebar_transparent(true) + .with_resizable(*resizable) + .with_titlebar_transparent(*transparent) .with_fullsize_content_view(true) .with_titlebar_buttons_hidden(false) .with_title_hidden(true) .with_menu(menu_bar_menu) - .with_inner_size(wry::application::dpi::LogicalSize::new(1200.00, 728.00)) + .with_inner_size(wry::application::dpi::LogicalSize::new(*width, *height)) .build(&event_loop) .unwrap(); @@ -59,7 +73,7 @@ fn main() -> wry::Result<()> { }; let _webview = WebViewBuilder::new(window)? - .with_url("https://weread.qq.com/")? + .with_url(&url.to_string())? // .with_devtools(true) .with_initialization_script(include_str!("pake.js")) .with_ipc_handler(handler) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3b7828d..83db8f2 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -52,6 +52,8 @@ "height": 728, "resizable": true, "title": "WeRead", + "transparent": true, + "url": "https://weread.qq.com/", "width": 1200 } ]