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