refactor: impl structs methods

This commit is contained in:
GyDi
2022-01-07 23:29:20 +08:00
parent 3b1561a99b
commit 3bb46eaa6f
21 changed files with 676 additions and 762 deletions

View File

@@ -13,8 +13,8 @@ export async function getAxios() {
try {
const info = await getClashInfo();
if (info?.controller?.server) server = info?.controller?.server;
if (info?.controller?.secret) secret = info?.controller?.secret;
if (info?.server) server = info?.server;
if (info?.secret) secret = info?.secret;
} catch {}
axiosIns = axios.create({
@@ -29,7 +29,7 @@ export async function getAxios() {
export async function getInfomation() {
if (server) return { server, secret };
const info = await getClashInfo();
return info?.controller!;
return info!;
}
/// Get Version

View File

@@ -2,7 +2,7 @@ import { invoke } from "@tauri-apps/api/tauri";
import { ApiType, CmdType } from "./types";
export async function getProfiles() {
return (await invoke<CmdType.ProfilesConfig>("get_profiles")) ?? {};
return invoke<CmdType.ProfilesConfig>("get_profiles");
}
export async function syncProfiles() {

View File

@@ -80,8 +80,9 @@ export namespace ApiType {
export namespace CmdType {
export interface ClashInfo {
status: string;
controller?: { server?: string; secret?: string };
message?: string;
port?: string;
server?: string;
secret?: string;
}
export interface ProfileItem {