精简MacOS平台下的rust代码
This commit is contained in:
@@ -28,42 +28,28 @@ use wry::webview::WebContext;
|
|||||||
|
|
||||||
fn main() -> wry::Result<()> {
|
fn main() -> wry::Result<()> {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let mut menu_bar_menu = Menu::new();
|
let (menu_bar_menu, close_item) = {
|
||||||
#[cfg(target_os = "macos")]
|
let mut menu_bar_menu = Menu::new();
|
||||||
let mut first_menu = Menu::new();
|
let mut first_menu = Menu::new();
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Hide);
|
||||||
first_menu.add_native_item(MenuItem::Hide);
|
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Minimize);
|
||||||
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
first_menu.add_native_item(MenuItem::Separator);
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Copy);
|
||||||
first_menu.add_native_item(MenuItem::Minimize);
|
first_menu.add_native_item(MenuItem::Cut);
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Paste);
|
||||||
first_menu.add_native_item(MenuItem::Separator);
|
first_menu.add_native_item(MenuItem::Undo);
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Redo);
|
||||||
first_menu.add_native_item(MenuItem::Copy);
|
first_menu.add_native_item(MenuItem::SelectAll);
|
||||||
#[cfg(target_os = "macos")]
|
first_menu.add_native_item(MenuItem::Separator);
|
||||||
first_menu.add_native_item(MenuItem::Cut);
|
let close_item = first_menu.add_item(
|
||||||
#[cfg(target_os = "macos")]
|
MenuItemAttributes::new("CloseWindow")
|
||||||
first_menu.add_native_item(MenuItem::Paste);
|
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
||||||
#[cfg(target_os = "macos")]
|
);
|
||||||
first_menu.add_native_item(MenuItem::Undo);
|
first_menu.add_native_item(MenuItem::Quit);
|
||||||
#[cfg(target_os = "macos")]
|
menu_bar_menu.add_submenu("App", true, first_menu);
|
||||||
first_menu.add_native_item(MenuItem::Redo);
|
(menu_bar_menu, close_item)
|
||||||
#[cfg(target_os = "macos")]
|
};
|
||||||
first_menu.add_native_item(MenuItem::SelectAll);
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
first_menu.add_native_item(MenuItem::Separator);
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let close_item = first_menu.add_item(
|
|
||||||
MenuItemAttributes::new("CloseWindow")
|
|
||||||
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
first_menu.add_native_item(MenuItem::Quit);
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||||
let (
|
let (
|
||||||
@@ -170,6 +156,7 @@ fn main() -> wry::Result<()> {
|
|||||||
.with_initialization_script(include_str!("pake.js"))
|
.with_initialization_script(include_str!("pake.js"))
|
||||||
.with_ipc_handler(handler)
|
.with_ipc_handler(handler)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
// 自定义cookie文件夹,仅用于Linux
|
// 自定义cookie文件夹,仅用于Linux
|
||||||
// Custom Cookie folder, only for Linux
|
// Custom Cookie folder, only for Linux
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
Reference in New Issue
Block a user