diff --git a/src/pages/home/components/adware.tsx b/src/pages/home/components/adware.tsx index f30f547..16724f8 100644 --- a/src/pages/home/components/adware.tsx +++ b/src/pages/home/components/adware.tsx @@ -15,7 +15,6 @@ const Adware: FC = ({data, only_flag, width}) => { const [adverts, setAdverts] = useState([]) const [space, setSpace] = useState(null) - useEffect(() => { const res = data.find(d => d.only_flag === only_flag) setSpace(res) @@ -31,36 +30,40 @@ const Adware: FC = ({data, only_flag, width}) => { } return ( - - { - adverts.length === 1 && jumpAdware(adverts[0].image_path)} - width={width} - height={(space.height / space.width) * width}/> - } + <> { - adverts.length > 1 && - {adverts.map(d => - 0 && + { + adverts.length === 1 && jumpAdware(adverts[0].image_path)} width={width} - height={(space.height / space.width) * width} - onClick={() => jumpAdware(d.image_path)}/> - )} - + height={(space.height / space.width) * width}/> + } + { + adverts.length > 1 && + {adverts.map(d => + jumpAdware(d.image_path)}/> + )} + + } + } - + ) } diff --git a/src/pages/home/components/feature_recommended.tsx b/src/pages/home/components/feature_recommended.tsx index 8aef137..289b9bb 100644 --- a/src/pages/home/components/feature_recommended.tsx +++ b/src/pages/home/components/feature_recommended.tsx @@ -151,7 +151,7 @@ const FeatureRecommended: FC = (props) => { return ( - {data.every(d => d.data.length) && + { data.map(d => = (props) => { className={styles.featureTitle} onClick={() => jump(d.url)} src={d.titleUrl}/> { - d.data.map((c, index) => 0 && d.data.map((c, index) => jump(d.detailsUrl + c.path, c.id, d.type)}> @@ -177,7 +177,7 @@ const FeatureRecommended: FC = (props) => { } ) } - } + ) } diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx index 2cd8a6c..b91c4b0 100644 --- a/src/pages/home/home.tsx +++ b/src/pages/home/home.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useState} from "react"; +import {FC, useState} from "react"; import {View} from "@tarojs/components"; import styles from "./home.module.scss"; import Adware from "@/pages/home/components/adware"; @@ -20,11 +20,11 @@ const Home: FC = () => { Taro.navigateTo({url: '/pages/login/login'}) } - useEffect(() => { + Taro.useLoad(() => { HomeApi.home().then(res => { setData(res) }) - }, []) + }) return ( @@ -37,7 +37,7 @@ const Home: FC = () => { skill={data?.skill || []} /> - + {data && } { !token && 登录后享受更多学习服务~