command.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { invoke } from "@tauri-apps/api/tauri";
  2. export async function restartSidecar() {
  3. return invoke<void>("restart_sidecar");
  4. }
  5. export interface ClashInfo {
  6. status: string;
  7. controller?: { server?: string; secret?: string };
  8. message?: string;
  9. }
  10. export async function getClashInfo() {
  11. return invoke<ClashInfo | null>("get_clash_info");
  12. }
  13. export async function importProfile(url: string) {
  14. return invoke<void>("import_profile", { url });
  15. }
  16. export async function updateProfile(index: number) {
  17. return invoke<void>("update_profile", { index });
  18. }
  19. export interface ProfileItem {
  20. name?: string;
  21. file?: string;
  22. mode?: string;
  23. url?: string;
  24. selected?: { name?: string; now?: string }[];
  25. extra?: {
  26. upload: number;
  27. download: number;
  28. total: number;
  29. expire: number;
  30. };
  31. }
  32. export interface ProfilesConfig {
  33. current?: number;
  34. items?: ProfileItem[];
  35. }
  36. export async function getProfiles() {
  37. return invoke<ProfilesConfig | null>("get_profiles");
  38. }
  39. export async function setProfiles(current: number, profile: ProfileItem) {
  40. return invoke<void>("set_profiles", { current, profile });
  41. }
  42. export async function putProfiles(current: number) {
  43. return invoke<void>("put_profiles", { current });
  44. }
  45. export async function setSysProxy(enable: boolean) {
  46. return invoke<void>("set_sys_proxy", { enable });
  47. }