mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
refactor: impl as struct methods
This commit is contained in:
@@ -1,6 +1,37 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { ApiType, CmdType } from "./types";
|
||||
|
||||
export async function getProfiles() {
|
||||
return (await invoke<CmdType.ProfilesConfig>("get_profiles")) ?? {};
|
||||
}
|
||||
|
||||
export async function syncProfiles() {
|
||||
return invoke<void>("sync_profiles");
|
||||
}
|
||||
|
||||
export async function importProfile(url: string) {
|
||||
return invoke<void>("import_profile", { url });
|
||||
}
|
||||
|
||||
export async function updateProfile(index: number) {
|
||||
return invoke<void>("update_profile", { index });
|
||||
}
|
||||
|
||||
export async function deleteProfile(index: number) {
|
||||
return invoke<void>("delete_profile", { index });
|
||||
}
|
||||
|
||||
export async function patchProfile(
|
||||
index: number,
|
||||
profile: CmdType.ProfileItem
|
||||
) {
|
||||
return invoke<void>("patch_profile", { index, profile });
|
||||
}
|
||||
|
||||
export async function selectProfile(index: number) {
|
||||
return invoke<void>("select_profile", { index });
|
||||
}
|
||||
|
||||
export async function restartSidecar() {
|
||||
return invoke<void>("restart_sidecar");
|
||||
}
|
||||
@@ -13,26 +44,6 @@ export async function patchClashConfig(payload: Partial<ApiType.ConfigData>) {
|
||||
return invoke<void>("patch_clash_config", { payload });
|
||||
}
|
||||
|
||||
export async function importProfile(url: string) {
|
||||
return invoke<void>("import_profile", { url });
|
||||
}
|
||||
|
||||
export async function updateProfile(index: number) {
|
||||
return invoke<void>("update_profile", { index });
|
||||
}
|
||||
|
||||
export async function getProfiles() {
|
||||
return (await invoke<CmdType.ProfilesConfig>("get_profiles")) ?? {};
|
||||
}
|
||||
|
||||
export async function setProfiles(index: number, profile: CmdType.ProfileItem) {
|
||||
return invoke<void>("set_profiles", { index, profile });
|
||||
}
|
||||
|
||||
export async function putProfiles(current: number) {
|
||||
return invoke<void>("put_profiles", { current });
|
||||
}
|
||||
|
||||
export async function setSysProxy(enable: boolean) {
|
||||
return invoke<void>("set_sys_proxy", { enable });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user