diff --git a/src/components/side/Ad.tsx b/src/components/side/Ad.tsx index 39b8b878..4e49edd5 100644 --- a/src/components/side/Ad.tsx +++ b/src/components/side/Ad.tsx @@ -11,8 +11,30 @@ interface Props { className?: string; } -export default function Ad(props: Props) { +interface RewardAdContentProps { + data: AdvertItem; +} + +interface ImageAdContentProps { + data: AdvertItem; + handleClose: MouseEventHandler; +} + +const ImageAdContent = ({ data, handleClose }: ImageAdContentProps) => ( +
+ ad +
+ +
+
+); + +export default function Ad({ data, className }: Props) { const [visible, setVisible] = useState(true); + const handleClose: MouseEventHandler = (e) => { e.preventDefault(); setVisible(false); @@ -22,95 +44,80 @@ export default function Ad(props: Props) { redirectRecord('', aid, 'ad'); }; + if (!visible) return null; + + const ProgressBar = ({ percent }: { percent: number }) => ( +
+
+
+ ); + + const AdTargetInfo = ({ data }: { data: AdvertItem }) => ( +
+ + {data.year ? '距离下个目标还差' : '距离目标还差'} + {100 - data.percent}% + + +
+ ); + + const AdServerInfo = ({ data }: { data: AdvertItem }) => ( +
+ + 服务器还剩{data.day}天 + +
+ + +{data.year}年 + +
+ +
+ ); + + const RewardAdDetail = ({ data }: { data: AdvertItem }) => ( + <> +
+ +
+
+ +
+ + ); + + const RewardAdContent = ({ data }: RewardAdContentProps) => ( +
+ ad +
+
+ 微信扫码赞助本站 +
+
+ +
+
+
+ ); + return ( - {isLicenseDetail && ( + {ShowIsLicenseDetail && (
内容整理自 spdx 和 GitHub 网站,并遵循 => { if (lid) { url = `/repository/recommend/?lid=${lid}`; } - const data = await fetcher(makeUrl(url)); + const data = await fetcher(makeUrl(url)); return data; } catch (error) { console.error(error); diff --git a/src/types/home.tsx b/src/types/home.tsx index 22505289..73102cd9 100644 --- a/src/types/home.tsx +++ b/src/types/home.tsx @@ -34,7 +34,7 @@ export interface Stats { user_total: number; } -export interface RecomemndItem { +export interface RecommendItem { rid: string; name: string; full_name: string; @@ -46,10 +46,10 @@ export interface RecomemndItem { stars_str: string; } -export interface RecomemndItems { +export interface RecommendItems { success: boolean; total: number; - data: RecomemndItem[]; + data: RecommendItem[]; } export interface AdvertItem {