mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 02:12:10 +08:00
chore: trim excessive comments
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// #[cfg(not(feature = "tracing"))]
|
||||
use crate::{
|
||||
config::{Config, IClashTemp, IProfiles, IVerge},
|
||||
constants,
|
||||
@@ -43,7 +42,6 @@ async fn delete_snapshot_logs(log_dir: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
// TODO flexi_logger 提供了最大保留天数,或许我们应该用内置删除log文件
|
||||
/// 删除log文件
|
||||
pub async fn delete_log() -> Result<()> {
|
||||
let log_dir = dirs::app_logs_dir()?;
|
||||
let service_log_dir = dirs::service_log_dir()?;
|
||||
@@ -63,7 +61,6 @@ pub async fn delete_log() -> Result<()> {
|
||||
verge.auto_log_clean.unwrap_or(0)
|
||||
};
|
||||
|
||||
// 1: 1天, 2: 7天, 3: 30天, 4: 90天
|
||||
let day = match auto_log_clean {
|
||||
1 => 1,
|
||||
2 => 7,
|
||||
@@ -74,7 +71,6 @@ pub async fn delete_log() -> Result<()> {
|
||||
|
||||
logging!(info, Type::Setup, "try to delete log files, day: {}", day);
|
||||
|
||||
// %Y-%m-%d to NaiveDateTime
|
||||
let parse_time_str = |s: &str| {
|
||||
let sa: Vec<&str> = s.split('-').collect();
|
||||
if sa.len() != 4 {
|
||||
@@ -320,14 +316,12 @@ async fn migrate_legacy_macos_logs() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 初始化DNS配置文件
|
||||
pub(super) async fn init_dns_config() -> Result<()> {
|
||||
use serde_yaml_ng::Value;
|
||||
|
||||
// 创建DNS子配置
|
||||
let dns_config = serde_yaml_ng::Mapping::from_iter([
|
||||
("enable".into(), Value::Bool(true)),
|
||||
// 与前端 DNS 默认一致,并供 dns.ipv6 锁定使用
|
||||
// Must match the frontend default used for authoritative `dns.ipv6`.
|
||||
("ipv6".into(), Value::Bool(true)),
|
||||
("listen".into(), Value::String(":53".into())),
|
||||
("enhanced-mode".into(), Value::String("fake-ip".into())),
|
||||
@@ -410,13 +404,11 @@ pub(super) async fn init_dns_config() -> Result<()> {
|
||||
),
|
||||
]);
|
||||
|
||||
// 获取默认DNS和host配置
|
||||
let default_dns_config = serde_yaml_ng::Mapping::from_iter([
|
||||
("dns".into(), Value::Mapping(dns_config)),
|
||||
("hosts".into(), Value::Mapping(serde_yaml_ng::Mapping::new())),
|
||||
]);
|
||||
|
||||
// 检查DNS配置文件是否存在
|
||||
let app_dir = dirs::app_home_dir()?;
|
||||
let dns_path = app_dir.join(constants::files::DNS_CONFIG);
|
||||
|
||||
@@ -428,7 +420,6 @@ pub(super) async fn init_dns_config() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 确保目录结构存在
|
||||
async fn ensure_directories() -> Result<()> {
|
||||
let directories = [
|
||||
("app_home", dirs::app_home_dir()?),
|
||||
@@ -449,7 +440,6 @@ async fn ensure_directories() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 初始化配置文件
|
||||
async fn initialize_config_files() -> Result<()> {
|
||||
if let Ok(path) = dirs::clash_path()
|
||||
&& !path.exists()
|
||||
@@ -481,7 +471,6 @@ async fn initialize_config_files() -> Result<()> {
|
||||
logging!(info, Type::Setup, "Created profiles config at {:?}", path);
|
||||
}
|
||||
|
||||
// 验证并修正verge配置
|
||||
IVerge::validate_and_fix_config()
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("Failed to validate verge config: {}", e))?;
|
||||
@@ -489,14 +478,8 @@ async fn initialize_config_files() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Initialize all the config files
|
||||
/// before tauri setup
|
||||
/// Initializes configuration required before Tauri setup.
|
||||
pub async fn init_config() -> Result<()> {
|
||||
// We do not need init_portable_flag here anymore due to lib.rs will to the things
|
||||
// let _ = dirs::init_portable_flag();
|
||||
|
||||
// We do not need init_log here anymore due to resolve will to the things
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
migrate_legacy_macos_logs().await?;
|
||||
|
||||
@@ -514,8 +497,7 @@ pub async fn init_config() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// initialize app resources
|
||||
/// after tauri setup
|
||||
/// Initializes application resources after Tauri setup.
|
||||
pub async fn init_resources() -> Result<()> {
|
||||
let app_dir = dirs::app_home_dir()?;
|
||||
let res_dir = dirs::app_resources_dir()?;
|
||||
@@ -529,8 +511,6 @@ pub async fn init_resources() -> Result<()> {
|
||||
|
||||
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
|
||||
|
||||
// copy the resource file
|
||||
// if the source file is newer than the destination file, copy it over
|
||||
for file in file_list.iter() {
|
||||
let src_path = res_dir.join(file);
|
||||
let dest_path = app_dir.join(file);
|
||||
@@ -559,7 +539,6 @@ pub async fn init_resources() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// initialize url scheme
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn init_scheme() -> Result<()> {
|
||||
use tauri::utils::platform::current_exe;
|
||||
|
||||
Reference in New Issue
Block a user