Skip to content

Commit e0130ec

Browse files
committed
🎨 优化icon读取
1 parent 1e82fe4 commit e0130ec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pages/options/routes/utils.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,23 @@ export function ScriptIcons({ script, size = 32, style }: ScriptIconsProps) {
201201
style = style || {};
202202
style.display = style.display || "inline-block";
203203
style.marginRight = style.marginRight || "8px";
204+
let icon = "";
204205
if (script.metadata.icon) {
206+
[icon] = script.metadata.icon;
207+
} else if (script.metadata.iconurl) {
208+
[icon] = script.metadata.iconurl;
209+
} else if (script.metadata.icon64) {
210+
[icon] = script.metadata.icon64;
211+
} else if (script.metadata.icon64url) {
212+
[icon] = script.metadata.icon64url;
213+
}
214+
if (icon) {
205215
return (
206216
<Avatar size={size || 32} shape="square" style={style}>
207-
<img src={script.metadata.icon[0]} alt={script?.name} />
217+
<img src={icon} alt={script?.name} />
208218
</Avatar>
209219
);
210220
}
221+
// eslint-disable-next-line react/jsx-no-useless-fragment
211222
return <></>;
212223
}

0 commit comments

Comments
 (0)