Merge branch 'fix-migrate-tauri2-errors'
* fix-migrate-tauri2-errors: (288 commits) # Conflicts: # .github/ISSUE_TEMPLATE/bug_report.yml
This commit is contained in:
@@ -49,12 +49,6 @@ export const getClashConfig = async () => {
|
||||
return instance.get("/configs") as Promise<IConfigData>;
|
||||
};
|
||||
|
||||
/// Update current configs
|
||||
export const updateConfigs = async (config: Partial<IConfigData>) => {
|
||||
const instance = await getAxios();
|
||||
return instance.patch("/configs", config);
|
||||
};
|
||||
|
||||
/// Update geo data
|
||||
export const updateGeoData = async () => {
|
||||
const instance = await getAxios();
|
||||
@@ -78,16 +72,16 @@ export const getRules = async () => {
|
||||
export const getProxyDelay = async (
|
||||
name: string,
|
||||
url?: string,
|
||||
timeout?: number
|
||||
timeout?: number,
|
||||
) => {
|
||||
const params = {
|
||||
timeout: timeout || 10000,
|
||||
url: url || "http://1.1.1.1",
|
||||
url: url || "http://cp.cloudflare.com/generate_204",
|
||||
};
|
||||
const instance = await getAxios();
|
||||
const result = await instance.get(
|
||||
`/proxies/${encodeURIComponent(name)}/delay`,
|
||||
{ params }
|
||||
{ params },
|
||||
);
|
||||
return result as any as { delay: number };
|
||||
};
|
||||
@@ -114,8 +108,8 @@ export const getProxies = async () => {
|
||||
// provider name map
|
||||
const providerMap = Object.fromEntries(
|
||||
Object.entries(providerRecord).flatMap(([provider, item]) =>
|
||||
item.proxies.map((p) => [p.name, { ...p, provider }])
|
||||
)
|
||||
item.proxies.map((p) => [p.name, { ...p, provider }]),
|
||||
),
|
||||
);
|
||||
|
||||
// compatible with proxy-providers
|
||||
@@ -128,6 +122,8 @@ export const getProxies = async () => {
|
||||
udp: false,
|
||||
xudp: false,
|
||||
tfo: false,
|
||||
mptcp: false,
|
||||
smux: false,
|
||||
history: [],
|
||||
};
|
||||
};
|
||||
@@ -158,7 +154,7 @@ export const getProxies = async () => {
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
let globalNames = new Set(globalGroups.map((each) => each.name));
|
||||
@@ -171,8 +167,8 @@ export const getProxies = async () => {
|
||||
|
||||
const proxies = [direct, reject].concat(
|
||||
Object.values(proxyRecord).filter(
|
||||
(p) => !p.all?.length && p.name !== "DIRECT" && p.name !== "REJECT"
|
||||
)
|
||||
(p) => !p.all?.length && p.name !== "DIRECT" && p.name !== "REJECT",
|
||||
),
|
||||
);
|
||||
|
||||
const _global: IProxyGroupItem = {
|
||||
@@ -197,7 +193,7 @@ export const getProxyProviders = async () => {
|
||||
Object.entries(providers).filter(([key, item]) => {
|
||||
const type = item.vehicleType.toLowerCase();
|
||||
return type === "http" || type === "file";
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -214,7 +210,7 @@ export const getRuleProviders = async () => {
|
||||
Object.entries(providers).filter(([key, item]) => {
|
||||
const type = item.vehicleType.toLowerCase();
|
||||
return type === "http" || type === "file";
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -222,7 +218,7 @@ export const getRuleProviders = async () => {
|
||||
export const providerHealthCheck = async (name: string) => {
|
||||
const instance = await getAxios();
|
||||
return instance.get(
|
||||
`/providers/proxies/${encodeURIComponent(name)}/healthcheck`
|
||||
`/providers/proxies/${encodeURIComponent(name)}/healthcheck`,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -258,16 +254,16 @@ export const closeAllConnections = async () => {
|
||||
export const getGroupProxyDelays = async (
|
||||
groupName: string,
|
||||
url?: string,
|
||||
timeout?: number
|
||||
timeout?: number,
|
||||
) => {
|
||||
const params = {
|
||||
timeout: timeout || 10000,
|
||||
url: url || "http://1.1.1.1",
|
||||
url: url || "http://cp.cloudflare.com/generate_204",
|
||||
};
|
||||
const instance = await getAxios();
|
||||
const result = await instance.get(
|
||||
`/group/${encodeURIComponent(groupName)}/delay`,
|
||||
{ params }
|
||||
{ params },
|
||||
);
|
||||
return result as any as Record<string, number>;
|
||||
};
|
||||
|
||||
@@ -6,29 +6,6 @@ export async function copyClashEnv() {
|
||||
return invoke<void>("copy_clash_env");
|
||||
}
|
||||
|
||||
export async function getClashLogs() {
|
||||
const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/;
|
||||
const newRegex = /(.+?)\s+(.+?)\s+(.+)/;
|
||||
const logs = await invoke<string[]>("get_clash_logs");
|
||||
|
||||
return logs.reduce<ILogItem[]>((acc, log) => {
|
||||
const result = log.match(regex);
|
||||
if (result) {
|
||||
const [_, _time, type, payload] = result;
|
||||
const time = dayjs(_time).format("MM-DD HH:mm:ss");
|
||||
acc.push({ time, type, payload });
|
||||
return acc;
|
||||
}
|
||||
|
||||
const result2 = log.match(newRegex);
|
||||
if (result2) {
|
||||
const [_, time, type, payload] = result2;
|
||||
acc.push({ time, type, payload });
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
export async function getProfiles() {
|
||||
return invoke<IProfilesConfig>("get_profiles");
|
||||
}
|
||||
@@ -43,7 +20,7 @@ export async function patchProfilesConfig(profiles: IProfilesConfig) {
|
||||
|
||||
export async function createProfile(
|
||||
item: Partial<IProfileItem>,
|
||||
fileData?: string | null
|
||||
fileData?: string | null,
|
||||
) {
|
||||
return invoke<void>("create_profile", { item, fileData });
|
||||
}
|
||||
@@ -84,7 +61,7 @@ export async function deleteProfile(index: string) {
|
||||
|
||||
export async function patchProfile(
|
||||
index: string,
|
||||
profile: Partial<IProfileItem>
|
||||
profile: Partial<IProfileItem>,
|
||||
) {
|
||||
return invoke<void>("patch_profile", { index, profile });
|
||||
}
|
||||
@@ -141,8 +118,12 @@ export async function changeClashCore(clashCore: string) {
|
||||
return invoke<any>("change_clash_core", { clashCore });
|
||||
}
|
||||
|
||||
export async function restartSidecar() {
|
||||
return invoke<void>("restart_sidecar");
|
||||
export async function restartCore() {
|
||||
return invoke<void>("restart_core");
|
||||
}
|
||||
|
||||
export async function restartApp() {
|
||||
return invoke<void>("restart_app");
|
||||
}
|
||||
|
||||
export async function getAppDir() {
|
||||
@@ -151,19 +132,19 @@ export async function getAppDir() {
|
||||
|
||||
export async function openAppDir() {
|
||||
return invoke<void>("open_app_dir").catch((err) =>
|
||||
Notice.error(err?.message || err.toString(), 1500)
|
||||
Notice.error(err?.message || err.toString(), 1500),
|
||||
);
|
||||
}
|
||||
|
||||
export async function openCoreDir() {
|
||||
return invoke<void>("open_core_dir").catch((err) =>
|
||||
Notice.error(err?.message || err.toString(), 1500)
|
||||
Notice.error(err?.message || err.toString(), 1500),
|
||||
);
|
||||
}
|
||||
|
||||
export async function openLogsDir() {
|
||||
return invoke<void>("open_logs_dir").catch((err) =>
|
||||
Notice.error(err?.message || err.toString(), 1500)
|
||||
Notice.error(err?.message || err.toString(), 1500),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -174,7 +155,7 @@ export async function openWebUrl(url: string) {
|
||||
export async function cmdGetProxyDelay(
|
||||
name: string,
|
||||
timeout: number,
|
||||
url?: string
|
||||
url?: string,
|
||||
) {
|
||||
name = encodeURIComponent(name);
|
||||
return invoke<{ delay: number }>("clash_api_get_proxy_delay", {
|
||||
@@ -188,30 +169,9 @@ export async function cmdTestDelay(url: string) {
|
||||
return invoke<number>("test_delay", { url });
|
||||
}
|
||||
|
||||
/// service mode
|
||||
|
||||
export async function checkService() {
|
||||
try {
|
||||
const result = await invoke<any>("check_service");
|
||||
if (result?.code === 0) return "active";
|
||||
if (result?.code === 400) return "installed";
|
||||
return "unknown";
|
||||
} catch (err: any) {
|
||||
return "uninstall";
|
||||
}
|
||||
}
|
||||
|
||||
export async function installService(passwd: string) {
|
||||
return invoke<void>("install_service", { passwd });
|
||||
}
|
||||
|
||||
export async function uninstallService(passwd: string) {
|
||||
return invoke<void>("uninstall_service", { passwd });
|
||||
}
|
||||
|
||||
export async function invoke_uwp_tool() {
|
||||
return invoke<void>("invoke_uwp_tool").catch((err) =>
|
||||
Notice.error(err?.message || err.toString(), 1500)
|
||||
Notice.error(err?.message || err.toString(), 1500),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -229,7 +189,7 @@ export async function exitApp() {
|
||||
|
||||
export async function copyIconFile(
|
||||
path: string,
|
||||
name: "common" | "sysproxy" | "tun"
|
||||
name: "common" | "sysproxy" | "tun",
|
||||
) {
|
||||
return invoke<void>("copy_icon_file", { path, name });
|
||||
}
|
||||
@@ -245,3 +205,35 @@ export async function getNetworkInterfaces() {
|
||||
export async function getNetworkInterfacesInfo() {
|
||||
return invoke<INetworkInterface[]>("get_network_interfaces_info");
|
||||
}
|
||||
|
||||
export async function createWebdavBackup() {
|
||||
return invoke<void>("create_webdav_backup");
|
||||
}
|
||||
|
||||
export async function deleteWebdavBackup(filename: string) {
|
||||
return invoke<void>("delete_webdav_backup", { filename });
|
||||
}
|
||||
|
||||
export async function restoreWebDavBackup(filename: string) {
|
||||
return invoke<void>("restore_webdav_backup", { filename });
|
||||
}
|
||||
|
||||
export async function saveWebdavConfig(
|
||||
url: string,
|
||||
username: string,
|
||||
password: String,
|
||||
) {
|
||||
return invoke<void>("save_webdav_config", {
|
||||
url,
|
||||
username,
|
||||
password,
|
||||
});
|
||||
}
|
||||
|
||||
export async function listWebDavBackup() {
|
||||
let list: IWebDavFile[] = await invoke<IWebDavFile[]>("list_webdav_backup");
|
||||
list.map((item) => {
|
||||
item.filename = item.href.split("/").pop() as string;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ const [ThemeModeProvider, useThemeMode, useSetThemeMode] = createContextState<
|
||||
"light" | "dark"
|
||||
>("light");
|
||||
|
||||
export const useEnableLog = () => useLocalStorage("enable-log", true);
|
||||
export const useEnableLog = () => useLocalStorage("enable-log", false);
|
||||
|
||||
interface IConnectionSetting {
|
||||
layout: "table" | "list";
|
||||
@@ -20,7 +20,7 @@ export const useConnectionSetting = () =>
|
||||
{
|
||||
serializer: JSON.stringify,
|
||||
deserializer: JSON.parse,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// save the state of each profile item loading
|
||||
|
||||
25
src/services/types.d.ts
vendored
25
src/services/types.d.ts
vendored
@@ -32,6 +32,7 @@ interface IConfigData {
|
||||
"tproxy-port": number;
|
||||
"external-controller": string;
|
||||
secret: string;
|
||||
"unified-delay": boolean;
|
||||
tun: {
|
||||
stack: string;
|
||||
device: string;
|
||||
@@ -55,6 +56,8 @@ interface IProxyItem {
|
||||
udp: boolean;
|
||||
xudp: boolean;
|
||||
tfo: boolean;
|
||||
mptcp: boolean;
|
||||
smux: boolean;
|
||||
history: {
|
||||
time: string;
|
||||
delay: number;
|
||||
@@ -467,6 +470,7 @@ interface IProxyVlessConfig extends IProxyBaseConfig {
|
||||
fingerprint?: string;
|
||||
servername?: string;
|
||||
"client-fingerprint"?: ClientFingerprint;
|
||||
smux?: boolean;
|
||||
}
|
||||
// vmess
|
||||
interface IProxyVmessConfig extends IProxyBaseConfig {
|
||||
@@ -495,6 +499,7 @@ interface IProxyVmessConfig extends IProxyBaseConfig {
|
||||
"global-padding"?: boolean;
|
||||
"authenticated-length"?: boolean;
|
||||
"client-fingerprint"?: ClientFingerprint;
|
||||
smux?: boolean;
|
||||
}
|
||||
interface WireGuardPeerOptions {
|
||||
server?: string;
|
||||
@@ -603,6 +608,7 @@ interface IProxyShadowsocksConfig extends IProxyBaseConfig {
|
||||
"udp-over-tcp"?: boolean;
|
||||
"udp-over-tcp-version"?: number;
|
||||
"client-fingerprint"?: ClientFingerprint;
|
||||
smux?: boolean;
|
||||
}
|
||||
// shadowsocksR
|
||||
interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
|
||||
@@ -702,7 +708,6 @@ interface IVergeConfig {
|
||||
tun_tray_icon?: boolean;
|
||||
enable_tun_mode?: boolean;
|
||||
enable_auto_launch?: boolean;
|
||||
enable_service_mode?: boolean;
|
||||
enable_silent_start?: boolean;
|
||||
enable_system_proxy?: boolean;
|
||||
proxy_auto_config?: boolean;
|
||||
@@ -743,4 +748,22 @@ interface IVergeConfig {
|
||||
auto_log_clean?: 0 | 1 | 2 | 3;
|
||||
proxy_layout_column?: number;
|
||||
test_list?: IVergeTestItem[];
|
||||
webdav_url?: string;
|
||||
webdav_username?: string;
|
||||
webdav_password?: string;
|
||||
}
|
||||
|
||||
interface IWebDavFile {
|
||||
filename: string;
|
||||
href: string;
|
||||
last_modified: string;
|
||||
content_length: number;
|
||||
content_type: string;
|
||||
tag: string;
|
||||
}
|
||||
|
||||
interface IWebDavConfig {
|
||||
url: string;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user