添加登录验证

This commit is contained in:
al 2024-07-19 16:22:43 +08:00
parent 25452fc21f
commit 0339587d23
9 changed files with 100 additions and 51 deletions

View File

@ -215,6 +215,10 @@ body{
width: max-content; width: max-content;
border-radius: 0.25rem; border-radius: 0.25rem;
} */ } */
.mediaDom .adm-image-viewer-slide{
/* max-height: 90vh; */
max-width: 100vw;
}
.photos-body img{ .photos-body img{
/* max-height: 90vh; */ /* max-height: 90vh; */
filter: blur(8px); filter: blur(8px);

View File

@ -157,9 +157,10 @@ export default function EditPassword() {
{/* 内容 */} {/* 内容 */}
<div className="pt-32 px-4"> <div className="pt-32 px-4">
<p className="text-3xl text-white font-medium"> <p className="text-3xl text-white font-medium">
{console.log(mobilePhone,"cccc")}
{searchParams.get("is_enabled") == "0" {searchParams.get("is_enabled") == "0"
? "设置密码" ? "设置密码"
: mobilePhone == "0" : mobilePhone
? "修改密码" ? "修改密码"
: "重置密码"} : "重置密码"}
</p> </p>

View File

@ -103,7 +103,7 @@ export default function PersonSpace() {
}; };
//保存内容到剪贴板 //保存内容到剪贴板
const copy = (_data) => { const copy = (_data) => {
console.log("_data",_data) console.log("_data", _data);
clipboard(_data); clipboard(_data);
Toast.show({ Toast.show({
icon: "success", icon: "success",
@ -340,43 +340,57 @@ export default function PersonSpace() {
)} )}
</div> </div>
</div> </div>
<Divider /> {spaceData&&!!spaceData?.previews?.images?.length&&
<div> <>
<div onClick={() => router.push(spaceData?.visitor_role === 4?`/space/person_space_introduce/${mid}`:`/space/${mid}`)}> <Divider />
<div className="flex justify-between items-center mb-2"> <div>
<span className="font-bold text-base">空间动态</span> <div
<div className="h-4 text-xs text-[#ffffff88]"> onClick={() =>
<span className="mr-2"> router.push(
查看{spaceData?.zone_moment_count || 0} spaceData?.visitor_role === 4
</span> ? `/space/person_space_introduce/${mid}`
<FontAwesomeIcon : `/space/${mid}`
icon={faAngleRight} )
size="xl" }
className="h-4" >
onClick={() => { <div className="flex justify-between items-center mb-2">
router.back(); <span className="font-bold text-base">空间动态</span>
}} <div className="h-4 text-xs text-[#ffffff88]">
/> <span className="mr-2">
查看{spaceData?.zone_moment_count}
</span>
<FontAwesomeIcon
icon={faAngleRight}
size="xl"
className="h-4"
onClick={() => {
router.back();
}}
/>
</div>
</div>
<div className="flex ">
{spaceData?.previews?.images?.map((item, index) => (
<div
key={item.id}
className="w-20 h-20 overflow-hidden rounded mr-1"
>
<Image
width="20vw"
height="20vw"
className={`rounded mr-2 ${
spaceData?.visitor_role === 4 && "imageBlur"
}`}
fit="cover"
src={item.urls[0]}
/>
</div>
))}
</div>
</div> </div>
</div> </div>
<div className="flex "> </>
{spaceData?.previews?.images?.map((item, index) => ( }
<div
key={item.id}
className="w-20 h-20 overflow-hidden rounded mr-1"
>
<Image
width="20vw"
height="20vw"
className={`rounded mr-2 ${spaceData?.visitor_role === 4 && "imageBlur"}`}
fit="cover"
src={item.urls[0]}
/>
</div>
))}
</div>
</div>
</div>
<> <>
<Divider /> <Divider />
@ -394,7 +408,12 @@ export default function PersonSpace() {
/> />
<div className="text-base"> <div className="text-base">
<span>微信</span> <span>微信</span>
<span className="text-sky-600" onClick={() => setVisible(true)}>点击查看</span> <span
className="text-sky-600"
onClick={() => setVisible(true)}
>
点击查看
</span>
</div> </div>
</div> </div>
</li> </li>

View File

@ -132,6 +132,7 @@ export default function Search() {
data={item} data={item}
key={item.id} key={item.id}
showMore={arr.length === 1} showMore={arr.length === 1}
link={`space/person_space_introduce/${item.mid}`}
/> />
)); ));
})()} })()}
@ -139,9 +140,9 @@ export default function Search() {
)} )}
{streamers.length > 0 && ( {streamers.length > 0 && (
<div> <div>
<p className="mt-2 mb-1 text-white text-xl font-medium">个人</p> <p className="mt-2 mb-1 text-white text-xl font-medium">用户</p>
{streamers.map((item) => ( {streamers.map((item) => (
<ZoneItem data={item} key={item.id} /> <ZoneItem data={item} key={item.id} link={`/profile/${item.mid}`}/>
))} ))}
</div> </div>
)} )}
@ -151,12 +152,12 @@ export default function Search() {
); );
} }
const ZoneItem = ({ data, showMore }) => { const ZoneItem = ({ data, showMore, link }) => {
const router = useRouter(); const router = useRouter();
return ( return (
<List.Item <List.Item
className="!p-0" className="!p-0"
onClick={() => router.push(`space/person_space_introduce/${data.mid}`)} onClick={() => router.push(link)}
key={data.id} key={data.id}
arrow={false} arrow={false}
> >

View File

@ -7,7 +7,7 @@ import { faAngleUp, faClose, faSave } from "@fortawesome/free-solid-svg-icons";
import { saveFile } from "@/utils/tools/handleFuns"; import { saveFile } from "@/utils/tools/handleFuns";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
export default function Photos({ isUnlocked, mediaAmount, media }) { export default function Photos({ isUnlocked, mediaAmount, media, type }) {
const [seeAllPhotos, setSeeAllPhotos] = useState(false); const [seeAllPhotos, setSeeAllPhotos] = useState(false);
const [currentPhotos, setCurrentPhotos] = useState([]); const [currentPhotos, setCurrentPhotos] = useState([]);
const [photos, setPhotos] = useState([]); const [photos, setPhotos] = useState([]);
@ -46,7 +46,7 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
const showPhotos = (photos, index) => { const showPhotos = (photos, index) => {
const mediaDom = document.createElement("div"); const mediaDom = document.createElement("div");
document.body.appendChild(mediaDom); document.body.appendChild(mediaDom);
mediaDom.className = `${photos[index]?.type == "hid" ? "photos-body" : ""}`; mediaDom.className = `${photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"}`;
ImageViewer.Multi.show({ ImageViewer.Multi.show({
images: photos.map((item) => item?.url), images: photos.map((item) => item?.url),
defaultIndex: index, defaultIndex: index,
@ -55,7 +55,7 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
getContainer: mediaDom, getContainer: mediaDom,
onIndexChange: (index) => { onIndexChange: (index) => {
mediaDom.className = `${ mediaDom.className = `${
photos[index]?.type == "hid" ? "photos-body" : "" photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
}`; }`;
}, },
afterClose: () => { afterClose: () => {
@ -181,7 +181,8 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
height={currentPhotos.length > 1 ? "24vw" : "auto"} height={currentPhotos.length > 1 ? "24vw" : "auto"}
className={`rounded max-w-full ${ className={`rounded max-w-full ${
item?.type == "hid" || item?.type == "hid" ||
(item?.type == "video" && !isUnlocked) (
item?.type == "video" && !isUnlocked && type=="space")
? "imageBlur" ? "imageBlur"
: "" : ""
}`} }`}

View File

@ -135,6 +135,7 @@ export default function PostItem({
media={data.media_component} media={data.media_component}
isUnlocked={data.is_zone_moment_unlocked} isUnlocked={data.is_zone_moment_unlocked}
mediaAmount={data.media_amount} mediaAmount={data.media_amount}
type={type}
/> />
)} )}
{type == "space" && !!data.c_type && ( {type == "space" && !!data.c_type && (

View File

@ -1,7 +1,28 @@
import { checkAuth } from "@/utils/auth"; import { checkAuth } from "@/utils/auth";
import { redirect } from "next/navigation"; import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { get } from "@/utils/storeInfo";
export default function WithAuth(WrappedComponent) { export default function WithAuth(WrappedComponent) {
const router = useRouter();
return checkAuth() ? WrappedComponent : redirect("/login"); useEffect(() => {
checkLogin();
// console.log("isLogin",isLogin)
}, []);
const checkLogin = async () => {
const hasToken = get("token");
console.log("hasToken", hasToken);
if (hasToken) {
const hasToken = get("token");
console.log("hasToken", hasToken);
if (hasToken) {
const currentIsLogin = await checkAuth();
if (!currentIsLogin) {
router.push("/login")
}
}
}else{
router.push("/login")
}
};
return WrappedComponent;
} }

View File

@ -44,6 +44,7 @@ export default function customFetch(method, url, options = {}, mid) {
resolve(data); resolve(data);
}) })
.catch((error) => { .catch((error) => {
console.log("error",error)
Toast.show({ Toast.show({
icon: "fail", icon: "fail",
content: error.toString(), content: error.toString(),

View File

@ -5,7 +5,7 @@ export function get(key){
let data = localStorage.getItem(key); let data = localStorage.getItem(key);
// console.log(key,data) // console.log(key,data)
return data ? JSON.parse(data) : {}; return data ? JSON.parse(data) : null;
} }
export function remove(key){ export function remove(key){
localStorage.removeItem(key) localStorage.removeItem(key)