mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +08:00
add cache for icon
This commit is contained in:
parent
e503095bae
commit
419fec23b7
@ -5,3 +5,4 @@
|
|||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
- YAML覆写功能支持对数组进行覆盖/前置/追加操作
|
- YAML覆写功能支持对数组进行覆盖/前置/追加操作
|
||||||
|
- 缓存代理组图标
|
||||||
|
|||||||
@ -179,8 +179,23 @@ const Proxies: React.FC = () => {
|
|||||||
<Avatar
|
<Avatar
|
||||||
className="bg-transparent mr-2"
|
className="bg-transparent mr-2"
|
||||||
size="sm"
|
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"
|
radius="sm"
|
||||||
src={groups[index].icon}
|
src={localStorage.getItem(groups[index].icon) || groups[index].icon}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<div className="text-ellipsis overflow-hidden whitespace-nowrap">
|
<div className="text-ellipsis overflow-hidden whitespace-nowrap">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user