mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-29 15:10:06 +00:00
Merge branch 'main' of https://github.com/tangly1024/NotionNext
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user