chore: decode base64

This commit is contained in:
MystiPanda 2024-07-06 10:12:40 +08:00
parent 905353d540
commit 766cf3aeae
No known key found for this signature in database

View File

@ -127,7 +127,31 @@ export const ProxiesEditorViewer = (props: Props) => {
}
}
};
const handleParse = () => {
let proxies = [] as IProxyConfig[];
let names: string[] = [];
let uris = "";
try {
uris = atob(proxyUri);
} catch {
uris = proxyUri;
}
uris
.trim()
.split("\n")
.forEach((uri) => {
try {
let proxy = parseUri(uri.trim());
if (!names.includes(proxy.name)) {
proxies.push(proxy);
names.push(proxy.name);
}
} catch (err: any) {
Notice.error(err.message || err.toString());
}
});
return proxies;
};
const fetchProfile = async () => {
let data = await readProfileFile(profileUid);
@ -247,18 +271,7 @@ export const ProxiesEditorViewer = (props: Props) => {
fullWidth
variant="contained"
onClick={() => {
let proxies = [] as IProxyConfig[];
proxyUri
.trim()
.split("\n")
.forEach((uri) => {
try {
let proxy = parseUri(uri.trim());
proxies.push(proxy);
} catch (err: any) {
Notice.error(err.message || err.toString());
}
});
let proxies = handleParse();
setPrependSeq([...prependSeq, ...proxies]);
}}
>
@ -270,18 +283,7 @@ export const ProxiesEditorViewer = (props: Props) => {
fullWidth
variant="contained"
onClick={() => {
let proxies = [] as IProxyConfig[];
proxyUri
.trim()
.split("\n")
.forEach((uri) => {
try {
let proxy = parseUri(uri.trim());
proxies.push(proxy);
} catch (err: any) {
Notice.error(err.message || err.toString());
}
});
let proxies = handleParse();
setAppendSeq([...appendSeq, ...proxies]);
}}
>