Files
clash-proxy/src/services/cmds.ts

62 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-12-25 22:33:29 +08:00
import { invoke } from "@tauri-apps/api/tauri";
import { ApiType, CmdType } from "./types";
2022-01-05 02:00:59 +08:00
export async function getProfiles() {
2022-01-07 23:29:20 +08:00
return invoke<CmdType.ProfilesConfig>("get_profiles");
2021-12-25 22:33:29 +08:00
}
2022-01-05 02:00:59 +08:00
export async function syncProfiles() {
return invoke<void>("sync_profiles");
2021-12-25 22:33:29 +08:00
}
2022-01-19 23:58:34 +08:00
export async function viewProfile(index: number) {
return invoke<void>("view_profile", { index });
2022-01-17 02:16:17 +08:00
}
2021-12-25 22:33:29 +08:00
export async function importProfile(url: string) {
2022-01-16 22:57:42 +08:00
return invoke<void>("import_profile", { url, withProxy: true });
2021-12-25 22:33:29 +08:00
}
2022-01-16 22:57:42 +08:00
export async function updateProfile(index: number, withProxy: boolean) {
return invoke<void>("update_profile", { index, withProxy });
2021-12-25 22:33:29 +08:00
}
2022-01-05 02:00:59 +08:00
export async function deleteProfile(index: number) {
return invoke<void>("delete_profile", { index });
2021-12-25 22:33:29 +08:00
}
2022-01-05 02:00:59 +08:00
export async function patchProfile(
index: number,
profile: CmdType.ProfileItem
) {
return invoke<void>("patch_profile", { index, profile });
2021-12-25 22:33:29 +08:00
}
2022-01-05 02:00:59 +08:00
export async function selectProfile(index: number) {
return invoke<void>("select_profile", { index });
}
export async function restartSidecar() {
return invoke<void>("restart_sidecar");
}
export async function getClashInfo() {
return invoke<CmdType.ClashInfo | null>("get_clash_info");
}
export async function patchClashConfig(payload: Partial<ApiType.ConfigData>) {
return invoke<void>("patch_clash_config", { payload });
2021-12-25 22:33:29 +08:00
}
export async function getVergeConfig() {
return invoke<CmdType.VergeConfig>("get_verge_config");
}
export async function patchVergeConfig(payload: CmdType.VergeConfig) {
return invoke<void>("patch_verge_config", { payload });
}
2022-01-12 02:54:50 +08:00
export async function getSystemProxy() {
return invoke<any>("get_sys_proxy");
}