From d0c22d0df0dddfaa8898723388e05eb018a9e3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Thu, 28 Dec 2023 21:53:38 +0000 Subject: [PATCH] build: make it compile under linux --- src/stub.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/stub.rs b/src/stub.rs index 4c3f14c..d826adb 100644 --- a/src/stub.rs +++ b/src/stub.rs @@ -5,15 +5,16 @@ use std::fs::File; use std::io::{BufReader, Read}; use std::io::{Cursor, Seek}; use std::path::Path; + +#[cfg(target_os = "windows")] use tao::platform::windows::WindowBuilderExtWindows; -use tao::window::Icon; + use tao::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, - window::WindowBuilder, + window::{Icon, WindowBuilder}, }; -use wry::WebContext; -use wry::{http::header::CONTENT_TYPE, WebViewBuilder}; +use wry::{http::header::CONTENT_TYPE, WebContext, WebViewBuilder}; use zip::ZipArchive; static APP_UUID: &str = "39abaebb-57b1-4c12-ab88-321fd7a93354"; @@ -86,11 +87,15 @@ fn main() -> wry::Result<()> { let event_loop = EventLoop::new(); let window = WindowBuilder::new() .with_title(format!("um-react-wry 桌面客户端 - {}", version_suffix)) - .with_maximized(true) - .with_window_icon(Some(load_icon(include_bytes!("um-react@16.webp")))) - .with_taskbar_icon(Some(load_icon(include_bytes!("um-react@192.webp")))) - .build(&event_loop) - .unwrap(); + .with_maximized(true); + + #[cfg(target_os = "windows")] + let window = window.with_taskbar_icon(Some(load_icon(include_bytes!("um-react@192.webp")))); + + let window = window.build(&event_loop).unwrap(); + + #[cfg(any(target_os = "windows", target_os = "linux"))] + window.set_window_icon(Some(load_icon(include_bytes!("um-react@16.webp")))); #[cfg(any( target_os = "windows",