Skip to content

Commit

Permalink
chore: rename clash-meta to mihomo
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Dec 12, 2023
1 parent 6215531 commit 072b3f6
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 17 deletions.
50 changes: 50 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ parking_lot = "0.12.0"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
tauri = { version = "1.5.3", features = [
tauri = { version = "1.5.3", features = [ "os-all",
"global-shortcut-all",
"notification-all",
"process-all",
Expand Down
6 changes: 3 additions & 3 deletions backend/tauri/src/config/verge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
pub enum ClashCore {
#[serde(rename = "clash-premium", alias = "clash")]
#[serde(rename = "clash", alias = "clash-premium")]
ClashPremium,
#[serde(rename = "clash-rs")]
ClashRs,
Expand All @@ -27,7 +27,7 @@ impl Default for ClashCore {
impl From<ClashCore> for String {
fn from(core: ClashCore) -> Self {
match core {
ClashCore::ClashPremium => "clash-premium".into(),
ClashCore::ClashPremium => "clash".into(),
ClashCore::ClashRs => "clash-rs".into(),
ClashCore::Mihomo => "mihomo".into(),
ClashCore::MihomoAlpha => "mihomo-alpha".into(),
Expand All @@ -38,7 +38,7 @@ impl From<ClashCore> for String {
impl std::fmt::Display for ClashCore {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ClashCore::ClashPremium => write!(f, "clash-premium"),
ClashCore::ClashPremium => write!(f, "clash"),
ClashCore::ClashRs => write!(f, "clash-rs"),
ClashCore::Mihomo => write!(f, "mihomo"),
ClashCore::MihomoAlpha => write!(f, "mihomo-alpha"),
Expand Down
6 changes: 3 additions & 3 deletions backend/tauri/src/core/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ impl CoreManager {
let config_path = dirs::path_to_str(&config_path)?;

let clash_core = { Config::verge().latest().clash_core.clone() };
let clash_core = clash_core.unwrap_or(ClashCore::ClashPremium);
let clash_core = clash_core.unwrap_or(ClashCore::ClashPremium).to_string();

let app_dir = dirs::app_home_dir()?;
let app_dir = dirs::path_to_str(&app_dir)?;

log::debug!(target: "app", "check config in `{clash_core}`");
let output = Command::new_sidecar(clash_core)?
.args(["-t", "-d", app_dir, "-f", config_path])
.output()?;

if !output.status.success() {
let error = clash_api::parse_check_output(output.stdout.clone());
let error = match error.len() > 0 {
let error = match !error.is_empty() {
true => error,
false => output.stdout.clone(),
};
Expand Down
1 change: 1 addition & 0 deletions backend/tauri/src/utils/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ pub fn save_window_state(app_handle: &AppHandle, save_to_file: bool) -> Result<(
// TODO: use enum instead
pub fn resolve_core_version(core_type: &ClashCore) -> Result<String> {
let core = core_type.clone().to_string();
log::debug!(target: "app", "check config in `{core}`");
let cmd = match core_type {
ClashCore::ClashPremium | ClashCore::Mihomo | ClashCore::MihomoAlpha => {
Command::new_sidecar(core)?.args(["-v"])
Expand Down
19 changes: 15 additions & 4 deletions backend/tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@
"icons/icon-new.icns",
"icons/icon.ico"
],
"resources": ["resources"],
"resources": [
"resources"
],
"externalBin": [
"sidecar/clash",
"sidecar/clash-meta",
"sidecar/mihomo",
"sidecar/clash-rs"
],
"copyright": "© 2022 zzzgydi All Rights Reserved",
"category": "DeveloperTool",
"shortDescription": "Clash Nyanpasu! (∠・ω< )⌒☆",
"longDescription": "Clash Nyanpasu! (∠・ω< )⌒☆",
"deb": {
"depends": ["openssl"]
"depends": [
"openssl"
]
},
"macOS": {
"frameworks": [],
Expand All @@ -50,7 +54,11 @@
"digestAlgorithm": "sha256",
"timestampUrl": "",
"wix": {
"language": ["zh-CN", "en-US", "ru-RU"]
"language": [
"zh-CN",
"en-US",
"ru-RU"
]
}
}
},
Expand Down Expand Up @@ -79,6 +87,9 @@
},
"notification": {
"all": true
},
"os": {
"all": true
}
},
"windows": [],
Expand Down
6 changes: 3 additions & 3 deletions scripts/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function clashMeta(): BinInfo {
const tmpFile = `${name}-${META_VERSION}.${urlExt}`;

return {
name: "clash-meta",
targetFile: `clash-meta-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
name: "mihomo",
targetFile: `mihomo-${SIDECAR_HOST}${isWin ? ".exe" : ""}`,
exeFile,
tmpFile,
downloadURL,
Expand Down Expand Up @@ -418,7 +418,7 @@ const resolveEnableLoopback = () =>
const tasks = [
{ name: "clash", func: () => resolveClash(), retry: 5 },
{
name: "clash-meta",
name: "mihomo",
func: () => getLatestVersion().then(() => resolveSidecar(clashMeta())),
retry: 5,
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/portable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function resolvePortable() {

zip.addLocalFile(path.join(releaseDir, "Clash Nyanpasu.exe"));
zip.addLocalFile(path.join(releaseDir, "clash.exe"));
zip.addLocalFile(path.join(releaseDir, "clash-meta.exe"));
zip.addLocalFile(path.join(releaseDir, "mihomo.exe"));
zip.addLocalFile(path.join(releaseDir, "clash-rs.exe"));
zip.addLocalFolder(path.join(releaseDir, "resources"), "resources");

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/layout-traffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const LayoutTraffic = () => {
}, [clashInfo, pageVisible]);

/* --------- meta memory information --------- */
const isMetaCore = verge?.clash_core === "clash-meta";
const isMetaCore = verge?.clash_core === "mihomo";
const displayMemory = isMetaCore && (verge?.enable_memory_usage ?? true);

const memoryWs = useWebsocket(
Expand Down
2 changes: 1 addition & 1 deletion src/services/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ interface IProfilesConfig {
interface IVergeConfig {
app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
language?: string;
clash_core?: string;
clash_core?: "mihomo" | "mihomo-alpha" | "clash-rs" | "clash";
theme_mode?: "light" | "dark" | "system";
theme_blur?: boolean;
traffic_graph?: boolean;
Expand Down

0 comments on commit 072b3f6

Please sign in to comment.