This commit is contained in:
GH Action - Upstream Sync
2024-05-30 01:09:37 +00:00
22 changed files with 337 additions and 221 deletions

View File

@@ -57,12 +57,10 @@ export default function CustomContextMenu(props) {
}
/**
* 鼠标点击事件
* 鼠标点击即关闭菜单
*/
const handleClick = event => {
if (menuRef.current && !menuRef.current.contains(event.target)) {
setShow(false)
}
setShow(false)
}
window.addEventListener('contextmenu', handleContextMenu)
@@ -88,7 +86,6 @@ export default function CustomContextMenu(props) {
function handleScrollTop() {
window.scrollTo({ top: 0, behavior: 'smooth' })
setShow(false)
}
function handleCopyLink() {
@@ -96,12 +93,12 @@ export default function CustomContextMenu(props) {
navigator.clipboard
.writeText(url)
.then(() => {
console.log('页面地址已复制')
// console.log('页面地址已复制')
alert(`${locale.COMMON.PAGE_URL_COPIED} : ${url}`)
})
.catch(error => {
console.error('复制页面地址失败:', error)
})
setShow(false)
}
/**
@@ -130,8 +127,6 @@ export default function CustomContextMenu(props) {
} else {
// alert("Please select some text first.");
}
setShow(false)
}
function handleChangeDarkMode() {

View File

@@ -20,6 +20,8 @@ export default function LazyImage({
style
}) {
const maxWidth = siteConfig('IMAGE_COMPRESS_WIDTH')
const defaultPlaceholderSrc = siteConfig('IMG_LAZY_LOAD_PLACEHOLDER')
const imageRef = useRef(null)
const [adjustedSrc, setAdjustedSrc] = useState(
placeholderSrc || siteConfig('IMG_LAZY_LOAD_PLACEHOLDER')
@@ -37,6 +39,14 @@ export default function LazyImage({
onLoad() // 触发传递的onLoad回调函数
}
}
/**
* 图片加载失败回调
*/
const handleImageError = () => {
if (imageRef.current) {
imageRef.current.src = defaultPlaceholderSrc
}
}
useEffect(() => {
const adjustedImageSrc = adjustImgSize(src, maxWidth)
@@ -71,7 +81,8 @@ export default function LazyImage({
ref: imageRef,
src: priority ? adjustedSrc : placeholderSrc,
alt: alt,
onLoad: handleImageLoad
onLoad: handleImageLoad,
onError: handleImageError // 添加onError处理函数
}
if (id) {