feat: implement draft management system for concurrent editing and committing of data

This commit is contained in:
Tunglies
2025-10-15 08:32:30 +08:00
parent 6113be3b6c
commit e6b7d512fb
9 changed files with 127 additions and 68 deletions

View File

@@ -1,9 +1,9 @@
use super::{Draft, IClashTemp, IProfiles, IRuntime, IVerge};
use super::{IClashTemp, IProfiles, IRuntime, IVerge};
use crate::{
config::{PrfItem, profiles_append_item_safe},
core::{CoreManager, handle},
enhance, logging,
utils::{dirs, help, logging::Type},
utils::{Draft, dirs, help, logging::Type},
};
use anyhow::{Result, anyhow};
use backoff::{Error as BackoffError, ExponentialBackoff};

View File

@@ -1,16 +1,13 @@
mod clash;
#[allow(clippy::module_inception)]
mod config;
mod draft;
mod encrypt;
mod prfitem;
pub mod profiles;
mod runtime;
mod verge;
pub use self::{
clash::*, config::*, draft::*, encrypt::*, prfitem::*, profiles::*, runtime::*, verge::*,
};
pub use self::{clash::*, config::*, encrypt::*, prfitem::*, profiles::*, runtime::*, verge::*};
pub const DEFAULT_PAC: &str = r#"function FindProxyForURL(url, host) {
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;";

View File

@@ -8,7 +8,7 @@ mod enhance;
mod feat;
mod module;
mod process;
mod utils;
pub mod utils;
#[cfg(target_os = "macos")]
use crate::utils::window_manager::WindowManager;
use crate::{

View File

@@ -109,7 +109,7 @@ impl<T: Clone + ToOwned> Draft<Box<T>> {
#[test]
fn test_draft_box() {
use super::IVerge;
use crate::config::IVerge;
// 1. 创建 Draft<Box<IVerge>>
let verge = Box::new(IVerge {

View File

@@ -1,5 +1,6 @@
pub mod autostart;
pub mod dirs;
pub mod draft;
pub mod format;
pub mod help;
pub mod i18n;
@@ -12,3 +13,5 @@ pub mod server;
pub mod singleton;
pub mod tmpl;
pub mod window_manager;
pub use draft::Draft;

View File

@@ -61,6 +61,12 @@ pub struct NetworkManager {
connection_error_count: Mutex<usize>,
}
impl Default for NetworkManager {
fn default() -> Self {
Self::new()
}
}
impl NetworkManager {
pub fn new() -> Self {
Self {