renamed to koala clash

This commit is contained in:
coolcoala
2025-08-05 17:51:26 +03:00
parent 7be3cdeb65
commit e32e83d45e
36 changed files with 286 additions and 276 deletions

View File

@@ -129,7 +129,7 @@ impl IClashTemp {
help::save_yaml(
&dirs::clash_path()?,
&self.0,
Some("# Generated by Clash Verge"),
Some("# Generated by Koala Clash"),
)
}

View File

@@ -11,8 +11,8 @@ use once_cell::sync::OnceCell;
use std::path::PathBuf;
use tokio::time::{sleep, Duration};
pub const RUNTIME_CONFIG: &str = "clash-verge.yaml";
pub const CHECK_CONFIG: &str = "clash-verge-check.yaml";
pub const RUNTIME_CONFIG: &str = "koala-clash.yaml";
pub const CHECK_CONFIG: &str = "koala-clash-check.yaml";
pub struct Config {
clash_config: Draft<Box<IClashTemp>>,
@@ -141,7 +141,7 @@ impl Config {
.as_ref()
.ok_or(anyhow!("failed to get runtime config"))?;
help::save_yaml(&path, &config, Some("# Generated by Clash Verge"))?;
help::save_yaml(&path, &config, Some("# Generated by Koala Clash"))?;
Ok(path)
}

View File

@@ -4,11 +4,11 @@ use crate::utils::{
tmpl,
};
use anyhow::{bail, Context, Result};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use serde_yaml::Mapping;
use std::{fs, time::Duration};
use base64::{engine::general_purpose::STANDARD, Engine as _};
use url::Url;
use super::Config;
@@ -407,7 +407,8 @@ impl PrfItem {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
if let Some(b64_data) = str_value.strip_prefix("base64:") {
STANDARD.decode(b64_data)
STANDARD
.decode(b64_data)
.ok()
.and_then(|bytes| String::from_utf8(bytes).ok())
} else {
@@ -423,7 +424,7 @@ impl PrfItem {
bail!(announce_msg.clone());
}
}
let announce_url = match header.get("announce-url") {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
@@ -436,7 +437,8 @@ impl PrfItem {
Some(value) => {
let str_value = value.to_str().unwrap_or("");
if let Some(b64_data) = str_value.strip_prefix("base64:") {
STANDARD.decode(b64_data)
STANDARD
.decode(b64_data)
.ok()
.and_then(|bytes| String::from_utf8(bytes).ok())
} else {
@@ -448,7 +450,9 @@ impl PrfItem {
let uid = help::get_uid("R");
let file = format!("{uid}.yaml");
let name = name.or(profile_title).unwrap_or(filename.unwrap_or("Remote File".into()));
let name = name
.or(profile_title)
.unwrap_or(filename.unwrap_or("Remote File".into()));
let data = resp.text_with_charset("utf-8").await?;
// process the charset "UTF-8 with BOM"

View File

@@ -66,7 +66,7 @@ impl IProfiles {
help::save_yaml(
&dirs::profiles_path()?,
self,
Some("# Profiles Config for Clash Verge"),
Some("# Profiles Config for Koala Clash"),
)
}

View File

@@ -238,7 +238,7 @@ pub struct IVergeTheme {
impl IVerge {
/// 有效的clash核心名称
pub const VALID_CLASH_CORES: &'static [&'static str] = &["verge-mihomo", "verge-mihomo-alpha"];
pub const VALID_CLASH_CORES: &'static [&'static str] = &["koala-mihomo", "koala-mihomo-alpha"];
/// 验证并修正配置文件中的clash_core值
pub fn validate_and_fix_config() -> Result<()> {
@@ -257,10 +257,10 @@ impl IVerge {
warn,
Type::Config,
true,
"启动时发现无效的clash_core配置: '{}', 将自动修正为 'verge-mihomo'",
"启动时发现无效的clash_core配置: '{}', 将自动修正为 'koala-mihomo'",
core
);
config.clash_core = Some("verge-mihomo".to_string());
config.clash_core = Some("koala-mihomo".to_string());
needs_fix = true;
}
} else {
@@ -268,16 +268,16 @@ impl IVerge {
info,
Type::Config,
true,
"启动时发现未配置clash_core, 将设置为默认值 'verge-mihomo'"
"启动时发现未配置clash_core, 将设置为默认值 'koala-mihomo'"
);
config.clash_core = Some("verge-mihomo".to_string());
config.clash_core = Some("koala-mihomo".to_string());
needs_fix = true;
}
// 修正后保存配置
if needs_fix {
logging!(info, Type::Config, true, "正在保存修正后的配置文件...");
help::save_yaml(&config_path, &config, Some("# Clash Verge Config"))?;
help::save_yaml(&config_path, &config, Some("# Koala Clash Config"))?;
logging!(
info,
Type::Config,
@@ -321,7 +321,7 @@ impl IVerge {
pub fn get_valid_clash_core(&self) -> String {
self.clash_core
.clone()
.unwrap_or_else(|| "verge-mihomo".to_string())
.unwrap_or_else(|| "koala-mihomo".to_string())
}
fn get_system_language() -> String {
@@ -340,18 +340,15 @@ impl IVerge {
}
pub fn new() -> Self {
match dirs::verge_path().and_then(|path| help::read_yaml::<IVerge>(&path)) {
Ok(config) => config,
Err(err) => {
log::error!(target: "app", "{err}");
Self::template()
}
}
dirs::verge_path().and_then(|path| help::read_yaml::<IVerge>(&path)).unwrap_or_else(|err| {
log::error!(target: "app", "{err}");
Self::template()
})
}
pub fn template() -> Self {
Self {
clash_core: Some("verge-mihomo".into()),
clash_core: Some("koala-mihomo".into()),
language: Some(Self::get_system_language()),
theme_mode: Some("system".into()),
#[cfg(not(target_os = "windows"))]
@@ -415,7 +412,7 @@ impl IVerge {
/// Save IVerge App Config
pub fn save_file(&self) -> Result<()> {
help::save_yaml(&dirs::verge_path()?, &self, Some("# Clash Verge Config"))
help::save_yaml(&dirs::verge_path()?, &self, Some("# Koala Clash Config"))
}
/// patch verge config