diff --git a/apps/user/app/(main)/(user)/dashboard/content.tsx b/apps/user/app/(main)/(user)/dashboard/content.tsx index 4978fff..99da56b 100644 --- a/apps/user/app/(main)/(user)/dashboard/content.tsx +++ b/apps/user/app/(main)/(user)/dashboard/content.tsx @@ -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( - <> -

{t('copySuccess')}

-

{t('manualImportMessage')}

- , - ); + const href = getAppSubLink(application.subscribe_type, url); + const showSuccessMessage = () => { + toast.success( + <> +

{t('copySuccess')}

+

{t('manualImportMessage')}

+ , + ); + }; + + if (isBrowser() && href) { + window.location.href = href; + const checkRedirect = setTimeout(() => { + if (window.location.href !== href) { + showSuccessMessage(); + } + clearTimeout(checkRedirect); + }, 1000); + return; + } + + showSuccessMessage(); } }; diff --git a/apps/user/config/use-global.tsx b/apps/user/config/use-global.tsx index 11181d6..1148dad 100644 --- a/apps/user/config/use-global.tsx +++ b/apps/user/config/use-global.tsx @@ -106,7 +106,7 @@ export const useGlobalStore = create((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((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 ''; }