mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-30 09:50:04 +08:00
chore: update i18n
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use super::CmdResult;
|
||||
use super::{CmdResult, WithErrorCode as _, coded_error};
|
||||
use crate::feat;
|
||||
use crate::utils::{dirs, yaml_emitter};
|
||||
use crate::{
|
||||
@@ -32,7 +32,9 @@ pub async fn get_clash_info() -> CmdResult<ClashInfo> {
|
||||
/// 修改Clash配置
|
||||
#[tauri::command]
|
||||
pub async fn patch_clash_config(payload: Mapping) -> CmdResult {
|
||||
feat::patch_clash(&payload).await.stringify_err()
|
||||
feat::patch_clash(&payload)
|
||||
.await
|
||||
.with_error_code("CLASH_CONFIG_UPDATE_FAILED")
|
||||
}
|
||||
|
||||
/// 修改Clash模式
|
||||
@@ -41,7 +43,9 @@ pub async fn patch_clash_config(payload: Mapping) -> CmdResult {
|
||||
/// 并提示用户(此前命令始终返回 `Ok(())`,吞掉了后端错误)。
|
||||
#[tauri::command]
|
||||
pub async fn patch_clash_mode(payload: String) -> CmdResult {
|
||||
feat::change_clash_mode(payload).await
|
||||
feat::change_clash_mode(payload)
|
||||
.await
|
||||
.with_error_code("CLASH_MODE_UPDATE_FAILED")
|
||||
}
|
||||
|
||||
/// 获取当前 Clash 模式(容错读取)
|
||||
@@ -74,7 +78,7 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
||||
let error_msg: String = format!("Core changed but failed to restart: {err}").into();
|
||||
handle::Handle::notice_message("config_core::change_error", error_msg.clone());
|
||||
logging!(error, Type::Core, "{error_msg}");
|
||||
Ok(Some(error_msg))
|
||||
Ok(Some(coded_error("CORE_CHANGE_FAILED", error_msg)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +86,7 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
||||
let error_msg: String = err;
|
||||
logging!(error, Type::Core, "failed to change core: {error_msg}");
|
||||
handle::Handle::notice_message("config_core::change_error", error_msg.clone());
|
||||
Ok(Some(error_msg))
|
||||
Ok(Some(coded_error("CORE_CHANGE_FAILED", error_msg)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +94,10 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<String>>
|
||||
/// 启动核心
|
||||
#[tauri::command]
|
||||
pub async fn start_core() -> CmdResult {
|
||||
let result = CoreManager::global().start_core().await.stringify_err();
|
||||
let result = CoreManager::global()
|
||||
.start_core()
|
||||
.await
|
||||
.with_error_code("CORE_START_FAILED");
|
||||
if result.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
@@ -101,7 +108,10 @@ pub async fn start_core() -> CmdResult {
|
||||
#[tauri::command]
|
||||
pub async fn stop_core() -> CmdResult {
|
||||
logging_error!(Type::Core, Config::profiles().await.data_arc().save_file().await);
|
||||
let result = CoreManager::global().stop_core().await.stringify_err();
|
||||
let result = CoreManager::global()
|
||||
.stop_core()
|
||||
.await
|
||||
.with_error_code("CORE_STOP_FAILED");
|
||||
if result.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
@@ -112,7 +122,10 @@ pub async fn stop_core() -> CmdResult {
|
||||
#[tauri::command]
|
||||
pub async fn restart_core() -> CmdResult {
|
||||
logging_error!(Type::Core, Config::profiles().await.data_arc().save_file().await);
|
||||
let result = CoreManager::global().restart_core().await.stringify_err();
|
||||
let result = CoreManager::global()
|
||||
.restart_core()
|
||||
.await
|
||||
.with_error_code("CORE_RESTART_FAILED");
|
||||
if result.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user