mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +08:00
add cache for icon
This commit is contained in:
parent
e503095bae
commit
419fec23b7
|
@ -5,3 +5,4 @@
|
|||
### New Features
|
||||
|
||||
- YAML覆写功能支持对数组进行覆盖/前置/追加操作
|
||||
- 缓存代理组图标
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue
Block a user