🐛 fix(dashboard): Improve URL encoding for subscription links and enhance success message handling
This commit is contained in:
parent
3e8912e7bb
commit
4983c33bb3
@ -245,21 +245,31 @@ export default function Content() {
|
|||||||
const app =
|
const app =
|
||||||
platformApps?.find((item) => item.is_default) || platformApps?.[0];
|
platformApps?.find((item) => item.is_default) || platformApps?.[0];
|
||||||
if (!app) return null;
|
if (!app) return null;
|
||||||
|
|
||||||
const handleCopy = (text: string, result: boolean) => {
|
const handleCopy = (text: string, result: boolean) => {
|
||||||
const href = getAppSubLink(application.subscribe_type, url);
|
|
||||||
|
|
||||||
if (isBrowser() && href) {
|
|
||||||
window.location.href = href;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
toast.success(
|
const href = getAppSubLink(application.subscribe_type, url);
|
||||||
<>
|
const showSuccessMessage = () => {
|
||||||
<p>{t('copySuccess')}</p>
|
toast.success(
|
||||||
<p>{t('manualImportMessage')}</p>
|
<>
|
||||||
</>,
|
<p>{t('copySuccess')}</p>
|
||||||
);
|
<p>{t('manualImportMessage')}</p>
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isBrowser() && href) {
|
||||||
|
window.location.href = href;
|
||||||
|
const checkRedirect = setTimeout(() => {
|
||||||
|
if (window.location.href !== href) {
|
||||||
|
showSuccessMessage();
|
||||||
|
}
|
||||||
|
clearTimeout(checkRedirect);
|
||||||
|
}, 1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showSuccessMessage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ export const useGlobalStore = create<GlobalStore>((set, get) => ({
|
|||||||
case 'Hiddify':
|
case 'Hiddify':
|
||||||
return `hiddify://import/${url}#${name}`;
|
return `hiddify://import/${url}#${name}`;
|
||||||
case 'Loon':
|
case 'Loon':
|
||||||
return `loon://import?sub=${encodeURI(url)}`;
|
return `loon://import?sub=${encodeURIComponent(url)}`;
|
||||||
case 'NekoBox':
|
case 'NekoBox':
|
||||||
return `sn://subscription?url=${url}&name=${name}`;
|
return `sn://subscription?url=${url}&name=${name}`;
|
||||||
case 'NekoRay':
|
case 'NekoRay':
|
||||||
@ -120,19 +120,21 @@ export const useGlobalStore = create<GlobalStore>((set, get) => ({
|
|||||||
}),
|
}),
|
||||||
)}`;
|
)}`;
|
||||||
case 'Shadowrocket':
|
case 'Shadowrocket':
|
||||||
return `shadowrocket://add/sub://${window.btoa(url)}?remark=${encodeURI(name)}`;
|
return `shadowrocket://add/sub://${window.btoa(url)}?remark=${encodeURIComponent(name)}`;
|
||||||
case 'Singbox':
|
case 'Singbox':
|
||||||
return `sing-box://import-remote-profile?url=${encodeURI(url)}#${name}`;
|
return `sing-box://import-remote-profile?url=${encodeURIComponent(url)}#${name}`;
|
||||||
case 'Surfboard':
|
case 'Surfboard':
|
||||||
return `surfboard:///install-config?url=${encodeURI(url)}`;
|
return `surfboard:///install-config?url=${encodeURIComponent(url)}`;
|
||||||
case 'Surge':
|
case 'Surge':
|
||||||
return `surge:///install-config?url=${encodeURI(url)}`;
|
return `surge:///install-config?url=${encodeURIComponent(url)}`;
|
||||||
case 'V2box':
|
case 'V2box':
|
||||||
return `v2box://install-sub?url=${encodeURI(url)}&name=${name}`;
|
return `v2box://install-sub?url=${encodeURIComponent(url)}&name=${name}`;
|
||||||
case 'V2rayN':
|
// case 'V2rayN':
|
||||||
return `v2rayn://install-sub?url=${encodeURI(url)}&name=${name}`;
|
// return `v2rayn://install-sub?url=${encodeURIComponent(url)}&name=${name}`;
|
||||||
case 'V2rayNg':
|
case 'V2rayNg':
|
||||||
return `v2rayng://install-sub?url=${encodeURI(url)}&name=${name}`;
|
return `v2rayng://install-sub?url=${encodeURIComponent(url)}#${name}`;
|
||||||
|
case 'Stash':
|
||||||
|
return `stash://install-config?url=${encodeURIComponent(url)}&name=${name}`;
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user