优化Linux下面的表现,更新ReadMe文档
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,6 +21,7 @@ dist-ssr
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
.npmrc
|
||||||
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|||||||
@@ -99,8 +99,14 @@ npm i
|
|||||||
// 调试
|
// 调试
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
// 打包
|
// 打包(Mac)
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
// 打包(Windows)
|
||||||
|
npm run build:windows
|
||||||
|
|
||||||
|
// 打包(Linux)
|
||||||
|
npm run build:linux
|
||||||
```
|
```
|
||||||
|
|
||||||
## 打新包
|
## 打新包
|
||||||
|
|||||||
@@ -101,8 +101,14 @@ npm i
|
|||||||
// Local development
|
// Local development
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
// Pack
|
// Pack (Mac)
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
// Pack (Windows)
|
||||||
|
npm run build:windows
|
||||||
|
|
||||||
|
// Pack(Linux)
|
||||||
|
npm run build:linux
|
||||||
```
|
```
|
||||||
|
|
||||||
## New pack
|
## New pack
|
||||||
|
|||||||
@@ -3,6 +3,21 @@
|
|||||||
extern crate image;
|
extern crate image;
|
||||||
use tauri_utils::config::{Config, WindowConfig};
|
use tauri_utils::config::{Config, WindowConfig};
|
||||||
|
|
||||||
|
#[cfg(target_os="macos")]
|
||||||
|
use wry::{
|
||||||
|
application::{
|
||||||
|
accelerator::{Accelerator, SysMods},
|
||||||
|
event::{Event, StartCause, WindowEvent},
|
||||||
|
event_loop::{ControlFlow, EventLoop},
|
||||||
|
keyboard::KeyCode,
|
||||||
|
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
|
||||||
|
window::{Fullscreen, Window, WindowBuilder},
|
||||||
|
},
|
||||||
|
webview::WebViewBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(target_os="windows")]
|
||||||
use wry::{
|
use wry::{
|
||||||
application::{
|
application::{
|
||||||
accelerator::{Accelerator, SysMods},
|
accelerator::{Accelerator, SysMods},
|
||||||
@@ -16,6 +31,18 @@ use wry::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(target_os="linux")]
|
||||||
|
use wry::{
|
||||||
|
application::{
|
||||||
|
event::{Event, StartCause, WindowEvent},
|
||||||
|
event_loop::{ControlFlow, EventLoop},
|
||||||
|
menu::{MenuBar as Menu, MenuItem, MenuType},
|
||||||
|
window::{Fullscreen, Window, WindowBuilder},
|
||||||
|
},
|
||||||
|
webview::WebViewBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
fn main() -> wry::Result<()> {
|
fn main() -> wry::Result<()> {
|
||||||
|
|
||||||
let mut menu_bar_menu = Menu::new();
|
let mut menu_bar_menu = Menu::new();
|
||||||
@@ -32,6 +59,7 @@ fn main() -> wry::Result<()> {
|
|||||||
first_menu.add_native_item(MenuItem::Redo);
|
first_menu.add_native_item(MenuItem::Redo);
|
||||||
first_menu.add_native_item(MenuItem::SelectAll);
|
first_menu.add_native_item(MenuItem::SelectAll);
|
||||||
first_menu.add_native_item(MenuItem::Separator);
|
first_menu.add_native_item(MenuItem::Separator);
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
let close_item = first_menu.add_item(
|
let close_item = first_menu.add_item(
|
||||||
MenuItemAttributes::new("CloseWindow")
|
MenuItemAttributes::new("CloseWindow")
|
||||||
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
||||||
@@ -58,7 +86,9 @@ fn main() -> wry::Result<()> {
|
|||||||
None
|
None
|
||||||
})
|
})
|
||||||
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
|
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
let icon_path = concat!(env!("CARGO_MANIFEST_DIR"), "/icons/icon.ico");
|
let icon_path = concat!(env!("CARGO_MANIFEST_DIR"), "/icons/icon.ico");
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
let icon = load_icon(std::path::Path::new(icon_path));
|
let icon = load_icon(std::path::Path::new(icon_path));
|
||||||
|
|
||||||
|
|
||||||
@@ -69,12 +99,13 @@ fn main() -> wry::Result<()> {
|
|||||||
.with_window_icon(Some(icon))
|
.with_window_icon(Some(icon))
|
||||||
.build(&event_loop)
|
.build(&event_loop)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let window = common_window
|
let window = common_window
|
||||||
.with_title("")
|
.with_title("")
|
||||||
.build(&event_loop)
|
.build(&event_loop)
|
||||||
.with_menu(menu_bar_menu)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let window = common_window
|
let window = common_window
|
||||||
.with_fullsize_content_view(true)
|
.with_fullsize_content_view(true)
|
||||||
@@ -141,6 +172,7 @@ fn main() -> wry::Result<()> {
|
|||||||
origin: MenuType::MenuBar,
|
origin: MenuType::MenuBar,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
if menu_id == close_item.clone().id() {
|
if menu_id == close_item.clone().id() {
|
||||||
webview.window().set_minimized(true);
|
webview.window().set_minimized(true);
|
||||||
}
|
}
|
||||||
@@ -158,7 +190,7 @@ fn get_windows_config() -> Option<WindowConfig> {
|
|||||||
config.tauri.windows.iter().next().cloned()
|
config.tauri.windows.iter().next().cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
fn load_icon(path: &std::path::Path) -> Icon {
|
fn load_icon(path: &std::path::Path) -> Icon {
|
||||||
let (icon_rgba, icon_width, icon_height) = {
|
let (icon_rgba, icon_width, icon_height) = {
|
||||||
// alternatively, you can embed the icon in the binary through `include_bytes!` macro and use `image::load_from_memory`
|
// alternatively, you can embed the icon in the binary through `include_bytes!` macro and use `image::load_from_memory`
|
||||||
|
|||||||
Reference in New Issue
Block a user