mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
feat: profile enhanced mode
This commit is contained in:
@@ -8,7 +8,7 @@ use crate::{
|
||||
use anyhow::Result;
|
||||
use serde_yaml::Mapping;
|
||||
use std::{path::PathBuf, process::Command};
|
||||
use tauri::{api, State};
|
||||
use tauri::{api, Manager, State};
|
||||
|
||||
/// get all profiles from `profiles.yaml`
|
||||
#[tauri::command]
|
||||
@@ -100,6 +100,43 @@ pub fn select_profile(
|
||||
wrap_err!(clash.activate(&profiles))
|
||||
}
|
||||
|
||||
/// change the profile chain
|
||||
#[tauri::command]
|
||||
pub fn change_profile_chain(
|
||||
chain: Option<Vec<String>>,
|
||||
app_handle: tauri::AppHandle,
|
||||
clash_state: State<'_, ClashState>,
|
||||
profiles_state: State<'_, ProfilesState>,
|
||||
) -> Result<(), String> {
|
||||
let clash = clash_state.0.lock().unwrap();
|
||||
let mut profiles = profiles_state.0.lock().unwrap();
|
||||
|
||||
profiles.put_chain(chain);
|
||||
|
||||
app_handle
|
||||
.get_window("main")
|
||||
.map(|win| wrap_err!(clash.activate_enhanced(&profiles, win, false)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// manually exec enhanced profile
|
||||
#[tauri::command]
|
||||
pub fn enhance_profiles(
|
||||
app_handle: tauri::AppHandle,
|
||||
clash_state: State<'_, ClashState>,
|
||||
profiles_state: State<'_, ProfilesState>,
|
||||
) -> Result<(), String> {
|
||||
let clash = clash_state.0.lock().unwrap();
|
||||
let profiles = profiles_state.0.lock().unwrap();
|
||||
|
||||
app_handle
|
||||
.get_window("main")
|
||||
.map(|win| wrap_err!(clash.activate_enhanced(&profiles, win, false)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// delete profile item
|
||||
#[tauri::command]
|
||||
pub fn delete_profile(
|
||||
|
||||
Reference in New Issue
Block a user