Skip to content

Commit

Permalink
Fix network error handling in ItemCover component
Browse files Browse the repository at this point in the history
  • Loading branch information
YouXam committed May 6, 2024
1 parent c614d5d commit 93ff180
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function ItemCover({ src, alt, index, className, onClick }: { index?: number, sr
(e.target as HTMLImageElement).src = "/placeholder.svg";
(e.target as HTMLImageElement).style.aspectRatio = "3/4";
setIsError(true);
console.log(index)
if (index === 0) {
fetch(src, {
redirect: "manual"
Expand All @@ -115,13 +114,16 @@ function ItemCover({ src, alt, index, className, onClick }: { index?: number, sr
toast("网络环境错误", {
description: "您可以切换到校园网环境,或者访问正式版网站。",
duration: 100000,
dismissible: false,
action: {
label: "跳转",
onClick: () => {
location.href = location.href.replace(location.origin, "https://byrdocs.org")
}
},
cancel: {
label: "关闭",
onClick: () => {}
}
})
}
}
Expand Down

0 comments on commit 93ff180

Please sign in to comment.