chore: get link by app.getHref (#6029)

This commit is contained in:
Katherine 2025-01-10 10:08:00 +08:00 committed by GitHub
parent a1c0d6b969
commit fa60e339b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,12 +33,10 @@ import { usePublicFormTranslation, NAMESPACE } from '../locale';
const PublicFormQRCode = () => { const PublicFormQRCode = () => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const { t } = usePublicFormTranslation(); const { t } = usePublicFormTranslation();
const baseURL = window.location.origin;
const params = useParams(); const params = useParams();
const isUnderSubApp = window.location.pathname.startsWith('/apps');
const app = useApp(); const app = useApp();
const link = const baseURL = window.location.origin;
baseURL + (isUnderSubApp ? `/apps/${app.name}/public-forms/${params.name}` : `/public-forms/${params.name}`); const link = baseURL + app.getHref(`public-forms/${params.name}`);
const handleQRCodeOpen = (newOpen: boolean) => { const handleQRCodeOpen = (newOpen: boolean) => {
setOpen(newOpen); setOpen(newOpen);
}; };
@ -106,9 +104,7 @@ export function AdminPublicFormPage() {
const handleCopyLink = () => { const handleCopyLink = () => {
const baseURL = window.location.origin; const baseURL = window.location.origin;
const isUnderSubApp = window.location.pathname.startsWith('/apps'); const link = baseURL + app.getHref(`public-forms/${params.name}`);
const link =
baseURL + (isUnderSubApp ? `/apps/${app.name}/public-forms/${params.name}` : `/public-forms/${params.name}`);
navigator.clipboard.writeText(link); navigator.clipboard.writeText(link);
message.success(t('Link copied successfully')); message.success(t('Link copied successfully'));
}; };