添加跨域图片转发;完善生成专属链接保存海报功能

This commit is contained in:
yezian 2024-01-06 21:04:28 +08:00
parent 863d2506c2
commit 070a86c55a
2 changed files with 39 additions and 13 deletions

View File

@ -5,8 +5,6 @@ import baseRequest from "@/utils/baseRequest";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { generateSignature } from "@/utils/crypto"; import { generateSignature } from "@/utils/crypto";
import Image from "next/image"; import Image from "next/image";
import verification from "@/public/icon/verification.png";
import platform_wechat from "@/public/images/platform_wechat.png";
import html2canvas from "html2canvas"; import html2canvas from "html2canvas";
export default function GenerateLink({ params }) { export default function GenerateLink({ params }) {
@ -79,6 +77,7 @@ export default function GenerateLink({ params }) {
useCORS: true, useCORS: true,
}); });
const data = canvas.toDataURL("image/jpg"); const data = canvas.toDataURL("image/jpg");
window.ReactNativeWebView.postMessage( window.ReactNativeWebView.postMessage(
JSON.stringify({ JSON.stringify({
type: "SAVE_IMAGE", type: "SAVE_IMAGE",
@ -137,23 +136,33 @@ export default function GenerateLink({ params }) {
</div> </div>
<div <div
id="print" id="print"
className="flex flex-1 scale-90 flex-col container relative" className="flex flex-1 scale-90 flex-col container bg-[#07050A] relative"
> >
<div className="absolute top-0 left-0 w-full"> <div className="absolute top-0 left-0 w-full z-0">
<div className="relative"> <div className="relative w-full h-64 overflow-hidden">
<img <img
src={data?.cover?.images[0].urls[0]} src={
"/cors/" +
data?.cover?.images[0].urls[0].split(
"https://file.tiefen.fun/"
)[1]
}
alt="" alt=""
className="w-full h-64 object-cover object-center opacity-30" className="w-full object-cover opacity-30"
/> />
<div className="absolute top-0 left-0 w-full h-64 bg-gradient-to-t from-[#07050A] to-[#00000000]"></div> <div className="absolute top-0 left-0 w-full h-64 bg-gradient-to-t from-[#07050A] to-[#00000000]"></div>
</div> </div>
</div> </div>
<div className="flex flex-col flex-1 px-4 py-2 z-10"> <div className="flex flex-col flex-1 px-4 py-2 z-10 relative">
<div className="flex flex-col items-center mt-24"> <div className="flex flex-col items-center mt-24">
<div className="w-[74px] h-[74px] rounded-full overflow-hidden"> <div className="w-[74px] h-[74px] rounded-full overflow-hidden">
<img <img
src={data?.avatar?.images[0].urls[0]} src={
"/cors/" +
data?.avatar?.images[0].urls[0].split(
"https://file.tiefen.fun/"
)[1]
}
alt="" alt=""
className="w-full object-cover" className="w-full object-cover"
/> />
@ -162,7 +171,9 @@ export default function GenerateLink({ params }) {
<p className="text-white text-2xl font-medium mr-1"> <p className="text-white text-2xl font-medium mr-1">
{data?.name} {data?.name}
</p> </p>
<Image src={verification} alt="" className="w-6 h-6" /> <div className="w-6 h-6">
<img src="/icon/verification.png" alt="" className="w-full" />
</div>
</div> </div>
<p className="text-secondary text-sm text-center font-medium mt-3 px-4"> <p className="text-secondary text-sm text-center font-medium mt-3 px-4">
{data?.bio} {data?.bio}
@ -170,7 +181,13 @@ export default function GenerateLink({ params }) {
</div> </div>
<div className="flex flex-col mt-8 bg-[#FFFFFF1A] rounded-2xl"> <div className="flex flex-col mt-8 bg-[#FFFFFF1A] rounded-2xl">
<div className="flex flex-row cursor-pointer bg-[#07050A] border-2 border-[#FFFFFF26] rounded-2xl h-12 items-center justify-center"> <div className="flex flex-row cursor-pointer bg-[#07050A] border-2 border-[#FFFFFF26] rounded-2xl h-12 items-center justify-center">
<Image src={platform_wechat} alt="" className="w-5 h-5" /> <div className="w-5 h-5">
<img
src="/images/platform_wechat.png"
alt=""
className="w-full object-cover"
/>
</div>
<p className="text-white text-base font-medium ml-2">我的微信</p> <p className="text-white text-base font-medium ml-2">我的微信</p>
</div> </div>
</div> </div>
@ -180,7 +197,12 @@ export default function GenerateLink({ params }) {
className="flex flex-row cursor-pointer bg-[#07050A] border-2 border-[#FFFFFF26] rounded-2xl h-12 items-center justify-center mt-4" className="flex flex-row cursor-pointer bg-[#07050A] border-2 border-[#FFFFFF26] rounded-2xl h-12 items-center justify-center mt-4"
> >
<img <img
src={item.icon.images[0].urls[0]} src={
"/cors/" +
item.icon.images[0].urls[0].split(
"https://file.tiefen.fun/"
)[1]
}
alt="" alt=""
className="w-5 h-5" className="w-5 h-5"
/> />
@ -190,7 +212,7 @@ export default function GenerateLink({ params }) {
</div> </div>
))} ))}
</div> </div>
<div className="flex justify-center"> <div className="flex justify-center pt-2 pb-4">
{qrcodeUrl && ( {qrcodeUrl && (
<Image <Image
className="aspect-square object-contain rounded-xl" className="aspect-square object-contain rounded-xl"

View File

@ -6,6 +6,10 @@ const nextConfig = {
source: "/api/:path*", source: "/api/:path*",
destination: "https://api.tiefen.fun/api/:path*", destination: "https://api.tiefen.fun/api/:path*",
}, },
{
source: "/cors/:path*",
destination: "https://file.tiefen.fun/:path*",
},
]; ];
}, },
transpilePackages: ["crypto-js"], transpilePackages: ["crypto-js"],