From f41450eca8608c9748d10dc9fe38605b8aa71bf9 Mon Sep 17 00:00:00 2001 From: Nik Date: Mon, 8 Jun 2026 11:00:18 +0300 Subject: [PATCH] =?UTF-8?q?card:=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20?= =?UTF-8?q?=C2=AB=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D1=8B=C2=BB=20+?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=B4=D1=91=D0=B6=D0=BD=D0=BE=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20vCard=20=D0=BD?= =?UTF-8?q?=D0=B0=20iOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/CardPage.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/CardPage.tsx b/frontend/src/pages/CardPage.tsx index fe12c59..d3f1698 100644 --- a/frontend/src/pages/CardPage.tsx +++ b/frontend/src/pages/CardPage.tsx @@ -55,15 +55,21 @@ export function CardPage() { if (b64 && b64.length < 60000) lines.push(`PHOTO;ENCODING=b;TYPE=${type}:${b64}`); } lines.push('END:VCARD'); + const vcard = lines.join('\r\n'); try { - const blob = new Blob([lines.join('\r\n')], { type: 'text/vcard;charset=utf-8' }); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; a.download = `${card.slug}.vcf`; - document.body.appendChild(a); a.click(); a.remove(); - setTimeout(() => URL.revokeObjectURL(url), 1000); - toast('Контакт сохранён ✓'); - } catch { toast('Откройте на телефоне для сохранения'); } + const isIOS = /iP(hone|ad|od)/.test(navigator.userAgent); + if (isIOS) { + window.location.href = 'data:text/vcard;charset=utf-8,' + encodeURIComponent(vcard); + } else { + const blob = new Blob([vcard], { type: 'text/vcard;charset=utf-8' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; a.download = `${card.slug}.vcf`; + document.body.appendChild(a); a.click(); a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 1000); + } + toast('Открываю карточку контакта…'); + } catch { toast('Не удалось открыть'); } } function toast(msg: string) { const t = document.getElementById('cp-toast'); @@ -120,7 +126,7 @@ export function CardPage() { {card.product_title && (