添加登录验证

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;
border-radius: 0.25rem;
} */
.mediaDom .adm-image-viewer-slide{
/* max-height: 90vh; */
max-width: 100vw;
}
.photos-body img{
/* max-height: 90vh; */
filter: blur(8px);

View File

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

View File

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

View File

@ -132,6 +132,7 @@ export default function Search() {
data={item}
key={item.id}
showMore={arr.length === 1}
link={`space/person_space_introduce/${item.mid}`}
/>
));
})()}
@ -139,9 +140,9 @@ export default function Search() {
)}
{streamers.length > 0 && (
<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) => (
<ZoneItem data={item} key={item.id} />
<ZoneItem data={item} key={item.id} link={`/profile/${item.mid}`}/>
))}
</div>
)}
@ -151,12 +152,12 @@ export default function Search() {
);
}
const ZoneItem = ({ data, showMore }) => {
const ZoneItem = ({ data, showMore, link }) => {
const router = useRouter();
return (
<List.Item
className="!p-0"
onClick={() => router.push(`space/person_space_introduce/${data.mid}`)}
onClick={() => router.push(link)}
key={data.id}
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 { 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 [currentPhotos, setCurrentPhotos] = useState([]);
const [photos, setPhotos] = useState([]);
@ -46,7 +46,7 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
const showPhotos = (photos, index) => {
const mediaDom = document.createElement("div");
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({
images: photos.map((item) => item?.url),
defaultIndex: index,
@ -55,7 +55,7 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
getContainer: mediaDom,
onIndexChange: (index) => {
mediaDom.className = `${
photos[index]?.type == "hid" ? "photos-body" : ""
photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
}`;
},
afterClose: () => {
@ -181,7 +181,8 @@ export default function Photos({ isUnlocked, mediaAmount, media }) {
height={currentPhotos.length > 1 ? "24vw" : "auto"}
className={`rounded max-w-full ${
item?.type == "hid" ||
(item?.type == "video" && !isUnlocked)
(
item?.type == "video" && !isUnlocked && type=="space")
? "imageBlur"
: ""
}`}

View File

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

View File

@ -1,7 +1,28 @@
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) {
return checkAuth() ? WrappedComponent : redirect("/login");
const router = useRouter();
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);
})
.catch((error) => {
console.log("error",error)
Toast.show({
icon: "fail",
content: error.toString(),

View File

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