mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:23:44 +08:00
fix: windows/linux runtime crash
This commit is contained in:
parent
9bb2160abe
commit
fdcefe458e
@ -10,7 +10,9 @@ use config::Config;
|
|||||||
use tauri_plugin_autostart::MacosLauncher;
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
use std::sync::{Mutex, Once};
|
use std::sync::{Mutex, Once};
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::AppHandle;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use tauri::Manager;
|
||||||
|
|
||||||
/// A global singleton handle to the application.
|
/// A global singleton handle to the application.
|
||||||
pub struct AppHandleManager {
|
pub struct AppHandleManager {
|
||||||
@ -203,8 +205,11 @@ pub fn run() {
|
|||||||
app.run(|app_handle, e| match e {
|
app.run(|app_handle, e| match e {
|
||||||
tauri::RunEvent::Ready | tauri::RunEvent::Resumed => {
|
tauri::RunEvent::Ready | tauri::RunEvent::Resumed => {
|
||||||
AppHandleManager::global().init(app_handle.clone());
|
AppHandleManager::global().init(app_handle.clone());
|
||||||
let main_window = AppHandleManager::global().get_handle().get_webview_window("main").unwrap();
|
#[cfg(target_os = "macos")]
|
||||||
let _ = main_window.set_title("Clash Verge");
|
{
|
||||||
|
let main_window = AppHandleManager::global().get_handle().get_webview_window("main").unwrap();
|
||||||
|
let _ = main_window.set_title("Clash Verge");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
tauri::RunEvent::Reopen { has_visible_windows, .. } => {
|
tauri::RunEvent::Reopen { has_visible_windows, .. } => {
|
||||||
@ -222,6 +227,7 @@ pub fn run() {
|
|||||||
if label == "main" {
|
if label == "main" {
|
||||||
match event {
|
match event {
|
||||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
AppHandleManager::global().set_activation_policy_accessory();
|
AppHandleManager::global().set_activation_policy_accessory();
|
||||||
if core::handle::Handle::global().is_exiting() {
|
if core::handle::Handle::global().is_exiting() {
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use crate::config::IVerge;
|
use crate::config::IVerge;
|
||||||
use crate::utils::error;
|
use crate::utils::error;
|
||||||
use crate::{config::Config, config::PrfItem, core::*, utils::init, utils::server};
|
use crate::{config::Config, config::PrfItem, core::*, utils::init, utils::server};
|
||||||
use crate::{log_err, wrap_err, AppHandleManager};
|
use crate::{log_err, wrap_err};
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use crate::AppHandleManager;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use percent_encoding::percent_decode_str;
|
use percent_encoding::percent_decode_str;
|
||||||
@ -133,6 +135,7 @@ pub fn create_window() {
|
|||||||
log::info!(target: "app", "Starting to create window");
|
log::info!(target: "app", "Starting to create window");
|
||||||
|
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
AppHandleManager::global().set_activation_policy_regular();
|
AppHandleManager::global().set_activation_policy_regular();
|
||||||
|
|
||||||
if let Some(window) = handle::Handle::global().get_window() {
|
if let Some(window) = handle::Handle::global().get_window() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user