修复问题
This commit is contained in:
parent
918190f559
commit
d2adcb07d1
|
@ -3,6 +3,7 @@
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
body {
|
body {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
position: relative
|
||||||
/* padding-bottom: constant(safe-area-inset-bottom);
|
/* padding-bottom: constant(safe-area-inset-bottom);
|
||||||
padding-bottom: env(safe-area-inset-bottom); */
|
padding-bottom: env(safe-area-inset-bottom); */
|
||||||
}
|
}
|
||||||
|
@ -403,3 +404,8 @@ textarea {
|
||||||
.adm-form-item-label .adm-form-item-required-asterisk {
|
.adm-form-item-label .adm-form-item-required-asterisk {
|
||||||
left: auto !important;
|
left: auto !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-modal-mask,
|
||||||
|
.ant-modal-wrap {
|
||||||
|
position: absolute !important;
|
||||||
|
}
|
|
@ -350,7 +350,7 @@ export default function PersonSpace() {
|
||||||
<FloatingPanel
|
<FloatingPanel
|
||||||
anchors={anchors}
|
anchors={anchors}
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
className="bg-deepBg pb-32"
|
className="bg-deepBg"
|
||||||
style={{ height: "calc(100vh - 60px)" }}
|
style={{ height: "calc(100vh - 60px)" }}
|
||||||
>
|
>
|
||||||
<JumboTabs
|
<JumboTabs
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { useRouter, useParams } from "next/navigation";
|
||||||
import requireAPI from "@/utils/requireAPI";
|
import requireAPI from "@/utils/requireAPI";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
|
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { saveImage } from "@/utils/tools/handleFuns";
|
import { saveDivImage } from "@/utils/tools/handleFuns";
|
||||||
import clipboard from "copy-to-clipboard";
|
import clipboard from "copy-to-clipboard";
|
||||||
export default function Share() {
|
export default function Share() {
|
||||||
//获取页面数据、生成二维码
|
//获取页面数据、生成二维码
|
||||||
|
@ -114,7 +114,7 @@ export default function Share() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => saveImage("print")}
|
onClick={() => saveDivImage("print")}
|
||||||
className="btn-md bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-base font-medium w-full mt-4"
|
className="btn-md bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-base font-medium w-full mt-4"
|
||||||
>
|
>
|
||||||
保存图片
|
保存图片
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Dialog, Toast } from "antd-mobile";
|
||||||
|
import { checkRole } from "@/utils/auth";
|
||||||
|
// import { useRouter } from "next/navigation";
|
||||||
|
import baseRequest from "@/utils/baseRequest";
|
||||||
|
export default function CheckVip({ children, isVipToPassFun, router }) {
|
||||||
|
// const router = useRouter();
|
||||||
|
const base = baseRequest();
|
||||||
|
useEffect(() => {}, []);
|
||||||
|
const handleCheck = () => {
|
||||||
|
const isVip = checkRole();
|
||||||
|
if (!isVip) {
|
||||||
|
const showMobal = Dialog.show({
|
||||||
|
title: "是否开通会员",
|
||||||
|
content: (
|
||||||
|
<div>
|
||||||
|
<div>会员可无限制保存图片,查看原图,一次开通永久有效。</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
bodyStyle: {
|
||||||
|
maxHeight: "none",
|
||||||
|
width: "80vw",
|
||||||
|
position: "fixed",
|
||||||
|
top: "200px",
|
||||||
|
left: "10vw",
|
||||||
|
"--text-color": "#fff",
|
||||||
|
color: "#fff",
|
||||||
|
},
|
||||||
|
// cancelText:"确认",
|
||||||
|
// confirmText:"取消",
|
||||||
|
style: {
|
||||||
|
"--text-color": "#fff",
|
||||||
|
},
|
||||||
|
closeOnAction: true,
|
||||||
|
actions: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: "close",
|
||||||
|
text: "取消",
|
||||||
|
bold: true,
|
||||||
|
style: { color: "#ffffff80" },
|
||||||
|
onClick: () => {
|
||||||
|
showMobal?.close();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "submit",
|
||||||
|
text: "确认",
|
||||||
|
style: { color: "#fff" },
|
||||||
|
onClick: () => {
|
||||||
|
showMobal.close();
|
||||||
|
console.log("showMobal", showMobal);
|
||||||
|
router.push(
|
||||||
|
`/webView/${encodeURIComponent(
|
||||||
|
`/vip?base=${encodeURIComponent(JSON.stringify(base))}`
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
isVipToPassFun();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return <div onClick={handleCheck}>{children}</div>;
|
||||||
|
}
|
|
@ -6,14 +6,22 @@ import React, {
|
||||||
useRef,
|
useRef,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
|
useMemo,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { Mask } from "antd-mobile";
|
import { Mask, Dialog, Toast } from "antd-mobile";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faAngleLeft, faAngleRight } from "@fortawesome/free-solid-svg-icons";
|
import {
|
||||||
|
faAngleLeft,
|
||||||
|
faAngleRight,
|
||||||
|
faDownload,
|
||||||
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import baseRequest from "@/utils/baseRequest";
|
import baseRequest from "@/utils/baseRequest";
|
||||||
import OwnImage from "../OwnImage";
|
import OwnImage from "../OwnImage";
|
||||||
|
import { saveImage } from "@/utils/tools/handleFuns";
|
||||||
|
import requireAPI from "@/utils/requireAPI";
|
||||||
|
import CheckVip from "@/components/CheckVip";
|
||||||
function ImagesMask({}, ref) {
|
function ImagesMask({}, ref) {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [images, setImages] = useState([]);
|
const [images, setImages] = useState([]);
|
||||||
|
@ -21,33 +29,34 @@ function ImagesMask({}, ref) {
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
const defaultIndex = useRef(null);
|
const defaultIndex = useRef(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
useEffect(() => {
|
const imagesMaskContaintMemo = useMemo(() => {
|
||||||
let body = document.body;
|
console.log(images);
|
||||||
if (visible) {
|
return (
|
||||||
body.style.touchAction = "none";
|
<ImagesMaskContaint
|
||||||
const root = createRoot(document?.getElementById("maskDomBox"));
|
images={images}
|
||||||
root.render(
|
visible={visible}
|
||||||
<div>
|
ref={scrollRef}
|
||||||
<ImagesMaskContaint
|
setVisible={setVisible}
|
||||||
images={images}
|
setImages={setImages}
|
||||||
visible={visible}
|
router={router}
|
||||||
ref={scrollRef}
|
data={data}
|
||||||
setVisible={setVisible}
|
defaultIndex={defaultIndex.current}
|
||||||
setImages={setImages}
|
// root={root}
|
||||||
router={router}
|
/>
|
||||||
data={data}
|
);
|
||||||
defaultIndex={defaultIndex.current}
|
}, [images]);
|
||||||
root={root}
|
// useEffect(() => {
|
||||||
/>
|
// let body = document.body;
|
||||||
</div>
|
// if (visible) {
|
||||||
);
|
// body.style.touchAction = "none";
|
||||||
} else {
|
// const root = createRoot(document?.getElementById("maskDomBox"));
|
||||||
body.style.touchAction = "auto";
|
// root.render(<div>{imagesMaskContaintMemo}</div>);
|
||||||
}
|
// } else {
|
||||||
|
// body.style.touchAction = "auto";
|
||||||
// root.render(<div>xxxx</div>);
|
// }
|
||||||
}, [visible]);
|
|
||||||
|
|
||||||
|
// // root.render(<div>xxxx</div>);
|
||||||
|
// }, [visible]);
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
show: (arr, index, data) => {
|
show: (arr, index, data) => {
|
||||||
defaultIndex.current = index;
|
defaultIndex.current = index;
|
||||||
|
@ -64,7 +73,7 @@ function ImagesMask({}, ref) {
|
||||||
close: () => setVisible(false),
|
close: () => setVisible(false),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return <></>;
|
return <div>{visible ? imagesMaskContaintMemo : null}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImagesMaskContaint = forwardRef(
|
const ImagesMaskContaint = forwardRef(
|
||||||
|
@ -77,7 +86,7 @@ const ImagesMaskContaint = forwardRef(
|
||||||
router,
|
router,
|
||||||
data,
|
data,
|
||||||
defaultIndex = 0,
|
defaultIndex = 0,
|
||||||
root,
|
// root,
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
|
@ -95,6 +104,7 @@ const ImagesMaskContaint = forwardRef(
|
||||||
const base = baseRequest();
|
const base = baseRequest();
|
||||||
const directionX = useRef(0);
|
const directionX = useRef(0);
|
||||||
const currentDistance = useRef(0);
|
const currentDistance = useRef(0);
|
||||||
|
console.log("======", images);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (defaultIndex) {
|
if (defaultIndex) {
|
||||||
setIsNotFirstImg(true);
|
setIsNotFirstImg(true);
|
||||||
|
@ -217,33 +227,44 @@ const ImagesMaskContaint = forwardRef(
|
||||||
setXOffset(-cxOffset * (index + (currentDirection == "left" ? 1 : -1)));
|
setXOffset(-cxOffset * (index + (currentDirection == "left" ? 1 : -1)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// };
|
const getOriginImg = async (id) => {
|
||||||
// };
|
const _data = await requireAPI("POST", `/api/previews/original_image`, {
|
||||||
// };
|
body: {
|
||||||
function downloadImage(url) {
|
image_id: id,
|
||||||
let randomNum = "";
|
},
|
||||||
for (let i = 0; i < 10; i++) {
|
});
|
||||||
randomNum += Math.floor(Math.random() * 10);
|
if (_data.ret === -1) {
|
||||||
}
|
Toast.show({
|
||||||
fetch(url)
|
icon: "fail",
|
||||||
.then((res) => res.blob())
|
content: _data.msg,
|
||||||
.then((blob) => {
|
position: "top",
|
||||||
if (typeof window == "undefined") return;
|
|
||||||
var a = document.createElement("a");
|
|
||||||
a.href = URL.createObjectURL(blob);
|
|
||||||
a.download = randomNum + ".jpg";
|
|
||||||
a.click();
|
|
||||||
});
|
});
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
setImages((old) => {
|
||||||
|
console.log(old);
|
||||||
|
const { urls, id, w, h } = _data.data;
|
||||||
|
const newImages = [...old];
|
||||||
|
newImages[currentIndex] = {
|
||||||
|
url: urls[0],
|
||||||
|
id,
|
||||||
|
w,
|
||||||
|
h,
|
||||||
|
};
|
||||||
|
|
||||||
|
return newImages;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Mask
|
<Mask
|
||||||
|
getContainer={() => document.getElementById("maskDomBox")}
|
||||||
destroyOnClose={false}
|
destroyOnClose={false}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
className="z-[1002] h-screen flex justify-center items-center"
|
className="z-[1002] h-screen flex justify-center items-center"
|
||||||
onMaskClick={() => {
|
onMaskClick={() => {
|
||||||
setVisible(false), setImages([]), setCurrentIndex(null);
|
setVisible(false), setImages([]), setCurrentIndex(null);
|
||||||
root.unmount();
|
// root.unmount();
|
||||||
}}
|
}}
|
||||||
color="#000000d9"
|
color="#000000d9"
|
||||||
>
|
>
|
||||||
|
@ -261,7 +282,29 @@ const ImagesMaskContaint = forwardRef(
|
||||||
<FontAwesomeIcon icon={faDownload} size="xl" />
|
<FontAwesomeIcon icon={faDownload} size="xl" />
|
||||||
</div> */}
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="flex gap-2">
|
||||||
|
<CheckVip
|
||||||
|
isVipToPassFun={() => getOriginImg(images[currentIndex]?.id)}
|
||||||
|
router={router}
|
||||||
|
>
|
||||||
|
<div className="flex justify-center items-center w-[38px] h-[38px] bg-[#ffffff1a] text-[#fff] font-medium rounded-full">
|
||||||
|
原图
|
||||||
|
</div>
|
||||||
|
</CheckVip>
|
||||||
|
|
||||||
|
<CheckVip
|
||||||
|
isVipToPassFun={() => saveImage(images[currentIndex]?.url)}
|
||||||
|
router={router}
|
||||||
|
>
|
||||||
|
<div className="flex justify-center items-center w-[38px] h-[38px] bg-[#ffffff1a] text-[#fff] rounded-full">
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faDownload}
|
||||||
|
size="xl"
|
||||||
|
// className="h-[14px]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CheckVip>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setZoomed(!zoomed);
|
setZoomed(!zoomed);
|
||||||
|
@ -334,7 +377,7 @@ const ImagesMaskContaint = forwardRef(
|
||||||
style={{ height: "calc(100vh - 174px)" }}
|
style={{ height: "calc(100vh - 174px)" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisible(false), setImages([]), setCurrentIndex(null);
|
setVisible(false), setImages([]), setCurrentIndex(null);
|
||||||
root.unmount();
|
// root.unmount();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -352,6 +395,7 @@ const ImagesMaskContaint = forwardRef(
|
||||||
onTouchEnd={() => handleEnd(currentIndex, direction)}
|
onTouchEnd={() => handleEnd(currentIndex, direction)}
|
||||||
>
|
>
|
||||||
{images.map((item, index) => {
|
{images.map((item, index) => {
|
||||||
|
console.log("------------", item);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
draggable={true}
|
draggable={true}
|
||||||
|
|
|
@ -40,6 +40,7 @@ export default function Photos({
|
||||||
// fullwidth:item.w>item.h,
|
// fullwidth:item.w>item.h,
|
||||||
w: item.w,
|
w: item.w,
|
||||||
h: item.h,
|
h: item.h,
|
||||||
|
id: item.id,
|
||||||
}));
|
}));
|
||||||
let videoArr = media.videos.map((item) => ({
|
let videoArr = media.videos.map((item) => ({
|
||||||
type: "video",
|
type: "video",
|
||||||
|
@ -64,6 +65,7 @@ export default function Photos({
|
||||||
type: "hid",
|
type: "hid",
|
||||||
w: newPhotos[0]?.w,
|
w: newPhotos[0]?.w,
|
||||||
h: newPhotos[0]?.h,
|
h: newPhotos[0]?.h,
|
||||||
|
id: newPhotos[0]?.id,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,12 @@ export default function PostItem({
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{type == "space" && data?.is_headed === 1 && (
|
{type == "space" && data?.is_headed === 1 && (
|
||||||
<OwnIcon src="/images/top_post.png" width={76} outClassName="mb-2" />
|
<OwnIcon
|
||||||
|
src="/images/top_post.png"
|
||||||
|
className="w-[76px] h-max"
|
||||||
|
outClassName="w-[76px] h-max mb-2"
|
||||||
|
fit="cover"
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -7,6 +7,10 @@ const nextConfig = {
|
||||||
destination: "https://h5api.tiefen.fun/api/:path*",
|
destination: "https://h5api.tiefen.fun/api/:path*",
|
||||||
// destination: "https://testapi.tiefen.fun/api/:path*",
|
// destination: "https://testapi.tiefen.fun/api/:path*",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
source: "/imgprod/:path*",
|
||||||
|
destination: "https://levianderwinv01.tiefen.space/imgprod/:path*",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
transpilePackages: ["crypto-js"],
|
transpilePackages: ["crypto-js"],
|
||||||
|
|
|
@ -148,7 +148,7 @@ export const handleShowVideo = (video) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
//保存div内容为图片
|
//保存div内容为图片
|
||||||
export const saveImage = async (divId) => {
|
export const saveDivImage = async (divId) => {
|
||||||
if (typeof window == "undefined") return;
|
if (typeof window == "undefined") return;
|
||||||
const div = document.getElementById(divId);
|
const div = document.getElementById(divId);
|
||||||
html2canvas(div, { useCORS: true }).then(function (canvas) {
|
html2canvas(div, { useCORS: true }).then(function (canvas) {
|
||||||
|
@ -164,10 +164,28 @@ export const saveImage = async (divId) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
//保存图片
|
//保存图片
|
||||||
|
export const saveImage = async (url) => {
|
||||||
|
if (typeof window == "undefined") return;
|
||||||
|
fetch(url)
|
||||||
|
.then((res) => res.blob())
|
||||||
|
.then((blob) => {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
// 创建一个链接元素
|
||||||
|
var link = document.createElement("a");
|
||||||
|
link.href = url;
|
||||||
|
// 设置下载的文件名
|
||||||
|
link.download = "SAVE_IMAGE.jpg";
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => console.log(error));
|
||||||
|
};
|
||||||
export const saveFile = async (href) => {
|
export const saveFile = async (href) => {
|
||||||
const isVip = checkRole();
|
const isVip = checkRole();
|
||||||
if (!isVip) {
|
if (!isVip) {
|
||||||
setIsVipModalVisible(true);
|
// setIsVipModalVisible(true);
|
||||||
Toast.show({
|
Toast.show({
|
||||||
icon: "fail",
|
icon: "fail",
|
||||||
content: "仅会员支持下载",
|
content: "仅会员支持下载",
|
||||||
|
|
Loading…
Reference in New Issue