🐛 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 =
|
||||
platformApps?.find((item) => item.is_default) || platformApps?.[0];
|
||||
if (!app) return null;
|
||||
|
||||
const handleCopy = (text: string, result: boolean) => {
|
||||
const href = getAppSubLink(application.subscribe_type, url);
|
||||
|
||||
if (isBrowser() && href) {
|
||||
window.location.href = href;
|
||||
return;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
toast.success(
|
||||
<>
|
||||
<p>{t('copySuccess')}</p>
|
||||
<p>{t('manualImportMessage')}</p>
|
||||
</>,
|
||||
);
|
||||
const href = getAppSubLink(application.subscribe_type, url);
|
||||
const showSuccessMessage = () => {
|
||||
toast.success(
|
||||
<>
|
||||
<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':
|
||||
return `hiddify://import/${url}#${name}`;
|
||||
case 'Loon':
|
||||
return `loon://import?sub=${encodeURI(url)}`;
|
||||
return `loon://import?sub=${encodeURIComponent(url)}`;
|
||||
case 'NekoBox':
|
||||
return `sn://subscription?url=${url}&name=${name}`;
|
||||
case 'NekoRay':
|
||||
@ -120,19 +120,21 @@ export const useGlobalStore = create<GlobalStore>((set, get) => ({
|
||||
}),
|
||||
)}`;
|
||||
case 'Shadowrocket':
|
||||
return `shadowrocket://add/sub://${window.btoa(url)}?remark=${encodeURI(name)}`;
|
||||
return `shadowrocket://add/sub://${window.btoa(url)}?remark=${encodeURIComponent(name)}`;
|
||||
case 'Singbox':
|
||||
return `sing-box://import-remote-profile?url=${encodeURI(url)}#${name}`;
|
||||
return `sing-box://import-remote-profile?url=${encodeURIComponent(url)}#${name}`;
|
||||
case 'Surfboard':
|
||||
return `surfboard:///install-config?url=${encodeURI(url)}`;
|
||||
return `surfboard:///install-config?url=${encodeURIComponent(url)}`;
|
||||
case 'Surge':
|
||||
return `surge:///install-config?url=${encodeURI(url)}`;
|
||||
return `surge:///install-config?url=${encodeURIComponent(url)}`;
|
||||
case 'V2box':
|
||||
return `v2box://install-sub?url=${encodeURI(url)}&name=${name}`;
|
||||
case 'V2rayN':
|
||||
return `v2rayn://install-sub?url=${encodeURI(url)}&name=${name}`;
|
||||
return `v2box://install-sub?url=${encodeURIComponent(url)}&name=${name}`;
|
||||
// case 'V2rayN':
|
||||
// return `v2rayn://install-sub?url=${encodeURIComponent(url)}&name=${name}`;
|
||||
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:
|
||||
return '';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user