🐛 兼容Windows/Linux的引入
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
use tauri::MenuItem;
|
||||
use tauri::{CustomMenuItem, Menu, Submenu, WindowMenuEvent};
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
use tauri::{Manager, SystemTray, SystemTrayMenu, WindowBuilder, WindowUrl};
|
||||
|
||||
pub fn get_menu() -> Menu {
|
||||
// first menu
|
||||
let hide = CustomMenuItem::new("hide", "Hide");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use crate::app::config::PakeConfig;
|
||||
use std::path::PathBuf;
|
||||
use tauri::{App, TitleBarStyle, Window, WindowBuilder, WindowUrl};
|
||||
use tauri::{App, Window, WindowBuilder, WindowUrl};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
|
||||
pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Window {
|
||||
let window_config = config
|
||||
@@ -21,22 +24,25 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
||||
_ => panic!("url type only can be web or local"),
|
||||
};
|
||||
|
||||
let title_bar_style = if window_config.transparent {
|
||||
TitleBarStyle::Overlay
|
||||
} else {
|
||||
TitleBarStyle::Visible
|
||||
};
|
||||
|
||||
let window_builder = WindowBuilder::new(app, "pake", url)
|
||||
let mut window_builder = WindowBuilder::new(app, "pake", url)
|
||||
.title("")
|
||||
.user_agent(user_agent)
|
||||
.resizable(window_config.resizable)
|
||||
.fullscreen(window_config.fullscreen)
|
||||
.title_bar_style(title_bar_style)
|
||||
.inner_size(window_config.width, window_config.height)
|
||||
.initialization_script(include_str!("../inject/style.js"))
|
||||
.initialization_script(include_str!("../inject/index.js"));
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let title_bar_style = if window_config.transparent {
|
||||
TitleBarStyle::Overlay
|
||||
} else {
|
||||
TitleBarStyle::Visible
|
||||
};
|
||||
window_builder = window_builder.title_bar_style(title_bar_style)
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
window_builder = window_builder.data_directory(_data_dir);
|
||||
|
||||
@@ -26,7 +26,7 @@ pub fn run_app() {
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
use pake::{get_system_tray, system_tray_handle};
|
||||
use menu::{get_system_tray, system_tray_handle};
|
||||
|
||||
let show_system_tray = pake_config.show_system_tray();
|
||||
let system_tray = get_system_tray(show_menu);
|
||||
|
||||
Reference in New Issue
Block a user