(content: string, filename: string)
| 75 | * 触发浏览器下载文件 |
| 76 | */ |
| 77 | export function downloadAsFile(content: string, filename: string): void { |
| 78 | const a = document.createElement('a'); |
| 79 | a.href = URL.createObjectURL(new Blob([content], { type: 'text/plain' })); |
| 80 | a.download = filename; |
| 81 | document.body.appendChild(a); |
| 82 | a.click(); |
| 83 | document.body.removeChild(a); |
| 84 | URL.revokeObjectURL(a.href); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * 安全 JSON 解析 |
no outgoing calls
no test coverage detected