fix: resolve lightweight mode state detection issues and improve logging #3814
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
use std::sync::{Arc, Once, OnceLock};
|
||||
|
||||
use crate::{logging, utils::logging::Type};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LightWeightState {
|
||||
#[allow(unused)]
|
||||
once: Arc<Once>,
|
||||
pub is_lightweight: bool,
|
||||
}
|
||||
|
||||
impl LightWeightState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
once: Arc::new(Once::new()),
|
||||
is_lightweight: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_lightweight_mode(&mut self, value: bool) -> &Self {
|
||||
self.is_lightweight = value;
|
||||
if value {
|
||||
logging!(info, Type::Lightweight, true, "轻量模式已开启");
|
||||
} else {
|
||||
logging!(info, Type::Lightweight, true, "轻量模式已关闭");
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LightWeightState {
|
||||
fn default() -> Self {
|
||||
static INSTANCE: OnceLock<LightWeightState> = OnceLock::new();
|
||||
INSTANCE.get_or_init(LightWeightState::new).clone()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// Tauri Manager 会进行 Arc 管理,无需额外 Arc
|
||||
// https://tauri.app/develop/state-management/#do-you-need-arc
|
||||
|
||||
pub mod lightweight;
|
||||
pub mod proxy;
|
||||
|
||||
Reference in New Issue
Block a user