mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: serde::json passing IVerge to the front end without deserialization
This commit is contained in:
@@ -58,6 +58,14 @@ export const BackupConfigViewer = memo(
|
||||
webdav_username !== username ||
|
||||
webdav_password !== password;
|
||||
|
||||
console.log(
|
||||
"webdavChanged",
|
||||
webdavChanged,
|
||||
webdav_url,
|
||||
webdav_username,
|
||||
webdav_password,
|
||||
);
|
||||
|
||||
const handleClickShowPassword = () => {
|
||||
setShowPassword((prev) => !prev);
|
||||
};
|
||||
@@ -98,12 +106,14 @@ export const BackupConfigViewer = memo(
|
||||
checkForm();
|
||||
try {
|
||||
setLoading(true);
|
||||
await saveWebdavConfig(data.url, data.username, data.password).then(
|
||||
() => {
|
||||
Notice.success(t("WebDAV Config Saved"));
|
||||
onSaveSuccess();
|
||||
}
|
||||
);
|
||||
await saveWebdavConfig(
|
||||
data.url.trim(),
|
||||
data.username.trim(),
|
||||
data.password.trim(),
|
||||
).then(() => {
|
||||
Notice.success(t("WebDAV Config Saved"));
|
||||
onSaveSuccess();
|
||||
});
|
||||
} catch (error) {
|
||||
Notice.error(t("WebDAV Config Save Failed", { error }), 3000);
|
||||
} finally {
|
||||
@@ -193,9 +203,9 @@ export const BackupConfigViewer = memo(
|
||||
sx={{ height: "100%" }}
|
||||
>
|
||||
{webdavChanged ||
|
||||
webdav_url === null ||
|
||||
webdav_username === null ||
|
||||
webdav_password === null ? (
|
||||
webdav_url === undefined ||
|
||||
webdav_username === undefined ||
|
||||
webdav_password === undefined ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
color={"primary"}
|
||||
@@ -231,5 +241,5 @@ export const BackupConfigViewer = memo(
|
||||
</Grid2>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -4,7 +4,11 @@ import { getVergeConfig, patchVergeConfig } from "@/services/cmds";
|
||||
export const useVerge = () => {
|
||||
const { data: verge, mutate: mutateVerge } = useSWR(
|
||||
"getVergeConfig",
|
||||
getVergeConfig
|
||||
async () => {
|
||||
const config = await getVergeConfig();
|
||||
console.log("Received verge config:", config);
|
||||
return config;
|
||||
},
|
||||
);
|
||||
|
||||
const patchVerge = async (value: Partial<IVergeConfig>) => {
|
||||
|
||||
@@ -20,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 });
|
||||
}
|
||||
@@ -61,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 });
|
||||
}
|
||||
@@ -132,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),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,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", {
|
||||
@@ -183,7 +183,7 @@ export async function checkService() {
|
||||
}
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,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 });
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export async function restoreWebDavBackup(filename: string) {
|
||||
export async function saveWebdavConfig(
|
||||
url: string,
|
||||
username: string,
|
||||
password: String
|
||||
password: String,
|
||||
) {
|
||||
return invoke<void>("save_webdav_config", {
|
||||
url,
|
||||
|
||||
1
src/services/types.d.ts
vendored
1
src/services/types.d.ts
vendored
@@ -708,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;
|
||||
|
||||
Reference in New Issue
Block a user