mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:53:44 +08:00
perf: Improve config validation error messages and handling
This commit is contained in:
parent
bc5d577553
commit
7a0e38a1b4
@ -13,7 +13,6 @@ use sysproxy::{Autoproxy, Sysproxy};
|
|||||||
type CmdResult<T = ()> = Result<T, String>;
|
type CmdResult<T = ()> = Result<T, String>;
|
||||||
use reqwest_dav::list_cmd::ListFile;
|
use reqwest_dav::list_cmd::ListFile;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_shell::ShellExt;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -30,10 +29,24 @@ pub fn get_profiles() -> CmdResult<IProfiles> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn enhance_profiles() -> CmdResult {
|
pub async fn enhance_profiles() -> CmdResult {
|
||||||
wrap_err!(CoreManager::global().update_config().await)?;
|
match CoreManager::global().update_config().await {
|
||||||
log_err!(tray::Tray::global().update_tooltip());
|
Ok((true, _)) => {
|
||||||
handle::Handle::refresh_clash();
|
println!("[enhance_profiles] 配置更新成功");
|
||||||
Ok(())
|
log_err!(tray::Tray::global().update_tooltip());
|
||||||
|
handle::Handle::refresh_clash();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Ok((false, error_msg)) => {
|
||||||
|
println!("[enhance_profiles] 配置验证失败: {}", error_msg);
|
||||||
|
handle::Handle::notice_message("config_validate::error", &error_msg);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("[enhance_profiles] 更新过程发生错误: {}", e);
|
||||||
|
handle::Handle::notice_message("config_validate::process_terminated", &e.to_string());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -72,7 +85,7 @@ pub async fn delete_profile(index: String) -> CmdResult {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn patch_profiles_config(
|
pub async fn patch_profiles_config(
|
||||||
profiles: IProfiles
|
profiles: IProfiles
|
||||||
) -> CmdResult {
|
) -> CmdResult<bool> {
|
||||||
println!("[cmd配置patch] 开始修改配置文件");
|
println!("[cmd配置patch] 开始修改配置文件");
|
||||||
|
|
||||||
// 保存当前配置,以便在验证失败时恢复
|
// 保存当前配置,以便在验证失败时恢复
|
||||||
@ -85,21 +98,17 @@ pub async fn patch_profiles_config(
|
|||||||
|
|
||||||
// 更新配置并进行验证
|
// 更新配置并进行验证
|
||||||
match CoreManager::global().update_config().await {
|
match CoreManager::global().update_config().await {
|
||||||
Ok(_) => {
|
Ok((true, _)) => {
|
||||||
println!("[cmd配置patch] 配置更新成功");
|
println!("[cmd配置patch] 配置更新成功");
|
||||||
handle::Handle::refresh_clash();
|
handle::Handle::refresh_clash();
|
||||||
let _ = tray::Tray::global().update_tooltip();
|
let _ = tray::Tray::global().update_tooltip();
|
||||||
Config::profiles().apply();
|
Config::profiles().apply();
|
||||||
wrap_err!(Config::profiles().data().save_file())?;
|
wrap_err!(Config::profiles().data().save_file())?;
|
||||||
|
Ok(true)
|
||||||
// 发送成功通知
|
|
||||||
handle::Handle::notice_message("operation_success", "配置patch成功");
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Ok((false, error_msg)) => {
|
||||||
println!("[cmd配置patch] 更新配置失败: {}", err);
|
println!("[cmd配置patch] 配置验证失败: {}", error_msg);
|
||||||
Config::profiles().discard();
|
Config::profiles().discard();
|
||||||
println!("[cmd配置patch] 错误详情: {}", err);
|
|
||||||
|
|
||||||
// 如果验证失败,恢复到之前的配置
|
// 如果验证失败,恢复到之前的配置
|
||||||
if let Some(prev_profile) = current_profile {
|
if let Some(prev_profile) = current_profile {
|
||||||
@ -115,7 +124,15 @@ pub async fn patch_profiles_config(
|
|||||||
println!("[cmd配置patch] 成功恢复到之前的配置");
|
println!("[cmd配置patch] 成功恢复到之前的配置");
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(err.to_string())
|
// 发送验证错误通知
|
||||||
|
handle::Handle::notice_message("config_validate::error", &error_msg);
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("[cmd配置patch] 更新过程发生错误: {}", e);
|
||||||
|
Config::profiles().discard();
|
||||||
|
handle::Handle::notice_message("config_validate::boot_error", &e.to_string());
|
||||||
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +142,7 @@ pub async fn patch_profiles_config(
|
|||||||
pub async fn patch_profiles_config_by_profile_index(
|
pub async fn patch_profiles_config_by_profile_index(
|
||||||
_app_handle: tauri::AppHandle,
|
_app_handle: tauri::AppHandle,
|
||||||
profile_index: String
|
profile_index: String
|
||||||
) -> CmdResult {
|
) -> CmdResult<bool> {
|
||||||
let profiles = IProfiles{current: Some(profile_index), items: None};
|
let profiles = IProfiles{current: Some(profile_index), items: None};
|
||||||
patch_profiles_config(profiles).await
|
patch_profiles_config(profiles).await
|
||||||
}
|
}
|
||||||
@ -183,39 +200,29 @@ pub async fn save_profile_file(index: String, file_data: Option<String>) -> CmdR
|
|||||||
// 保存新的配置文件
|
// 保存新的配置文件
|
||||||
wrap_err!(fs::write(&file_path, file_data.clone().unwrap()))?;
|
wrap_err!(fs::write(&file_path, file_data.clone().unwrap()))?;
|
||||||
|
|
||||||
// 直接验证保存的配置文件
|
|
||||||
let clash_core = Config::verge().latest().clash_core.clone().unwrap_or("verge-mihomo".into());
|
|
||||||
let test_dir = wrap_err!(dirs::app_home_dir())?.join("test");
|
|
||||||
let test_dir = test_dir.to_string_lossy();
|
|
||||||
let file_path_str = file_path.to_string_lossy();
|
let file_path_str = file_path.to_string_lossy();
|
||||||
|
|
||||||
println!("[cmd配置save] 开始验证配置文件: {}", file_path_str);
|
println!("[cmd配置save] 开始验证配置文件: {}", file_path_str);
|
||||||
|
|
||||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
// 验证配置文件
|
||||||
let output = wrap_err!(app_handle
|
match CoreManager::global().validate_config_file(&file_path_str).await {
|
||||||
.shell()
|
Ok((true, _)) => {
|
||||||
.sidecar(clash_core)
|
println!("[cmd配置save] 验证成功");
|
||||||
.map_err(|e| e.to_string())?
|
Ok(())
|
||||||
.args(["-t", "-d", test_dir.as_ref(), "-f", file_path_str.as_ref()])
|
}
|
||||||
.output()
|
Ok((false, error_msg)) => {
|
||||||
.await)?;
|
println!("[cmd配置save] 验证失败: {}", error_msg);
|
||||||
|
// 恢复原始配置文件
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
let error_keywords = ["FATA", "fatal", "Parse config error", "level=fatal"];
|
handle::Handle::notice_message("config_validate::error", &error_msg.to_string()); // 保存文件弹出此提示
|
||||||
let has_error = !output.status.success() || error_keywords.iter().any(|&kw| stderr.contains(kw));
|
Ok(())
|
||||||
|
}
|
||||||
if has_error {
|
Err(e) => {
|
||||||
println!("[cmd配置save] 编辑验证失败 {}", stderr);
|
println!("[cmd配置save] 验证过程发生错误: {}", e);
|
||||||
// 恢复原始配置文件
|
// 恢复原始配置文件
|
||||||
wrap_err!(fs::write(&file_path, original_content))?;
|
wrap_err!(fs::write(&file_path, original_content))?;
|
||||||
// 发送错误通知
|
Err(e.to_string())
|
||||||
handle::Handle::notice_message("config_validate::error", &*stderr);
|
}
|
||||||
return Err(format!("cmd配置save失败 {}", stderr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("[cmd配置save] 验证成功");
|
|
||||||
handle::Handle::notice_message("operation_success", "配置更新成功");
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
@ -80,24 +80,11 @@ impl Config {
|
|||||||
match CoreManager::global().validate_config().await {
|
match CoreManager::global().validate_config().await {
|
||||||
Ok((is_valid, error_msg)) => {
|
Ok((is_valid, error_msg)) => {
|
||||||
if !is_valid {
|
if !is_valid {
|
||||||
println!("[首次启动] 配置验证失败,使用默认最小配置启动{}", error_msg);
|
println!("[首次启动] 配置验证失败,使用默认最小配置启动: {}", error_msg);
|
||||||
if error_msg.is_empty() {
|
CoreManager::global()
|
||||||
CoreManager::global()
|
.use_default_config("config_validate::boot_error", &error_msg)
|
||||||
.use_default_config(
|
.await?;
|
||||||
"config_validate::boot_error",
|
Some(("config_validate::boot_error", error_msg))
|
||||||
"",
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Some(("config_validate::boot_error", String::new()))
|
|
||||||
} else {
|
|
||||||
CoreManager::global()
|
|
||||||
.use_default_config(
|
|
||||||
"config_validate::stderr_error",
|
|
||||||
&error_msg,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Some(("config_validate::stderr_error", error_msg))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
println!("[首次启动] 配置验证成功");
|
println!("[首次启动] 配置验证成功");
|
||||||
Some(("config_validate::success", String::new()))
|
Some(("config_validate::success", String::new()))
|
||||||
@ -106,10 +93,7 @@ impl Config {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("[首次启动] 验证进程执行失败: {}", err);
|
println!("[首次启动] 验证进程执行失败: {}", err);
|
||||||
CoreManager::global()
|
CoreManager::global()
|
||||||
.use_default_config(
|
.use_default_config("config_validate::process_terminated", "")
|
||||||
"config_validate::process_terminated",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
Some(("config_validate::process_terminated", String::new()))
|
Some(("config_validate::process_terminated", String::new()))
|
||||||
}
|
}
|
||||||
|
@ -117,63 +117,64 @@ impl CoreManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log::info!(target: "app", "change core to `{clash_core}`");
|
log::info!(target: "app", "change core to `{clash_core}`");
|
||||||
|
|
||||||
|
// 1. 先更新内核配置(但不应用)
|
||||||
Config::verge().draft().clash_core = Some(clash_core);
|
Config::verge().draft().clash_core = Some(clash_core);
|
||||||
Config::generate().await?;
|
|
||||||
|
// 2. 使用新内核验证配置
|
||||||
// 验证配置
|
println!("[切换内核] 使用新内核验证配置");
|
||||||
println!("[切换内核] 开始验证配置");
|
|
||||||
match self.validate_config().await {
|
match self.validate_config().await {
|
||||||
Ok((is_valid, error_msg)) => {
|
Ok((true, _)) => {
|
||||||
if !is_valid {
|
println!("[切换内核] 配置验证通过,开始切换内核");
|
||||||
println!("[切换内核] 配置验证失败: {}", error_msg);
|
// 3. 验证通过后,应用内核配置并重启
|
||||||
if error_msg.is_empty() {
|
Config::verge().apply();
|
||||||
self.use_default_config(
|
log_err!(Config::verge().latest().save_file());
|
||||||
"config_validate::core_change",
|
|
||||||
"",
|
match self.restart_core().await {
|
||||||
).await?;
|
Ok(_) => {
|
||||||
} else {
|
println!("[切换内核] 内核切换成功");
|
||||||
self.use_default_config(
|
Config::runtime().apply();
|
||||||
"config_validate::stderr_error",
|
Ok(())
|
||||||
&error_msg,
|
}
|
||||||
).await?;
|
Err(err) => {
|
||||||
|
println!("[切换内核] 内核切换失败: {}", err);
|
||||||
|
Config::verge().discard();
|
||||||
|
Config::runtime().discard();
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok((false, error_msg)) => {
|
||||||
|
println!("[切换内核] 配置验证失败: {}", error_msg);
|
||||||
|
// 使用默认配置并继续切换内核
|
||||||
|
self.use_default_config("config_validate::core_change", &error_msg).await?;
|
||||||
|
Config::verge().apply();
|
||||||
|
log_err!(Config::verge().latest().save_file());
|
||||||
|
|
||||||
|
match self.restart_core().await {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("[切换内核] 内核切换成功(使用默认配置)");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("[切换内核] 内核切换失败: {}", err);
|
||||||
|
Config::verge().discard();
|
||||||
|
Err(err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
println!("[切换内核] 配置验证成功");
|
|
||||||
handle::Handle::notice_message("config_validate::success", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("[切换内核] 验证进程执行失败: {}", err);
|
println!("[切换内核] 验证过程发生错误: {}", err);
|
||||||
self.use_default_config(
|
|
||||||
"config_validate::process_terminated",
|
|
||||||
"",
|
|
||||||
).await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.restart_core().await {
|
|
||||||
Ok(_) => {
|
|
||||||
Config::verge().apply();
|
|
||||||
Config::runtime().apply();
|
|
||||||
log_err!(Config::verge().latest().save_file());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Config::verge().discard();
|
Config::verge().discard();
|
||||||
Config::runtime().discard();
|
|
||||||
Err(err)
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 使用子进程验证配置
|
/// 内部验证配置文件的实现
|
||||||
pub async fn validate_config(&self) -> Result<(bool, String)> {
|
async fn validate_config_internal(&self, config_path: &str) -> Result<(bool, String)> {
|
||||||
println!("[core配置验证] 开始验证配置");
|
println!("[core配置验证] 开始验证配置文件: {}", config_path);
|
||||||
|
|
||||||
let config_path = Config::generate_file(ConfigType::Check)?;
|
|
||||||
let config_path = dirs::path_to_str(&config_path)?;
|
|
||||||
println!("[core配置验证] 配置文件路径: {}", config_path);
|
|
||||||
|
|
||||||
let clash_core = { Config::verge().latest().clash_core.clone() };
|
let clash_core = { Config::verge().latest().clash_core.clone() };
|
||||||
let clash_core = clash_core.unwrap_or("verge-mihomo".into());
|
let clash_core = clash_core.unwrap_or("verge-mihomo".into());
|
||||||
println!("[core配置验证] 使用内核: {}", clash_core);
|
println!("[core配置验证] 使用内核: {}", clash_core);
|
||||||
@ -199,36 +200,51 @@ impl CoreManager {
|
|||||||
let error_keywords = ["FATA", "fatal", "Parse config error", "level=fatal"];
|
let error_keywords = ["FATA", "fatal", "Parse config error", "level=fatal"];
|
||||||
let has_error = !output.status.success() || error_keywords.iter().any(|&kw| stderr.contains(kw));
|
let has_error = !output.status.success() || error_keywords.iter().any(|&kw| stderr.contains(kw));
|
||||||
|
|
||||||
println!("[core配置验证] 退出状态: {:?}", output.status);
|
println!("\n[core配置验证] -------- 验证结果 --------");
|
||||||
|
println!("[core配置验证] 进程退出状态: {:?}", output.status);
|
||||||
|
|
||||||
if !stderr.is_empty() {
|
if !stderr.is_empty() {
|
||||||
println!("[core配置验证] 错误输出: {}", stderr);
|
println!("[core配置验证] stderr输出:\n{}", stderr);
|
||||||
}
|
}
|
||||||
if !stdout.is_empty() {
|
if !stdout.is_empty() {
|
||||||
println!("[core配置验证] 标准输出: {}", stdout);
|
println!("[core配置验证] stdout输出:\n{}", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if has_error {
|
if has_error {
|
||||||
let error_msg = if stderr.is_empty() {
|
println!("[core配置验证] 发现错误,开始处理错误信息");
|
||||||
if let Some(code) = output.status.code() {
|
let error_msg = if !stdout.is_empty() {
|
||||||
handle::Handle::notice_message("config_validate::error", &code.to_string());
|
stdout.to_string()
|
||||||
String::new()
|
} else if !stderr.is_empty() {
|
||||||
} else {
|
stderr.to_string()
|
||||||
handle::Handle::notice_message("config_validate::process_terminated", "");
|
} else if let Some(code) = output.status.code() {
|
||||||
String::new()
|
format!("验证进程异常退出,退出码: {}", code)
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
handle::Handle::notice_message("config_validate::stderr_error", &*stderr);
|
"验证进程被终止".to_string()
|
||||||
String::new()
|
|
||||||
};
|
};
|
||||||
Ok((false, error_msg))
|
|
||||||
|
println!("[core配置验证] -------- 验证结束 --------\n");
|
||||||
|
Ok((false, error_msg)) // 返回错误消息给调用者处理
|
||||||
} else {
|
} else {
|
||||||
handle::Handle::notice_message("config_validate::success", "");
|
println!("[core配置验证] 验证成功");
|
||||||
|
println!("[core配置验证] -------- 验证结束 --------\n");
|
||||||
Ok((true, String::new()))
|
Ok((true, String::new()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 验证运行时配置
|
||||||
|
pub async fn validate_config(&self) -> Result<(bool, String)> {
|
||||||
|
let config_path = Config::generate_file(ConfigType::Check)?;
|
||||||
|
let config_path = dirs::path_to_str(&config_path)?;
|
||||||
|
self.validate_config_internal(config_path).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 验证指定的配置文件
|
||||||
|
pub async fn validate_config_file(&self, config_path: &str) -> Result<(bool, String)> {
|
||||||
|
self.validate_config_internal(config_path).await
|
||||||
|
}
|
||||||
|
|
||||||
/// 更新proxies等配置
|
/// 更新proxies等配置
|
||||||
pub async fn update_config(&self) -> Result<()> {
|
pub async fn update_config(&self) -> Result<(bool, String)> {
|
||||||
println!("[core配置更新] 开始更新配置");
|
println!("[core配置更新] 开始更新配置");
|
||||||
|
|
||||||
// 1. 先生成新的配置内容
|
// 1. 先生成新的配置内容
|
||||||
@ -242,48 +258,48 @@ impl CoreManager {
|
|||||||
println!("[core配置更新] 临时配置文件路径: {}", temp_config);
|
println!("[core配置更新] 临时配置文件路径: {}", temp_config);
|
||||||
|
|
||||||
// 3. 验证配置
|
// 3. 验证配置
|
||||||
let (is_valid, error_msg) = match self.validate_config().await {
|
match self.validate_config().await {
|
||||||
Ok((valid, msg)) => (valid, msg),
|
Ok((true, _)) => {
|
||||||
Err(e) => {
|
println!("[core配置更新] 配置验证通过");
|
||||||
println!("[core配置更新] 验证过程发生错误: {}", e);
|
// 4. 验证通过后,生成正式的运行时配置
|
||||||
Config::runtime().discard(); // 验证失败时丢弃新配置
|
println!("[core配置更新] 生成运行时配置");
|
||||||
return Err(e);
|
let run_path = Config::generate_file(ConfigType::Run)?;
|
||||||
}
|
let run_path = dirs::path_to_str(&run_path)?;
|
||||||
};
|
|
||||||
|
|
||||||
if !is_valid {
|
// 5. 应用新配置
|
||||||
println!("[core配置更新] 配置验证未通过,保持当前配置不变");
|
println!("[core配置更新] 应用新配置");
|
||||||
Config::runtime().discard(); // 验证失败时丢弃新配置
|
for i in 0..3 {
|
||||||
return Err(anyhow::anyhow!(error_msg));
|
match clash_api::put_configs(run_path).await {
|
||||||
}
|
Ok(_) => {
|
||||||
|
println!("[core配置更新] 配置应用成功");
|
||||||
// 4. 验证通过后,生成正式的运行时配置
|
Config::runtime().apply();
|
||||||
println!("[core配置更新] 验证通过,生成运行时配置");
|
return Ok((true, String::new()));
|
||||||
let run_path = Config::generate_file(ConfigType::Run)?;
|
}
|
||||||
let run_path = dirs::path_to_str(&run_path)?;
|
Err(err) => {
|
||||||
|
if i < 2 {
|
||||||
// 5. 应用新配置
|
println!("[core配置更新] 第{}次重试应用配置", i + 1);
|
||||||
println!("[core配置更新] 应用新配置");
|
log::info!(target: "app", "{err}");
|
||||||
for i in 0..10 {
|
sleep(Duration::from_millis(100)).await;
|
||||||
match clash_api::put_configs(run_path).await {
|
} else {
|
||||||
Ok(_) => {
|
println!("[core配置更新] 配置应用失败: {}", err);
|
||||||
println!("[core配置更新] 配置应用成功");
|
Config::runtime().discard();
|
||||||
Config::runtime().apply(); // 应用成功时保存新配置
|
return Ok((false, err.to_string()));
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
if i < 9 {
|
|
||||||
println!("[core配置更新] 第{}次重试应用配置", i + 1);
|
|
||||||
log::info!(target: "app", "{err}");
|
|
||||||
} else {
|
|
||||||
println!("[core配置更新] 配置应用失败: {}", err);
|
|
||||||
Config::runtime().discard(); // 应用失败时丢弃新配置
|
|
||||||
return Err(err.into());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok((true, String::new()))
|
||||||
|
}
|
||||||
|
Ok((false, error_msg)) => {
|
||||||
|
println!("[core配置更新] 配置验证失败: {}", error_msg);
|
||||||
|
Config::runtime().discard();
|
||||||
|
Ok((false, error_msg))
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("[core配置更新] 验证过程发生错误: {}", e);
|
||||||
|
Config::runtime().discard();
|
||||||
|
Err(e)
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(100)).await;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,8 +439,8 @@
|
|||||||
"Enable Tray Speed": "تفعيل سرعة التراي",
|
"Enable Tray Speed": "تفعيل سرعة التراي",
|
||||||
"Lite Mode": "وضع الأداء الخفيف",
|
"Lite Mode": "وضع الأداء الخفيف",
|
||||||
"Lite Mode Info": "إيقاف الواجهة الرسومية والإبقاء على تشغيل النواة",
|
"Lite Mode Info": "إيقاف الواجهة الرسومية والإبقاء على تشغيل النواة",
|
||||||
"Config Validation Failed": "فشل التحقق من تكوين الاشتراك. يرجى التحقق من ملف تكوين الاشتراك؛ تم التراجع عن التعديلات.",
|
"Config Validation Failed": "فشل التحقق من تكوين الاشتراك، يرجى فحص ملف التكوين، تم التراجع عن التغييرات، تفاصيل الخطأ:",
|
||||||
"Boot Config Validation Failed": "فشل التحقق من تكوين الاشتراك. تم البدء بالتكوين الافتراضي. يرجى التحقق من ملف تكوين الاشتراك.",
|
"Boot Config Validation Failed": "فشل التحقق من التكوين عند الإقلاع، تم استخدام التكوين الافتراضي، يرجى فحص ملف التكوين، تفاصيل الخطأ:",
|
||||||
"Core Change Config Validation Failed": "فشل التحقق من التكوين عند تغيير النواة؛ تم البدء بالتكوين الافتراضي. يرجى التحقق من ملف تكوين الاشتراك.",
|
"Core Change Config Validation Failed": "فشل التحقق من التكوين عند تغيير النواة، تم استخدام التكوين الافتراضي، يرجى فحص ملف التكوين، تفاصيل الخطأ:",
|
||||||
"Config Validation Process Terminated": "تم إنهاء عملية التحقق من التكوين."
|
"Config Validation Process Terminated": "تم إنهاء عملية التحقق"
|
||||||
}
|
}
|
||||||
|
@ -436,8 +436,8 @@
|
|||||||
"Enable Tray Speed": "فعال کردن سرعت ترای",
|
"Enable Tray Speed": "فعال کردن سرعت ترای",
|
||||||
"Lite Mode": "در فارسی",
|
"Lite Mode": "در فارسی",
|
||||||
"Lite Mode Info": "رابط کاربری گرافیکی را ببندید و فقط هسته را در حال اجرا نگه دارید",
|
"Lite Mode Info": "رابط کاربری گرافیکی را ببندید و فقط هسته را در حال اجرا نگه دارید",
|
||||||
"Config Validation Failed": "اعتبارسنجی پیکربندی اشتراک ناموفق بود. لطفاً فایل پیکربندی اشتراک را بررسی کنید؛ تغییرات به حالت قبل بازگردانده شد.",
|
"Config Validation Failed": "اعتبارسنجی پیکربندی اشتراک ناموفق بود، فایل پیکربندی را بررسی کنید، تغییرات برگشت داده شد، جزئیات خطا:",
|
||||||
"Boot Config Validation Failed": "اعتبارسنجی پیکربندی اشتراک ناموفق بود. با پیکربندی پیشفرض راهاندازی شد. لطفاً فایل پیکربندی اشتراک را بررسی کنید.",
|
"Boot Config Validation Failed": "اعتبارسنجی پیکربندی هنگام راهاندازی ناموفق بود، پیکربندی پیشفرض استفاده شد، فایل پیکربندی را بررسی کنید، جزئیات خطا:",
|
||||||
"Core Change Config Validation Failed": "اعتبارسنجی پیکربندی هنگام تغییر هسته ناموفق بود؛ با پیکربندی پیشفرض راهاندازی شد. لطفاً فایل پیکربندی اشتراک را بررسی کنید.",
|
"Core Change Config Validation Failed": "اعتبارسنجی پیکربندی هنگام تغییر هسته ناموفق بود، پیکربندی پیشفرض استفاده شد، فایل پیکربندی را بررسی کنید، جزئیات خطا:",
|
||||||
"Config Validation Process Terminated": "فرآیند اعتبارسنجی پیکربندی متوقف شد."
|
"Config Validation Process Terminated": "فرآیند اعتبارسنجی متوقف شد"
|
||||||
}
|
}
|
||||||
|
@ -435,8 +435,8 @@
|
|||||||
"Enable Tray Speed": "Aktifkan Tray Speed",
|
"Enable Tray Speed": "Aktifkan Tray Speed",
|
||||||
"Lite Mode": "Mode Ringan",
|
"Lite Mode": "Mode Ringan",
|
||||||
"Lite Mode Info": "Tutup GUI dan biarkan hanya kernel yang berjalan",
|
"Lite Mode Info": "Tutup GUI dan biarkan hanya kernel yang berjalan",
|
||||||
"Config Validation Failed": "Validasi konfigurasi langganan gagal. Silakan periksa file konfigurasi langganan; perubahan telah dikembalikan.",
|
"Config Validation Failed": "Validasi konfigurasi langganan gagal, periksa file konfigurasi, perubahan dibatalkan, detail kesalahan:",
|
||||||
"Boot Config Validation Failed": "Validasi konfigurasi langganan gagal. Memulai dengan konfigurasi default. Silakan periksa file konfigurasi langganan.",
|
"Boot Config Validation Failed": "Validasi konfigurasi saat boot gagal, menggunakan konfigurasi default, periksa file konfigurasi, detail kesalahan:",
|
||||||
"Core Change Config Validation Failed": "Validasi konfigurasi gagal saat beralih kernel; memulai dengan konfigurasi default. Silakan periksa file konfigurasi langganan.",
|
"Core Change Config Validation Failed": "Validasi konfigurasi saat ganti inti gagal, menggunakan konfigurasi default, periksa file konfigurasi, detail kesalahan:",
|
||||||
"Config Validation Process Terminated": "Proses validasi konfigurasi telah dihentikan."
|
"Config Validation Process Terminated": "Proses validasi dihentikan"
|
||||||
}
|
}
|
||||||
|
@ -436,8 +436,8 @@
|
|||||||
"Enable Tray Speed": "Включить скорость в лотке",
|
"Enable Tray Speed": "Включить скорость в лотке",
|
||||||
"Lite Mode": "Облегченный режим",
|
"Lite Mode": "Облегченный режим",
|
||||||
"Lite Mode Info": "Закройте графический интерфейс и оставьте работать только ядро",
|
"Lite Mode Info": "Закройте графический интерфейс и оставьте работать только ядро",
|
||||||
"Config Validation Failed": "Проверка конфигурации подписки не удалась. Пожалуйста, проверьте файл конфигурации подписки; изменения были отменены.",
|
"Config Validation Failed": "Ошибка проверки конфигурации подписки, проверьте файл конфигурации, изменения отменены, ошибка:",
|
||||||
"Boot Config Validation Failed": "Проверка конфигурации подписки не удалась. Запуск с конфигурацией по умолчанию. Пожалуйста, проверьте файл конфигурации подписки.",
|
"Boot Config Validation Failed": "Ошибка проверки конфигурации при запуске, используется конфигурация по умолчанию, проверьте файл конфигурации, ошибка:",
|
||||||
"Core Change Config Validation Failed": "Проверка конфигурации при смене ядра не удалась; запуск с конфигурацией по умолчанию. Пожалуйста, проверьте файл конфигурации подписки.",
|
"Core Change Config Validation Failed": "Ошибка проверки конфигурации при смене ядра, используется конфигурация по умолчанию, проверьте файл конфигурации, ошибка:",
|
||||||
"Config Validation Process Terminated": "Процесс проверки конфигурации был завершён."
|
"Config Validation Process Terminated": "Процесс проверки прерван"
|
||||||
}
|
}
|
||||||
|
@ -435,8 +435,8 @@
|
|||||||
"Enable Tray Speed": "Трей скоростьне үстерү",
|
"Enable Tray Speed": "Трей скоростьне үстерү",
|
||||||
"Lite Mode": "Җиңел Режим",
|
"Lite Mode": "Җиңел Режим",
|
||||||
"Lite Mode Info": "GUI-ны ябыгыз һәм бары тик төшне генә эшләтеп калдырыгыз",
|
"Lite Mode Info": "GUI-ны ябыгыз һәм бары тик төшне генә эшләтеп калдырыгыз",
|
||||||
"Config Validation Failed": "Язылу көйләүләрен тикшерү уңышсыз тәмамланды. Зинһар, язылу көйләүләре файлын тикшерегез; үзгәрешләр кире кагылды.",
|
"Config Validation Failed": "Язылу көйләү тикшерүе уңышсыз, көйләү файлын тикшерегез, үзгәрешләр кире кайтарылды, хата:",
|
||||||
"Boot Config Validation Failed": "Язылу көйләүләрен тикшерү уңышсыз тәмамланды. Кәгазь көйләүләр белән эшли башлады. Зинһар, язылу көйләүләре файлын тикшерегез.",
|
"Boot Config Validation Failed": "Йөкләү вакытында көйләү тикшерүе уңышсыз, стандарт көйләү кулланылды, көйләү файлын тикшерегез, хата:",
|
||||||
"Core Change Config Validation Failed": "Ядроны алыштырганда көйләүне тикшерү уңышсыз тәмамланды; кәгазь көйләүләр белән эшли башлады. Зинһар, язылу көйләүләре файлын тикшерегез.",
|
"Core Change Config Validation Failed": "Ядро алыштырганда көйләү тикшерүе уңышсыз, стандарт көйләү кулланылды, көйләү файлын тикшерегез, хата:",
|
||||||
"Config Validation Process Terminated": "Көйләүне тикшерү процессы туктатылды."
|
"Config Validation Process Terminated": "Тикшерү процессы туктатылды"
|
||||||
}
|
}
|
||||||
|
@ -436,8 +436,8 @@
|
|||||||
"Enable Tray Speed": "启用托盘速率",
|
"Enable Tray Speed": "启用托盘速率",
|
||||||
"Lite Mode": "轻量模式",
|
"Lite Mode": "轻量模式",
|
||||||
"Lite Mode Info": "关闭GUI界面,仅保留内核运行",
|
"Lite Mode Info": "关闭GUI界面,仅保留内核运行",
|
||||||
"Config Validation Failed": "订阅配置校验失败,请检查订阅配置文件,修改已回滚",
|
"Config Validation Failed": "订阅配置校验失败,请检查订阅配置文件,变更已回滚,错误详情:",
|
||||||
"Boot Config Validation Failed": "启动订阅配置校验失败,已使用默认配置启动;请检查订阅配置文件",
|
"Boot Config Validation Failed": "启动订阅配置校验失败,已使用默认配置启动;请检查订阅配置文件,错误详情:",
|
||||||
"Core Change Config Validation Failed": "切换内核时配置校验失败,已使用默认配置启动;请检查订阅配置文件",
|
"Core Change Config Validation Failed": "切换内核时配置校验失败,已使用默认配置启动;请检查订阅配置文件,错误详情:",
|
||||||
"Config Validation Process Terminated": "验证进程被终止"
|
"Config Validation Process Terminated": "验证进程被终止"
|
||||||
}
|
}
|
||||||
|
@ -58,19 +58,19 @@ const handleNoticeMessage = (
|
|||||||
Notice.error(msg);
|
Notice.error(msg);
|
||||||
break;
|
break;
|
||||||
case "config_validate::boot_error":
|
case "config_validate::boot_error":
|
||||||
Notice.error(t("Boot Config Validation Failed"));
|
Notice.error(`${t("Boot Config Validation Failed")} ${msg}`);
|
||||||
break;
|
break;
|
||||||
case "config_validate::core_change":
|
case "config_validate::core_change":
|
||||||
Notice.error(t("Core Change Config Validation Failed"));
|
Notice.error(`${t("Core Change Config Validation Failed")} ${msg}`);
|
||||||
break;
|
break;
|
||||||
case "config_validate::error":
|
case "config_validate::error":
|
||||||
Notice.error(t("Config Validation Failed"));
|
Notice.error(`${t("Config Validation Failed")} ${msg}`);
|
||||||
break;
|
break;
|
||||||
case "config_validate::process_terminated":
|
case "config_validate::process_terminated":
|
||||||
Notice.error(t("Config Validation Process Terminated"));
|
Notice.error(t("Config Validation Process Terminated"));
|
||||||
break;
|
break;
|
||||||
case "config_validate::stderr_error":
|
case "config_validate::stdout_error":
|
||||||
Notice.error(msg);
|
Notice.error(`${t("Config Validation Failed")} ${msg}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -174,11 +174,11 @@ const ProfilePage = () => {
|
|||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await patchProfiles({ current: profile });
|
const success = await patchProfiles({ current: profile });
|
||||||
await mutateLogs();
|
await mutateLogs();
|
||||||
closeAllConnections();
|
closeAllConnections();
|
||||||
await activateSelected();
|
await activateSelected();
|
||||||
if (notifySuccess) {
|
if (notifySuccess && success) {
|
||||||
Notice.success(t("Profile Switched"), 1000);
|
Notice.success(t("Profile Switched"), 1000);
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user