@@ -49,6 +49,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import md5 from 'md5'
|
||||
import type { ContactInfo } from '@/types/DBDocumentTypes'
|
||||
import { sanitizeFileName } from '@/utils/sanitizeFileName'
|
||||
|
||||
const { contactInfo } = defineProps<{ contactInfo: ContactInfo }>()
|
||||
|
||||
@@ -90,10 +91,7 @@ function addToAddressBook() {
|
||||
const blob = new Blob([vCard], { type: 'text/vcard;charset=utf-8' })
|
||||
const link = document.createElement('a')
|
||||
|
||||
const sanitized = contactInfo.name
|
||||
?.replace(/[<>:"/\\|?*\x00-\x1F]/g, '') // Убираем запрещённые символы
|
||||
.replace(/\s+/g, '_') // Заменяем пробелы на подчёркивания
|
||||
.trim()
|
||||
const sanitized = contactInfo.name && sanitizeFileName(contactInfo.name)
|
||||
|
||||
link.href = URL.createObjectURL(blob)
|
||||
link.download = `${sanitized || 'contact'}.vcf`
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export const sanitizeFileName = (fileName: string) => {
|
||||
return fileName
|
||||
.replace(/[<>:"/\\|?*\x00-\x1F]/g, '') // Убираем запрещённые символы
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
}
|
||||
@@ -74,6 +74,7 @@ import { getQrCodeDocument } from '@/api/qrCode'
|
||||
import { type QRCodeDocument } from '@/types/DBDocumentTypes'
|
||||
import { addLabelToSvg } from '@/utils/images/svg/addLabelToSvg'
|
||||
import logo from '@/assets/logo.svg?raw'
|
||||
import { sanitizeFileName } from '@/utils/sanitizeFileName'
|
||||
|
||||
const { qr_code_uri } = defineProps<{ qr_code_uri: QRCodeDocument['uri'] }>()
|
||||
const color = ref('#000') // Цвет для текста QR-кода
|
||||
@@ -92,12 +93,9 @@ const {
|
||||
queryFn: () => getQrCodeDocument(qr_code_uri),
|
||||
})
|
||||
|
||||
// Получение имени файла
|
||||
const sanitizedFileName = computed(() => {
|
||||
const sanitized = qrCodeDoc.value?.name
|
||||
?.replace(/[<>:"/\\|?*\x00-\x1F]/g, '') // Убираем запрещённые символы
|
||||
.replace(/\s+/g, ' ') // Заменяем пробелы на подчёркивания
|
||||
.trim()
|
||||
const sanitized = qrCodeDoc.value?.name && sanitizeFileName(qrCodeDoc.value?.name)
|
||||
|
||||
return sanitized ? `${sanitized} QR-Code - НаСвязи` : 'QR-Code - НаСвязи'
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user