mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-06 03:13:44 +08:00
fix: kernel-caused silent mode failure to start windows
This commit is contained in:
parent
fa30567140
commit
2a6f8b401b
@ -20,12 +20,16 @@ use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
|||||||
// 打开面板
|
// 打开面板
|
||||||
pub fn open_or_close_dashboard() {
|
pub fn open_or_close_dashboard() {
|
||||||
if let Some(window) = handle::Handle::global().get_window() {
|
if let Some(window) = handle::Handle::global().get_window() {
|
||||||
if let Ok(true) = window.is_focused() {
|
// 如果窗口存在,则切换其显示状态
|
||||||
|
if window.is_visible().unwrap_or(false) {
|
||||||
let _ = window.hide();
|
let _ = window.hide();
|
||||||
return;
|
} else {
|
||||||
|
let _ = window.show();
|
||||||
|
let _ = window.set_focus();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
resolve::create_window();
|
||||||
}
|
}
|
||||||
resolve::create_window();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重启clash
|
// 重启clash
|
||||||
|
@ -37,7 +37,7 @@ pub fn find_unused_port() -> Result<u16> {
|
|||||||
/// handle something when start app
|
/// handle something when start app
|
||||||
pub async fn resolve_setup(app: &mut App) {
|
pub async fn resolve_setup(app: &mut App) {
|
||||||
error::redirect_panic_to_log();
|
error::redirect_panic_to_log();
|
||||||
// #[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
app.set_activation_policy(tauri::ActivationPolicy::Accessory);
|
||||||
let version = app.package_info().version.to_string();
|
let version = app.package_info().version.to_string();
|
||||||
|
|
||||||
@ -128,7 +128,29 @@ pub fn create_window() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let builder = tauri::WebviewWindowBuilder::new(
|
#[cfg(target_os = "windows")]
|
||||||
|
let window = {
|
||||||
|
let app_handle = app_handle.clone();
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
tauri::WebviewWindowBuilder::new(
|
||||||
|
&app_handle,
|
||||||
|
"main".to_string(),
|
||||||
|
tauri::WebviewUrl::App("index.html".into()),
|
||||||
|
)
|
||||||
|
.title("Clash Verge")
|
||||||
|
.visible(false)
|
||||||
|
.fullscreen(false)
|
||||||
|
.min_inner_size(600.0, 520.0)
|
||||||
|
.decorations(false)
|
||||||
|
.maximizable(true)
|
||||||
|
.additional_browser_args("--enable-features=msWebView2EnableDraggableRegions --disable-features=OverscrollHistoryNavigation,msExperimentalScrolling")
|
||||||
|
.transparent(true)
|
||||||
|
.build()
|
||||||
|
}).join().unwrap()
|
||||||
|
}.unwrap();
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
let window = tauri::WebviewWindowBuilder::new(
|
||||||
&app_handle,
|
&app_handle,
|
||||||
"main".to_string(),
|
"main".to_string(),
|
||||||
tauri::WebviewUrl::App("index.html".into()),
|
tauri::WebviewUrl::App("index.html".into()),
|
||||||
@ -136,31 +158,9 @@ pub fn create_window() {
|
|||||||
.title("Clash Verge")
|
.title("Clash Verge")
|
||||||
.visible(false)
|
.visible(false)
|
||||||
.fullscreen(false)
|
.fullscreen(false)
|
||||||
.min_inner_size(600.0, 520.0);
|
.min_inner_size(600.0, 520.0)
|
||||||
|
.build()
|
||||||
#[cfg(target_os = "windows")]
|
.unwrap();
|
||||||
let window = builder
|
|
||||||
.decorations(false)
|
|
||||||
.maximizable(true)
|
|
||||||
.additional_browser_args("--enable-features=msWebView2EnableDraggableRegions --disable-features=OverscrollHistoryNavigation,msExperimentalScrolling")
|
|
||||||
.transparent(true)
|
|
||||||
.visible(false)
|
|
||||||
.build().unwrap();
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let window = builder
|
|
||||||
.decorations(true)
|
|
||||||
.hidden_title(true)
|
|
||||||
.title_bar_style(tauri::TitleBarStyle::Overlay)
|
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let window = builder
|
|
||||||
.decorations(false)
|
|
||||||
.transparent(true)
|
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
match window.restore_state(StateFlags::all()) {
|
match window.restore_state(StateFlags::all()) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -169,12 +169,14 @@ pub fn create_window() {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(target: "app", "failed to restore window state: {}", e);
|
log::error!(target: "app", "failed to restore window state: {}", e);
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
window
|
{
|
||||||
.set_size(tauri::Size::Physical(tauri::PhysicalSize {
|
window.clone().on_window_event(move |_event| {
|
||||||
width: 800,
|
let _ = window.set_size(tauri::Size::Physical(tauri::PhysicalSize {
|
||||||
height: 636,
|
width: 800,
|
||||||
}))
|
height: 636,
|
||||||
.unwrap();
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
window
|
window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user