mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-22 19:52:14 +08:00
* feat: update Cargo.toml for 2024 edition and optimize release profiles * feat: refactor environment variable settings for Linux and improve code organization * Refactor conditional statements to use `&&` for improved readability - Updated multiple files to combine nested `if let` statements using `&&` for better clarity and conciseness. - This change enhances the readability of the code by reducing indentation levels and making the conditions more straightforward. - Affected files include: media_unlock_checker.rs, profile.rs, clash.rs, profiles.rs, async_proxy_query.rs, core.rs, handle.rs, hotkey.rs, service.rs, timer.rs, tray/mod.rs, merge.rs, seq.rs, config.rs, proxy.rs, window.rs, general.rs, dirs.rs, i18n.rs, init.rs, network.rs, and window.rs in the resolve module. * refactor: streamline conditional checks using `&&` for improved readability * fix: update release profile settings for panic behavior and optimization * fix: adjust optimization level in Cargo.toml and reorder imports in lightweight.rs
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use super::CmdResult;
|
|
use crate::{config::*, wrap_err};
|
|
use anyhow::Context;
|
|
use serde_yaml_ng::Mapping;
|
|
use std::collections::HashMap;
|
|
|
|
/// 获取运行时配置
|
|
#[tauri::command]
|
|
pub async fn get_runtime_config() -> CmdResult<Option<Mapping>> {
|
|
Ok(Config::runtime().await.latest_ref().config.clone())
|
|
}
|
|
|
|
/// 获取运行时YAML配置
|
|
#[tauri::command]
|
|
pub async fn get_runtime_yaml() -> CmdResult<String> {
|
|
let runtime = Config::runtime().await;
|
|
let runtime = runtime.latest_ref();
|
|
let config = runtime.config.as_ref();
|
|
wrap_err!(
|
|
config
|
|
.ok_or(anyhow::anyhow!("failed to parse config to yaml file"))
|
|
.and_then(|config| serde_yaml_ng::to_string(config)
|
|
.context("failed to convert config to yaml"))
|
|
)
|
|
}
|
|
|
|
/// 获取运行时存在的键
|
|
#[tauri::command]
|
|
pub async fn get_runtime_exists() -> CmdResult<Vec<String>> {
|
|
Ok(Config::runtime().await.latest_ref().exists_keys.clone())
|
|
}
|
|
|
|
/// 获取运行时日志
|
|
#[tauri::command]
|
|
pub async fn get_runtime_logs() -> CmdResult<HashMap<String, Vec<(String, String)>>> {
|
|
Ok(Config::runtime().await.latest_ref().chain_logs.clone())
|
|
}
|