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}
-
+
@@ -300,7 +336,10 @@ export default function PersonSpace() {
-
-
{streamerInfo?.streamer_ext?.gender === 1 ? (
) : (
@@ -358,7 +409,10 @@ export default function PersonSpace() {
@@ -371,7 +425,10 @@ export default function PersonSpace() {
@@ -384,7 +441,10 @@ export default function PersonSpace() {
@@ -394,11 +454,17 @@ export default function PersonSpace() {
)}
{streamerInfo?.streamer_ext?.bio && (
- 个性签名|{streamerInfo?.streamer_ext?.bio}
+
+ 个性签名|
+ {streamerInfo?.streamer_ext?.bio}
+
)}
- {spaceData&&!!spaceData?.previews?.images?.length&&
+ {spaceData && !!spaceData?.previews?.images?.length && (
<>
@@ -428,27 +494,29 @@ export default function PersonSpace() {
- {spaceData?.previews?.images?.slice(0,4).map((item, index) => (
-
-
-
- ))}
+ {spaceData?.previews?.images
+ ?.slice(0, 4)
+ .map((item, index) => (
+
+
+
+ ))}
>
- }
+ )}
<>
@@ -462,7 +530,10 @@ export default function PersonSpace() {
height={32}
width={32}
className="mr-2"
- src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/platform_wechat.png"}
+ src={
+ process.env.NEXT_PUBLIC_WEB_ASSETS_URL +
+ "/images/platform_wechat.png"
+ }
/>
微信:
@@ -479,7 +550,7 @@ export default function PersonSpace() {
-
- {item?.link_name}:{item?.nickname}
+ {item?.link_name}:{item?.nickname}
@@ -505,11 +576,14 @@ export default function PersonSpace() {
className="h-3 mr-1"
/> */}
+ height={24}
+ width={24}
+ className="mr-1"
+ src={
+ process.env.NEXT_PUBLIC_WEB_ASSETS_URL +
+ "/icons/copy.png"
+ }
+ />
复制
@@ -519,12 +593,17 @@ export default function PersonSpace() {
className="h-3 mr-1"
/> */}
- 前往
+ height={24}
+ width={24}
+ className="mr-1"
+ src={
+ process.env.NEXT_PUBLIC_WEB_ASSETS_URL +
+ "/icons/goto.png"
+ }
+ />
+
+ 前往
+
@@ -542,7 +621,11 @@ export default function PersonSpace() {
router.push("/messageDetail?mid="+streamerInfo?.streamer_ext?.mid)}
+ onClick={() =>
+ router.push(
+ "/messageDetail?mid=" + streamerInfo?.streamer_ext?.mid
+ )
+ }
>
私聊
diff --git a/app/space/[id]/page.js b/app/space/[id]/page.js
index d27b7ed..68f7186 100644
--- a/app/space/[id]/page.js
+++ b/app/space/[id]/page.js
@@ -144,20 +144,21 @@ export default function PersonSpace() {
setLoading(false);
setOffset(data.data.offset);
- setHasMore(data.data.more)
+ setHasMore(data.data.more);
return data.data.list;
} catch (error) {
setLoading(false);
}
};
const firstRequest = (currentKey) => {
+ if (typeof window == "undefined") return;
let floatingPanel = document.getElementsByClassName(
"adm-floating-panel-content"
)[0];
floatingPanel?.scrollTo(0, 0);
setOffset(0);
setHasMore(true);
- if(!postList.length)return;
+ if (!postList.length) return;
if (streamerInfo) {
getPostList(streamerInfo.id, currentKey, 0).then((res) => {
setPostList(res || []);
@@ -200,7 +201,7 @@ export default function PersonSpace() {
visitor_role: streamerInfo?.visitor_role,
avatar:
streamerInfo?.streamer_ext?.avatar?.images[0]?.urls[0],
- admission_price:streamerInfo?.admission_price
+ admission_price: streamerInfo?.admission_price,
})
)
)
@@ -212,7 +213,9 @@ export default function PersonSpace() {
diff --git a/app/space/person_space_introduce/[mid]/page.js b/app/space/person_space_introduce/[mid]/page.js
index 1f4df36..b723463 100644
--- a/app/space/person_space_introduce/[mid]/page.js
+++ b/app/space/person_space_introduce/[mid]/page.js
@@ -43,7 +43,7 @@ export default function PersonSpaceIntroduce() {
const showPhotos = (photos, index) => {
currentIndex.current = index;
const interval = setInterval(() => {
- console.log("bbbbbb")
+ if (typeof window == "undefined") return;
const bodyBox = document.getElementsByClassName("photos-bodyBox")[0];
if (bodyBox) {
bodyBox.firstChild.lastChild.style.transform = `translateX(-${
@@ -53,7 +53,6 @@ export default function PersonSpaceIntroduce() {
}
}, 400);
-
handleShowImages(index, photos, interval);
// setVisible(true)
@@ -64,6 +63,7 @@ export default function PersonSpaceIntroduce() {
// );
};
const handleShowImages = (index, photos, interval) => {
+ if (typeof window == "undefined") return;
const mediaDom = document.createElement("div");
mediaDom.style.width = "100vw";
document.body.appendChild(mediaDom);
@@ -80,22 +80,27 @@ export default function PersonSpaceIntroduce() {
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;
}
}
},
@@ -166,7 +171,10 @@ export default function PersonSpaceIntroduce() {
@@ -296,7 +309,7 @@ export default function PersonSpaceIntroduce() {
} else {
// router.push("/pay");
router.push(
- "/webView/" +
+ "/webView/" +
encodeURIComponent(
"/zone/pay/" +
data?.id +
@@ -314,7 +327,10 @@ export default function PersonSpaceIntroduce() {
height={18}
placeholder=""
className="mr-2"
- src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/icons/money_pink.png"}
+ src={
+ process.env.NEXT_PUBLIC_WEB_ASSETS_URL +
+ "/icons/money_pink.png"
+ }
/>
)}
diff --git a/components/ImagesMask/index.jsx b/components/ImagesMask/index.jsx
index d61120d..d85e8d4 100644
--- a/components/ImagesMask/index.jsx
+++ b/components/ImagesMask/index.jsx
@@ -17,7 +17,10 @@ import {
import { createRoot } from "react-dom/client";
import { useRouter } from "next/navigation";
import baseRequest from "@/utils/baseRequest";
-const root = createRoot(document?.getElementById("maskDomBox"));
+const root =
+ typeof window !== "undefined"
+ ? createRoot(document?.getElementById("maskDomBox"))
+ : null;
function ImagesMask({}, ref) {
const [visible, setVisible] = useState(false);
const [images, setImages] = useState([]);
@@ -139,6 +142,7 @@ const ImagesMaskContaint = forwardRef(
fetch(url)
.then((res) => res.blob())
.then((blob) => {
+ if (typeof window == "undefined") return;
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = randomNum + ".jpg";
diff --git a/components/Photos/index.js b/components/Photos/index.js
index a696323..befcb5f 100644
--- a/components/Photos/index.js
+++ b/components/Photos/index.js
@@ -244,6 +244,7 @@ export default function Photos({
onClick={() => {
if (item?.type == "video") {
if (!isUnlocked && type == "space") {
+ if (typeof window == "undefined") return;
const mediaDom = document.createElement("div");
document.body.appendChild(mediaDom);
ImageViewer.show({
diff --git a/components/UploadImgs/index.js b/components/UploadImgs/index.js
index 40faf96..18609fd 100644
--- a/components/UploadImgs/index.js
+++ b/components/UploadImgs/index.js
@@ -3,7 +3,7 @@ import { DotLoading, Image, ImageViewer } from "antd-mobile";
import { uploadImage, uploadVideo } from "@/utils/upload";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAdd, faClose } from "@fortawesome/free-solid-svg-icons";
-export default function UploadImgs({assets, getImgs }) {
+export default function UploadImgs({ assets, getImgs }) {
const maxCount = 6;
const [fileList, setFileList] = useState([]);
const [loading, setLoading] = useState(false);
@@ -14,14 +14,15 @@ export default function UploadImgs({assets, getImgs }) {
if (file.type.indexOf("image/") != -1) {
// const image = await uploadImage(file);
// getImgs((old) => [...old, image.id]);
- const newFiles = [
- ...assets,
- file,
- ];
- const newAssets = newFiles.map(item=>({ type: "img", src: URL.createObjectURL(item) }));
+ const newFiles = [...assets, file];
+ const newAssets = newFiles.map((item) => ({
+ type: "img",
+ src: URL.createObjectURL(item),
+ }));
setFileList(newAssets);
getImgs(newFiles);
} else if (file.type.indexOf("video/") != -1) {
+ if (typeof window == "undefined") return;
const videoD = document.getElementById("videoD");
const videoC = document.getElementById("videoC");
// console.log("videoC", videoC);
@@ -43,11 +44,11 @@ export default function UploadImgs({assets, getImgs }) {
// const video = await uploadVideo(file);
// getImgs((old) => [...old, video.id]);
// setFileList((old) => [...old, video]);
- const newFiles = [
- ...assets,
- file,
- ];
- const newAssets = newFiles.map(item=>({ type: "video", src: URL.createObjectURL(item) }));
+ const newFiles = [...assets, file];
+ const newAssets = newFiles.map((item) => ({
+ type: "video",
+ src: URL.createObjectURL(item),
+ }));
setFileList(newAssets);
}
diff --git a/utils/copy.js b/utils/copy.js
index 7e046b3..8864dd6 100644
--- a/utils/copy.js
+++ b/utils/copy.js
@@ -1,4 +1,5 @@
export default function copy(text = "") {
+ if (typeof window == "undefined") return;
let input = document.createElement("input");
input.style.position = "fixed";
input.style.top = "-10000px";
diff --git a/utils/tools/handleFuns.js b/utils/tools/handleFuns.js
index 0e020d1..ea67ffd 100644
--- a/utils/tools/handleFuns.js
+++ b/utils/tools/handleFuns.js
@@ -1,8 +1,8 @@
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { faClose} from "@fortawesome/free-solid-svg-icons";
-import { Dialog,Toast } from "antd-mobile";
+import { faClose } from "@fortawesome/free-solid-svg-icons";
+import { Dialog, Toast } from "antd-mobile";
import html2canvas from "html2canvas";
-import {checkRole} from "../auth";
+import { checkRole } from "../auth";
import Player from "next-video/player";
// export const handleShowVideos = (video) => {
// Dialog.className = "videoMask";
@@ -52,10 +52,13 @@ export const handleShowVideo = (video) => {
Dialog.className = "videoMask";
Dialog.show({
title: "",
- bodyStyle:{paddingTop:0},
+ bodyStyle: { paddingTop: 0 },
content: (
-
-
Dialog.clear()}>
+
+
Dialog.clear()}
+ >
{
};
//保存div内容为图片
export const saveImage = async (divId) => {
+ if (typeof window == "undefined") return;
const div = document.getElementById(divId);
html2canvas(div, { useCORS: true }).then(function (canvas) {
// 创建一个图片元素
@@ -138,6 +142,7 @@ export const saveFile = async (href) => {
});
return;
}
+ if (typeof window == "undefined") return;
var link = document.createElement("a");
link.href = href;
link.target = "_blank";
diff --git a/utils/upload.js b/utils/upload.js
index cb932be..58b72dc 100644
--- a/utils/upload.js
+++ b/utils/upload.js
@@ -45,7 +45,7 @@ async function calculateFileMetadata(file) {
const fileData = event.target.result;
const wordArray = CryptoJS.lib.WordArray.create(fileData);
const md5Hash = CryptoJS.MD5(wordArray).toString();
-
+ if (typeof window == "undefined") return;
const mediaElement = document.createElement(
file.type.startsWith("image/") ? "img" : "video"
);