fix: silent start does not take effect (#3708)
* fix: light mode error * feat: optimize the logic * fix: clippy issues
This commit is contained in:
committed by
GitHub
Unverified
parent
cc39b2734e
commit
4e54b61380
@@ -54,12 +54,12 @@ pub fn auto_lightweight_mode_init() {
|
||||
let _ = app_handle.state::<Mutex<LightWeightState>>();
|
||||
let is_silent_start = { Config::verge().data().enable_silent_start }.unwrap_or(false);
|
||||
let enable_auto = { Config::verge().data().enable_auto_light_weight_mode }.unwrap_or(false);
|
||||
if enable_auto && is_silent_start {
|
||||
if enable_auto && !is_silent_start {
|
||||
logging!(
|
||||
info,
|
||||
Type::Lightweight,
|
||||
true,
|
||||
"Add timer listener when creating window in silent start mode"
|
||||
"Add timer listener when creating window normally"
|
||||
);
|
||||
set_lightweight_mode(true);
|
||||
enable_auto_light_weight_mode();
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
use std::sync::Once;
|
||||
use std::sync::{Arc, Once, OnceLock};
|
||||
|
||||
use crate::{logging, utils::logging::Type};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LightWeightState {
|
||||
#[allow(unused)]
|
||||
once: Once,
|
||||
once: Arc<Once>,
|
||||
pub is_lightweight: bool,
|
||||
}
|
||||
|
||||
impl LightWeightState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
once: Once::new(),
|
||||
once: Arc::new(Once::new()),
|
||||
is_lightweight: false,
|
||||
}
|
||||
}
|
||||
@@ -37,6 +38,7 @@ impl LightWeightState {
|
||||
|
||||
impl Default for LightWeightState {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
static INSTANCE: OnceLock<LightWeightState> = OnceLock::new();
|
||||
INSTANCE.get_or_init(LightWeightState::new).clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,17 @@ pub fn create_window(is_show: bool) -> bool {
|
||||
is_show
|
||||
);
|
||||
|
||||
if !is_show {
|
||||
logging!(
|
||||
info,
|
||||
Type::Window,
|
||||
true,
|
||||
"Not to create window when starting in silent mode"
|
||||
);
|
||||
handle::Handle::notify_startup_completed();
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(app_handle) = handle::Handle::global().app_handle() {
|
||||
if let Some(window) = app_handle.get_webview_window("main") {
|
||||
logging!(info, Type::Window, true, "主窗口已存在,将显示现有窗口");
|
||||
|
||||
Reference in New Issue
Block a user