add cache for icon

This commit is contained in:
pompurin404 2024-08-30 17:26:20 +08:00
parent e503095bae
commit 419fec23b7
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -5,3 +5,4 @@
### New Features
- YAML覆写功能支持对数组进行覆盖/前置/追加操作
- 缓存代理组图标

View File

@ -179,8 +179,23 @@ const Proxies: React.FC = () => {
<Avatar
className="bg-transparent mr-2"
size="sm"
onLoad={() => {
const img = new Image()
img.crossOrigin = 'anonymous'
img.onload = (): void => {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.width = img.width
canvas.height = img.height
ctx?.drawImage(img, 0, 0)
const data = canvas.toDataURL('image/png')
console.log('set')
localStorage.setItem(groups[index].icon, data)
}
img.src = groups[index].icon
}}
radius="sm"
src={groups[index].icon}
src={localStorage.getItem(groups[index].icon) || groups[index].icon}
/>
) : null}
<div className="text-ellipsis overflow-hidden whitespace-nowrap">