mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-15 07:12:09 +08:00
refactor(ipc): remove unused commands
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use super::CmdResult;
|
||||
use crate::core::autostart;
|
||||
use crate::{cmd::StringifyErr as _, feat, utils::dirs};
|
||||
use smartstring::alias::String;
|
||||
use tauri::{AppHandle, Manager as _};
|
||||
@@ -45,22 +44,12 @@ pub async fn restart_app() -> CmdResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_portable_flag() -> bool {
|
||||
*dirs::PORTABLE_FLAG.get().unwrap_or(&false)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_app_dir() -> CmdResult<String> {
|
||||
let app_home_dir = dirs::app_home_dir().stringify_err()?.to_string_lossy().into();
|
||||
Ok(app_home_dir)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_auto_launch_status() -> CmdResult<bool> {
|
||||
autostart::get_launch_status().stringify_err()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String> {
|
||||
feat::download_icon_cache(url, name).await
|
||||
|
||||
@@ -80,31 +80,6 @@ pub async fn change_clash_core(clash_core: String) -> CmdResult<Option<CommandFa
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn start_core() -> CmdResult {
|
||||
let result = CoreManager::global()
|
||||
.start_core()
|
||||
.await
|
||||
.map_err(|error| proxy_aware_coded_error(&error, "CORE_START_FAILED"));
|
||||
if result.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn stop_core() -> CmdResult {
|
||||
logging_error!(Type::Core, profiles_save_file_safe().await);
|
||||
let result = CoreManager::global()
|
||||
.stop_core()
|
||||
.await
|
||||
.map_err(|error| proxy_aware_coded_error(&error, "CORE_STOP_FAILED"));
|
||||
if result.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn restart_core() -> CmdResult {
|
||||
logging_error!(Type::Core, profiles_save_file_safe().await);
|
||||
|
||||
@@ -7,9 +7,3 @@ pub async fn entry_lightweight_mode() -> CmdResult {
|
||||
lightweight::entry_lightweight_mode().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn exit_lightweight_mode() -> CmdResult {
|
||||
lightweight::exit_lightweight_mode().await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -125,7 +125,6 @@ pub use save_profile::*;
|
||||
pub use service::*;
|
||||
pub use system::*;
|
||||
pub use uwp::*;
|
||||
pub use validate::*;
|
||||
pub use verge::*;
|
||||
pub use webdav::*;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use anyhow::{Context as _, anyhow};
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use serde_yaml_ng::Mapping;
|
||||
use smartstring::alias::String;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_runtime_config() -> CmdResult<Option<Mapping>> {
|
||||
@@ -27,11 +27,6 @@ pub async fn get_runtime_yaml() -> CmdResult<String> {
|
||||
.stringify_err()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_runtime_exists() -> CmdResult<HashSet<String>> {
|
||||
Ok(Config::runtime().await.latest_arc().exists_keys.clone())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_runtime_logs() -> CmdResult<HashMap<String, Vec<(String, String)>>> {
|
||||
Ok(Config::runtime().await.latest_arc().chain_logs.clone())
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use super::CmdResult;
|
||||
use crate::core::{
|
||||
handle,
|
||||
validate::{CoreConfigValidator, ValidationErrorKind, ValidationOutcome},
|
||||
validate::{ValidationErrorKind, ValidationOutcome},
|
||||
};
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use smartstring::alias::String;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ValidationNoticeTarget {
|
||||
@@ -13,35 +11,6 @@ pub enum ValidationNoticeTarget {
|
||||
Script,
|
||||
}
|
||||
|
||||
/// 发送脚本验证通知消息
|
||||
#[tauri::command]
|
||||
pub async fn script_validate_notice(status: String, msg: String) -> CmdResult {
|
||||
handle::Handle::notice_message(status.as_str(), msg.as_str());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 验证指定脚本文件
|
||||
#[tauri::command]
|
||||
pub async fn validate_script_file(file_path: String) -> CmdResult<ValidationOutcome> {
|
||||
logging!(info, Type::Config, "验证脚本文件: {}", file_path);
|
||||
|
||||
match CoreConfigValidator::validate_config_file_outcome(&file_path, None).await {
|
||||
Ok(outcome) => {
|
||||
handle_validation_notice(&outcome, ValidationNoticeTarget::Script, "脚本文件");
|
||||
Ok(outcome)
|
||||
}
|
||||
Err(e) => {
|
||||
let error_msg = e.to_string();
|
||||
logging!(error, Type::Config, "验证脚本文件过程发生错误: {}", error_msg);
|
||||
handle::Handle::notice_message("config_validate::process_terminated", &error_msg);
|
||||
Ok(ValidationOutcome::invalid(
|
||||
ValidationErrorKind::ProcessTerminated,
|
||||
error_msg,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn notice_key(kind: ValidationErrorKind, target: ValidationNoticeTarget) -> &'static str {
|
||||
match kind {
|
||||
ValidationErrorKind::FileMissing => "config_validate::file_not_found",
|
||||
|
||||
Reference in New Issue
Block a user