(imageUrl: string)
| 112 | * @param imageUrl 图片 URL |
| 113 | */ |
| 114 | export async function downloadImageAsBase64(imageUrl: string): Promise<string> { |
| 115 | try { |
| 116 | const response = await fetch(imageUrl) |
| 117 | const blob = await response.blob() |
| 118 | |
| 119 | return new Promise((resolve, reject) => { |
| 120 | const reader = new FileReader() |
| 121 | reader.onloadend = () => resolve(reader.result as string) |
| 122 | reader.onerror = reject |
| 123 | reader.readAsDataURL(blob) |
| 124 | }) |
| 125 | } catch (error) { |
| 126 | console.error("[Chat Integration] Download image error:", error) |
| 127 | throw error |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * 检测页面中的代码块并添加"解释代码"按钮 |
nothing calls this directly
no outgoing calls
no test coverage detected