this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

tweaks

EGOIST 2fd31b82 b0d6bcae

+44 -1
+44 -1
src/app.tsx
··· 12 12 13 13 const wrapper = useRef<HTMLDivElement>(null) 14 14 15 - const copyImage = async () => { 15 + const imageToBlob = async () => { 16 16 if (!wrapper.current) return 17 17 18 18 const blob = await domToBlob(wrapper.current, { ··· 25 25 }, 26 26 }) 27 27 28 + return blob 29 + } 30 + 31 + const copyImage = async () => { 32 + const blob = await imageToBlob() 33 + 34 + if (!blob) return 35 + 28 36 await navigator.clipboard.write([ 29 37 new ClipboardItem({ 30 38 [blob.type]: blob, 31 39 }), 32 40 ]) 41 + } 42 + 43 + const downloadImage = async () => { 44 + if (!wrapper.current) return 45 + 46 + const blob = await imageToBlob() 47 + 48 + if (!blob) return 49 + 50 + const url = URL.createObjectURL(blob) 51 + 52 + const a = document.createElement("a") 53 + a.href = url 54 + a.download = "anime-sedai.png" 55 + a.click() 56 + 57 + URL.revokeObjectURL(url) 33 58 } 34 59 35 60 return ( ··· 141 166 }} 142 167 > 143 168 复制图片 169 + </button> 170 + 171 + <button 172 + type="button" 173 + className="border rounded-md px-4 py-2 inline-flex" 174 + onClick={() => { 175 + toast.promise(downloadImage(), { 176 + success: "下载成功", 177 + loading: "下载中", 178 + error(error) { 179 + return `下载失败: ${ 180 + error instanceof Error ? error.message : "未知错误" 181 + }` 182 + }, 183 + }) 184 + }} 185 + > 186 + 下载图片 144 187 </button> 145 188 </div> 146 189