|
145 | 145 | }; |
146 | 146 | }; |
147 | 147 |
|
| 148 | + const getFileName = () => |
| 149 | + `${issuerName}〔${issueDate.year}〕${refNo}号 ${docTitle.replaceAll('\n', '')}.pdf`; |
| 150 | +
|
148 | 151 | const generatePDF = async () => { |
149 | 152 | isGenerating = true; |
150 | 153 | try { |
|
166 | 169 | pdfBlob = blob; |
167 | 170 | pdf = URL.createObjectURL(blob); |
168 | 171 |
|
169 | | - const filename = `${issuerName}〔${issueDate.year}〕${refNo}号 ${docTitle.replaceAll('\n', '')}.pdf`; |
170 | | - const file = new File([blob], filename, { type: 'application/pdf' }); |
| 172 | + const file = new File([blob], getFileName(), { type: 'application/pdf' }); |
171 | 173 | if (typeof navigator !== 'undefined' && 'canShare' in navigator) { |
172 | 174 | try { |
173 | 175 | canShare = navigator.canShare({ files: [file] }); |
|
190 | 192 |
|
191 | 193 | const handleShare = async () => { |
192 | 194 | if (!pdfBlob || !canShare) return; |
193 | | - const filename = `${issuerName}〔${issueDate.year}〕${refNo}号 ${docTitle.replaceAll('\n', '')}.pdf`; |
194 | | - const file = new File([pdfBlob], filename, { type: 'application/pdf' }); |
| 195 | + const file = new File([pdfBlob], getFileName(), { type: 'application/pdf' }); |
195 | 196 | try { |
196 | | - await navigator.share({ files: [file], title: filename }); |
| 197 | + await navigator.share({ files: [file] }); |
197 | 198 | } catch (e) { |
198 | 199 | if (e instanceof Error && e.name === 'AbortError') return; |
199 | 200 | console.error('Error sharing:', e); |
|
202 | 203 |
|
203 | 204 | const handleDownload = () => { |
204 | 205 | if (!pdf) return; |
205 | | - const filename = `${issuerName}〔${issueDate.year}〕${refNo}号 ${docTitle.replaceAll('\n', '')}.pdf`; |
206 | | - triggerDownload(pdf, filename); |
| 206 | + triggerDownload(pdf, getFileName()); |
207 | 207 | }; |
208 | 208 |
|
209 | 209 | $effect(() => { |
|
0 commit comments