mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-21 11:42:09 +08:00
* refactor(ipc): generate bindings with Specta * fix(profile): project IPC inputs to consumed fields * fix(events): remove unused refresh payloads * fix(webdav): return only consumed backup metadata * fix(network): trim unused interface metadata * fix(sysinfo): return only displayed system fields * chore(knip): check generated runtime exports * fix(proxy): confirm runtime chain updates before UI changes * fix(clipboard): propagate proxy environment copy failures * refactor(dns): remove ignored runtime patch * refactor(core): trim unused upgrade response fields * refactor(ipc): avoid redundant response copies * refactor(proxy): clarify automatic proxy query naming * chore(tests): remove added IPC regression tests * refactor(ipc): enforce typed command boundaries * chore(contract): check generated bindings before push * refactor(ipc): remove unused proxy liveness payloads
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use parking_lot::RwLock;
|
|
use serde::Serialize;
|
|
use tauri::{AppHandle, Runtime, State, command};
|
|
use tauri_plugin_clipboard_manager::ClipboardExt as _;
|
|
|
|
use crate::Platform;
|
|
|
|
#[derive(Serialize, specta::Type)]
|
|
pub struct SystemInfo {
|
|
pub system_name: String,
|
|
pub system_version: String,
|
|
}
|
|
|
|
impl From<&Platform> for SystemInfo {
|
|
fn from(platform: &Platform) -> Self {
|
|
Self {
|
|
system_name: platform.sysinfo.system_name.clone(),
|
|
system_version: platform.sysinfo.system_version.clone(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[command]
|
|
#[specta::specta]
|
|
pub fn get_system_info(state: State<'_, RwLock<Platform>>) -> Result<SystemInfo, String> {
|
|
let platform = state.inner().read();
|
|
Ok(SystemInfo::from(&*platform))
|
|
}
|
|
|
|
/// 获取应用的运行时间(毫秒)
|
|
#[command]
|
|
#[specta::specta]
|
|
pub fn get_app_uptime(state: State<'_, RwLock<Platform>>) -> Result<u128, String> {
|
|
Ok(state.inner().read().appinfo.app_startup_time.elapsed().as_millis())
|
|
}
|
|
|
|
#[command]
|
|
#[specta::specta]
|
|
pub fn export_diagnostic_info<R: Runtime>(
|
|
app_handle: AppHandle<R>,
|
|
state: State<'_, RwLock<Platform>>,
|
|
) -> Result<(), String> {
|
|
let info = state.inner().read().to_string();
|
|
let clipboard = app_handle.clipboard();
|
|
clipboard.write_text(info).map_err(|error| error.to_string())
|
|
}
|