diff --git a/app/layout.js b/app/layout.js index 57c44ed..6476f61 100644 --- a/app/layout.js +++ b/app/layout.js @@ -36,26 +36,28 @@ export default function RootLayout({ children }) { useEffect(() => { // 禁止双指放大 window.onload = function () { - document.addEventListener("touchstart", function (event) { - if (event.touches.length > 1) { - event.preventDefault(); - } - }); - var lastTouchEnd = 0; - document.addEventListener( - "touchend", - function (event) { - var now = new Date().getTime(); - if (now - lastTouchEnd <= 300) { + if (typeof window !== "undefined") { + document.addEventListener("touchstart", function (event) { + if (event.touches.length > 1) { event.preventDefault(); } - lastTouchEnd = now; - }, - false - ); - document.addEventListener("gesturestart", function (event) { - event.preventDefault(); - }); + }); + var lastTouchEnd = 0; + document.addEventListener( + "touchend", + function (event) { + var now = new Date().getTime(); + if (now - lastTouchEnd <= 300) { + event.preventDefault(); + } + lastTouchEnd = now; + }, + false + ); + document.addEventListener("gesturestart", function (event) { + event.preventDefault(); + }); + } }; }, []); useEffect(() => { diff --git a/app/profile/[mid]/page.js b/app/profile/[mid]/page.js index da7ed4d..947f631 100644 --- a/app/profile/[mid]/page.js +++ b/app/profile/[mid]/page.js @@ -47,7 +47,28 @@ export default function PersonSpace() { const showPhotos = (photos, index) => { currentIndex.current = index; const interval = setInterval(() => { - console.log("bbbbbb") + console.log("bbbbbb"); + if (typeof window == "undefined") return; + document.addEventListener("touchstart", function (event) { + if (event.touches.length > 1) { + event.preventDefault(); + } + }); + var lastTouchEnd = 0; + document.addEventListener( + "touchend", + function (event) { + var now = new Date().getTime(); + if (now - lastTouchEnd <= 300) { + event.preventDefault(); + } + lastTouchEnd = now; + }, + false + ); + document.addEventListener("gesturestart", function (event) { + event.preventDefault(); + }); const bodyBox = document.getElementsByClassName("photos-bodyBox")[0]; if (bodyBox) { bodyBox.firstChild.lastChild.style.transform = `translateX(-${ @@ -57,7 +78,6 @@ export default function PersonSpace() { } }, 400); - handleShowImages(index, photos, interval); // setVisible(true) @@ -68,6 +88,7 @@ export default function PersonSpace() { // ); }; const handleShowImages = (index, photos, interval) => { + if (typeof window == "undefined") return; const mediaDom = document.createElement("div"); mediaDom.style.width = "100vw"; document.body.appendChild(mediaDom); @@ -84,22 +105,27 @@ export default function PersonSpace() { getContainer: mediaDom, onIndexChange: (index) => { + if (typeof window == "undefined") return; currentIndex.current = index; mediaDom.className = `${ photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom" }`; - const leftBtn = document.getElementsByClassName("imagesBtnsControllerLeft")[0] - const rightBtn = document.getElementsByClassName("imagesBtnsControllerRight")[0] - if(leftBtn && rightBtn){ - if(!index){ - leftBtn.style.opacity=0.5 - rightBtn.style.opacity=1 - }else if(index==photos.length-1){ - leftBtn.style.opacity=1 - rightBtn.style.opacity=0.5 - }else{ - leftBtn.style.opacity=1 - rightBtn.style.opacity=1 + const leftBtn = document.getElementsByClassName( + "imagesBtnsControllerLeft" + )[0]; + const rightBtn = document.getElementsByClassName( + "imagesBtnsControllerRight" + )[0]; + if (leftBtn && rightBtn) { + if (!index) { + leftBtn.style.opacity = 0.5; + rightBtn.style.opacity = 1; + } else if (index == photos.length - 1) { + leftBtn.style.opacity = 1; + rightBtn.style.opacity = 0.5; + } else { + leftBtn.style.opacity = 1; + rightBtn.style.opacity = 1; } } }, @@ -244,7 +270,9 @@ export default function PersonSpace() { } else { showPhotos( topPhotos.filter((it) => it.type == "img"), - topPhotos.filter((it) => it.type == "img").indexOf(photo) + topPhotos + .filter((it) => it.type == "img") + .indexOf(photo) ); } }} @@ -264,7 +292,10 @@ export default function PersonSpace() { className="" width={98} height={98} - src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/icons/play.png"} + src={ + process.env.NEXT_PUBLIC_WEB_ASSETS_URL + + "/icons/play.png" + } /> )} @@ -282,7 +313,12 @@ export default function PersonSpace() { {streamerInfo?.streamer_ext?.name}

- +