refactor: 升级 tauri 到 2.x
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
use crate::app::config::PakeConfig;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{App, Window, WindowBuilder, WindowUrl};
|
||||
use tauri::{App, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
|
||||
pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Window {
|
||||
pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> WebviewWindow {
|
||||
let window_config = config
|
||||
.windows
|
||||
.first()
|
||||
@@ -14,8 +14,8 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
||||
let user_agent = config.user_agent.get();
|
||||
|
||||
let url = match window_config.url_type.as_str() {
|
||||
"web" => WindowUrl::App(window_config.url.parse().unwrap()),
|
||||
"local" => WindowUrl::App(PathBuf::from(&window_config.url)),
|
||||
"web" => WebviewUrl::App(window_config.url.parse().unwrap()),
|
||||
"local" => WebviewUrl::App(PathBuf::from(&window_config.url)),
|
||||
_ => panic!("url type can only be web or local"),
|
||||
};
|
||||
|
||||
@@ -24,14 +24,14 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
||||
serde_json::to_string(&window_config).unwrap()
|
||||
);
|
||||
|
||||
let mut window_builder = WindowBuilder::new(app, "pake", url)
|
||||
let mut window_builder = WebviewWindowBuilder::new(app, "pake", url)
|
||||
.title("")
|
||||
.user_agent(user_agent)
|
||||
.visible(false) // Prevent initial shaking
|
||||
.resizable(window_config.resizable)
|
||||
.fullscreen(window_config.fullscreen)
|
||||
.inner_size(window_config.width, window_config.height)
|
||||
.disable_file_drop_handler()
|
||||
.disable_drag_drop_handler()
|
||||
.always_on_top(window_config.always_on_top)
|
||||
.initialization_script(&config_script)
|
||||
.initialization_script(include_str!("../inject/component.js"))
|
||||
|
||||
Reference in New Issue
Block a user