feat: enhance clash caller & support more commands

This commit is contained in:
GyDi
2021-12-14 18:37:03 +08:00
parent 4719649bf4
commit 881a95520a
6 changed files with 121 additions and 32 deletions

View File

@@ -0,0 +1,26 @@
use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Manager};
use crate::config::ClashController;
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct ClashInfoPayload {
/// value between `success` and `error`
pub status: String,
/// the clash core's external controller infomation
pub controller: Option<ClashController>,
/// some message
pub message: Option<String>,
}
/// emit `clash_runtime` to the main windows
pub fn clash_start(app_handle: &AppHandle, payload: &ClashInfoPayload) {
match app_handle.get_window("main") {
Some(main_win) => {
main_win.emit("clash_start", payload).unwrap();
}
_ => {}
};
}

View File

@@ -0,0 +1,2 @@
pub mod emit;
pub mod state;

View File

@@ -0,0 +1,6 @@
use std::sync::{Arc, Mutex};
use super::emit::ClashInfoPayload;
#[derive(Default)]
pub struct ClashInfoState(pub Arc<Mutex<ClashInfoPayload>>);