修复广场关注

This commit is contained in:
al 2024-08-05 21:10:36 +08:00
parent a8ac8007bf
commit 7a80240273
8 changed files with 112 additions and 80 deletions

View File

@ -77,23 +77,23 @@ export default function RootLayout({ children }) {
{/* <!-- 这里要注意,这里图片的尺寸要和设备的静态图片显示尺寸完全对应,差一个像素都会导致启动动画无法显示 --> */} {/* <!-- 这里要注意,这里图片的尺寸要和设备的静态图片显示尺寸完全对应,差一个像素都会导致启动动画无法显示 --> */}
{/* <!-- 下面列举了iPhone的所有尺寸ps:为了方便大家就全部贴出来了!!) --> */} {/* <!-- 下面列举了iPhone的所有尺寸ps:为了方便大家就全部贴出来了!!) --> */}
{/* <!-- iPhone 678 startup image @2x--> */} {/* <!-- iPhone 678 startup image @2x--> */}
<link href={"/images/launchPage/750_1334.png"} media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/750_1334.png"} media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/>
{/* <!-- iPhone 678p startup image @3x--> */} {/* <!-- iPhone 678p startup image @3x--> */}
<link href={"/images/launchPage/1242_2208.png"} media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1242_2208.png"} media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
{/* <!-- iPhone X Xs startup image @3x--> */} {/* <!-- iPhone X Xs startup image @3x--> */}
<link href={"/images/launchPage/1125_2436.png"} media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1125_2436.png"} media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
{/* <!-- iPhone XR startup image @2X --> */} {/* <!-- iPhone XR startup image @2X --> */}
<link href={"/images/launchPage/828_1792.png"} media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/828_1792.png"} media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/>
{/* <!-- iPhone XR Max startup image @3x--> */} {/* <!-- iPhone XR Max startup image @3x--> */}
<link href={"/images/launchPage/640_960.png"} media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/640_960.png"} media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/640_1136.png"} media="(device-width: 320px) and (device-height: 568) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/640_1136.png"} media="(device-width: 320px) and (device-height: 568) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1080_1920.png"} media="(device-width: 360px) and (device-height: 640px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1080_1920.png"} media="(device-width: 360px) and (device-height: 640px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1080_2340.png"} media="(device-width: 360px) and (device-height: 780px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1080_2340.png"} media="(device-width: 360px) and (device-height: 780px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1170_2532.png"} media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1170_2532.png"} media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1179_2556.png"} media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1179_2556.png"} media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1242_2688.png"} media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1242_2688.png"} media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1284_2778.png"} media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1284_2778.png"} media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
<link href={"/images/launchPage/1290_2796.png"} media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/> <link href={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/images/launchPage/1290_2796.png"} media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3)" rel="apple-touch-startup-image"/>
</head> </head>
<body className={`${inter.className} h-full`}> <body className={`${inter.className} h-full`}>
<main className={`w-full bg-deepBg h-full`}> <main className={`w-full bg-deepBg h-full`}>

View File

@ -19,7 +19,7 @@ import { saveUserInfo, removeUserInfo } from "@/utils/storeInfo";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { cryptoPassword } from "@/utils/crypto"; import { cryptoPassword } from "@/utils/crypto";
import requireAPI from "@/utils/requireAPI"; import requireAPI from "@/utils/requireAPI";
import { signOut, signIn } from "@/utils/auth"; import { signOut, signIn,checkAuth } from "@/utils/auth";
/* /*
params格式 params格式
{ {
@ -55,8 +55,16 @@ function Login({ handleLogin }) {
setDeviceType("pc"); setDeviceType("pc");
} }
handleLogin({ isSignin: false, userToken: null }); handleLogin({ isSignin: false, userToken: null });
signOut(); checkAuth().then(res=>{
if(res){
router.push("/")
}else{
removeUserInfo(); removeUserInfo();
// signOut();
}
})
}, []); }, []);
useEffect(() => { useEffect(() => {
let interval; let interval;
@ -448,7 +456,7 @@ const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {
const BottomBox = () => { const BottomBox = () => {
const router = useRouter(); const router = useRouter();
return ( return (
<div className="fixed bottom-0 w-full p-6 "> <div className="w-full p-6 ">
<div className="p-3 rounded-md flex justify-between items-center bg-[#ffffff17]"> <div className="p-3 rounded-md flex justify-between items-center bg-[#ffffff17]">
<div> <div>
<p className="">铁粉空间APP可以下载啦</p> <p className="">铁粉空间APP可以下载啦</p>

View File

@ -322,6 +322,31 @@ const My = () => {
className="h-4 text-gray-300" className="h-4 text-gray-300"
/> />
</li> */} </li> */}
<li
className="flex justify-between items-center p-3 py-2"
onClick={() => {
Toast.show({
icon: "success",
content: "请下载安装app后进行申请入驻",
position: "top",
});
}}
>
<div className="flex items-center">
<Image
className="mr-2"
width={32}
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/icons/32DP/join.png"}
placeholder=""
/>
<span className="text-base">申请入驻</span>
</div>
<FontAwesomeIcon
icon={faAngleRight}
size="sm"
className="h-4 text-gray-300"
/>
</li>
<li <li
className="flex justify-between items-center p-3 py-2" className="flex justify-between items-center p-3 py-2"
onClick={() => { onClick={() => {

View File

@ -7,14 +7,7 @@ import React, {
useImperativeHandle, useImperativeHandle,
forwardRef, forwardRef,
} from "react"; } from "react";
import { import { Tabs, Swiper, Toast, InfiniteScroll, List, Image } from "antd-mobile";
Tabs,
Swiper,
Toast,
InfiniteScroll,
List,
Image,
} from "antd-mobile";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faRefresh } from "@fortawesome/free-solid-svg-icons"; import { faRefresh } from "@fortawesome/free-solid-svg-icons";
import PostItem from "../components/PostItem"; import PostItem from "../components/PostItem";
@ -24,10 +17,9 @@ import PostItemSkeleton from "@/components/skeletons/PostItemSkeleton";
import Link from "next/link"; import Link from "next/link";
import requireAPI from "@/utils/requireAPI"; import requireAPI from "@/utils/requireAPI";
import Empty from "@/components/Empty"; import Empty from "@/components/Empty";
import {get} from "@/utils/storeInfo" import { get } from "@/utils/storeInfo";
import {useSearchParams} from "next/navigation" import { useSearchParams } from "next/navigation";
import StreamerNavigator from "@/components/StreamerNavigator"; import StreamerNavigator from "@/components/StreamerNavigator";
import { checkAuth } from "@/utils/auth";
const variables = { const variables = {
"@active-line-color": "#f00", // 将主题色改为红色 "@active-line-color": "#f00", // 将主题色改为红色
}; };
@ -44,7 +36,6 @@ export default function Home() {
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const swiperRef = useRef(null); const swiperRef = useRef(null);
const [activeIndex, setActiveIndex] = useState(0); const [activeIndex, setActiveIndex] = useState(0);
const [visible, setVisible] = useState(false);
const [scrollHeight, setScrollHeight] = useState(0); const [scrollHeight, setScrollHeight] = useState(0);
// 获取屏幕高度 // 获取屏幕高度
@ -52,11 +43,6 @@ export default function Home() {
useEffect(() => { useEffect(() => {
setScrollHeight(window.innerHeight); setScrollHeight(window.innerHeight);
// getData(0) // getData(0)
checkAuth().then(res=>{
if(res && get("inviter")){
setVisible(true)
}
})
}, []); }, []);
const childrenFunc = () => { const childrenFunc = () => {
if (!activeIndex) { if (!activeIndex) {
@ -93,7 +79,9 @@ export default function Home() {
href="search" href="search"
className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full" className="w-9 h-9 flex items-center justify-center bg-[#FFFFFF1A] rounded-full"
> >
<Image src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL+"/icons/search.png"} /> <Image
src={process.env.NEXT_PUBLIC_WEB_ASSETS_URL + "/icons/search.png"}
/>
</Link> </Link>
</div> </div>
<Swiper <Swiper
@ -125,7 +113,7 @@ export default function Home() {
> >
<FontAwesomeIcon icon={faRefresh} size="xl" /> <FontAwesomeIcon icon={faRefresh} size="xl" />
</div> </div>
<StreamerNavigator visible={visible} setVisible={setVisible} userId={Number(get("inviter"))}/> <StreamerNavigator userId={Number(get("inviter"))} />
</div> </div>
); );
} }
@ -154,7 +142,7 @@ const RecommPostList = forwardRef(({ scrollHeight }, ref) => {
// throw new Error("刷新失败"); // throw new Error("刷新失败");
const list = await getRecommPostList(1); const list = await getRecommPostList(1);
setCommenPostList(list); setCommenPostList(list);
setHasMore(true) setHasMore(true);
} }
async function loadMore() { async function loadMore() {
const list = await getRecommPostList(0); const list = await getRecommPostList(0);
@ -193,7 +181,7 @@ const RecommPostList = forwardRef(({ scrollHeight }, ref) => {
)} )}
{commenPostList?.map((item) => ( {commenPostList?.map((item) => (
<List.Item key={item.id} className="!p-0"> <List.Item key={item.id} className="!p-0">
<PostItem type="post" data={item} date={new Date(item.ct*1000)}/> <PostItem type="post" data={item} date={new Date(item.ct * 1000)} />
</List.Item> </List.Item>
))} ))}
{commenPostList?.length == 0 && !loading && ( {commenPostList?.length == 0 && !loading && (
@ -217,9 +205,11 @@ const FollowPostList = forwardRef(({ scrollHeight }, ref) => {
const [followPostList, setFollowPostList] = useState([]); const [followPostList, setFollowPostList] = useState([]);
const [currentTime, setCurrentTime] = useState(); const [currentTime, setCurrentTime] = useState();
const [offset, setOffset] = useState(0); const [offset, setOffset] = useState(0);
const [ids, setIds] = useState([]);
useEffect(() => { useEffect(() => {
getFollowPostList().then((res) => { getFollowIds().then((res) => {
setFollowPostList(res); setIds(res)
getFollowPostList(res,0)
}); });
}, []); }, []);
useImperativeHandle( useImperativeHandle(
@ -237,33 +227,46 @@ const FollowPostList = forwardRef(({ scrollHeight }, ref) => {
// }); // });
// throw new Error("刷新失败"); // throw new Error("刷新失败");
// getRecommPostList(1); // getRecommPostList(1);
const list = await getFollowPostList(1); await getFollowPostList(ids,0);
setFollowPostList(list);
} }
async function loadMore() { async function loadMore() {
const list = await getFollowPostList(); await getFollowPostList(ids,offset);
const newList = [...followPostList, ...list]; // const newList = [...followPostList, ...list];
setOffset(newList.length / 4); // setFollowPostList(newList);
setFollowPostList(newList);
} }
const getFollowPostList = async () => { const getFollowIds = async () => {
setLoading(true); setLoading(true);
setCurrentTime(Math.floor(new Date().getTime() / 1000)); setCurrentTime(Math.floor(new Date().getTime() / 1000));
const data = await requireAPI("POST", "/api/account_relation/list_follow", { const data = await requireAPI(
"POST",
"/api/account_relation/list_follow",
{
body: { offset, limit: 4 }, body: { offset, limit: 4 },
}, true); },
setHasMore(data.data.list.length > 0); true
);
return data;
};
const getFollowPostList = async (data,offset) => {
if (data.data.list.length > 0) { if (data.data.list.length > 0) {
//查关注主播展示资料 //查关注主播展示资料
const followsResponse = const followsResponse = await requireAPI(
await requireAPI("POST", "/api/moment/list_by_mids", { "POST",
"/api/moment/list_by_mids",
{
body: { body: {
offset, offset,
limit: 4, limit: 4,
ct_upper_bound: currentTime, ct_upper_bound: currentTime,
mids: data.data.list?.map((item) => item.obj_mid), mids: data.data.list?.map((item) => item.obj_mid),
}, },
}); }
);
// debugger;
console.log("offset",followsResponse.data.offset)
setOffset(followsResponse.data.offset);
setHasMore(followsResponse.data.more);
setLoading(false); setLoading(false);
if (data.ret == -1) { if (data.ret == -1) {
Toast.show({ Toast.show({
@ -272,12 +275,13 @@ const FollowPostList = forwardRef(({ scrollHeight }, ref) => {
position: "top", position: "top",
}); });
} else { } else {
return followsResponse.data.list; setFollowPostList(old=>[...old,...followsResponse.data.list]);
} }
} else { } else {
setLoading(false); setLoading(false);
} }
}; };
return ( return (
<div className="px-4 pb-20"> <div className="px-4 pb-20">
{/* <PullToRefresh onRefresh={doRefresh}> */} {/* <PullToRefresh onRefresh={doRefresh}> */}
@ -293,13 +297,13 @@ const FollowPostList = forwardRef(({ scrollHeight }, ref) => {
)} )}
{followPostList?.map((item, index) => ( {followPostList?.map((item, index) => (
<List.Item key={item.id + "_" + index} className="!p-0"> <List.Item key={item.id + "_" + index} className="!p-0">
<PostItem type="post" data={item} date={new Date(item.ct*1000)}/> <PostItem type="post" data={item} date={new Date(item.ct * 1000)} />
</List.Item> </List.Item>
))} ))}
{!followPostList?.length && ( {!followPostList?.length && (
<div <div
className={`flex flex-col items-center justify-center`} className={`flex flex-col items-center justify-center`}
style={{ height: `${scrollHeight-98}px` }} style={{ height: `${scrollHeight - 98}px` }}
> >
<Empty type="nodata" /> <Empty type="nodata" />
</div> </div>

View File

@ -6,9 +6,7 @@ import {getStreamer} from "@/api/streamer";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import {remove} from "@/utils/storeInfo" import {remove} from "@/utils/storeInfo"
export default function StreamerNavigator({ export default function StreamerNavigator({
visible,
userId, userId,
setVisible
}) { }) {
const [streamerInfo,setStreamerInfo] = useState(null); const [streamerInfo,setStreamerInfo] = useState(null);
const router = useRouter(); const router = useRouter();
@ -20,10 +18,10 @@ export default function StreamerNavigator({
},[]) },[])
const handleCloseMask = ()=>{ const handleCloseMask = ()=>{
remove("inviter") remove("inviter")
setVisible(false) setStreamerInfo(null)
} }
return ( return (
<Mask visible={visible} onMaskClick={handleCloseMask}> <Mask visible={(!!streamerInfo)} onMaskClick={handleCloseMask}>
<div <div
className="fixed top-[20%] left-[12.5%] w-3/4 flex-1 justify-center items-center " className="fixed top-[20%] left-[12.5%] w-3/4 flex-1 justify-center items-center "

View File

@ -4,7 +4,7 @@ const nextConfig = {
return [ return [
{ {
source: "/api/:path*", source: "/api/:path*",
destination: "https://h5api.tiefen.fun/api/:path*", destination: "https://testapi.tiefen.fun/api/:path*",
}, },
]; ];
}, },

View File

@ -1,15 +1,12 @@
import { setCookie, deleteCookie, getCookie } from "cookies-next"; import { setCookie, deleteCookie, getCookie } from "cookies-next";
import requireAPI from "./requireAPI"; import requireAPI from "./requireAPI";
import {get} from "./storeInfo" import { get } from "./storeInfo";
export async function checkAuth() { export async function checkAuth() {
try { try {
const data = await requireAPI("POST", `/api/login/validate`); const data = await requireAPI("POST", `/api/login/validate`);
if (data.ret === -1) { return data.ret === 1;
return false;
}
return true;
} catch (e) { } catch (e) {
console.warn(e); console.log(e);
} }
} }
@ -23,9 +20,9 @@ export function signOut() {
deleteCookie("mid"); deleteCookie("mid");
} }
export function checkRole(){ export function checkRole() {
const account = get("account"); const account = get("account");
const role = account.role; const role = account?.role;
const isVip = account.is_a_member; const isVip = account?.is_a_member;
return (role !== 0 || isVip === 1); return role !== 0 || isVip === 1;
}; }

View File

@ -24,7 +24,7 @@ export default function customFetch(method, url, options = {}, mid) {
newBody.mid = mid; newBody.mid = mid;
} }
const body = JSON.stringify({ ...base, ...newBody }); const body = JSON.stringify({ ...base, ...newBody });
// console.log("newBody", body,url); console.log("newBody", body,url);
// 合并选项 // 合并选项
const mergedOptions = { ...defaultOptions, body }; const mergedOptions = { ...defaultOptions, body };
@ -33,10 +33,10 @@ export default function customFetch(method, url, options = {}, mid) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fetch(url, mergedOptions) fetch(url, mergedOptions)
.then((response) => { .then((response) => {
// 检查响应状态码 // // 检查响应状态码
if (!response.ok) { // if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); // throw new Error(`HTTP error! status: ${response.status}`);
} // }
// 解析 JSON 响应 // 解析 JSON 响应
return response.json(); return response.json();
}) })