(text: string)
| 202 | |
| 203 | // 辅助函数:复制文本到剪贴板 |
| 204 | export function copyToClipboard(text: string): Promise<boolean> { |
| 205 | // 使用回调方式处理 Promise,避免使用 async/await |
| 206 | return new Promise<boolean>((resolve) => { |
| 207 | try { |
| 208 | navigator.clipboard.writeText(text) |
| 209 | .then(() => resolve(true)) |
| 210 | .catch((err) => { |
| 211 | console.error('Failed to copy text: ', err); |
| 212 | resolve(false); |
| 213 | }); |
| 214 | } catch (err) { |
| 215 | console.error('Failed to copy text: ', err); |
| 216 | resolve(false); |
| 217 | } |
| 218 | }); |
| 219 | } |
nothing calls this directly
no outgoing calls
no test coverage detected