|
| 1 | +import React from "react"; |
| 2 | +import { Button, Card, Col, Row, Space, Typography } from "antd"; |
| 3 | +import { RightCircleOutlined } from "@ant-design/icons"; |
| 4 | +import { PageProps } from ".."; |
| 5 | +import { useUrl } from "@/api/hooks/url"; |
| 6 | +import { useNavigate } from "react-router-dom"; |
| 7 | + |
| 8 | +/* ---------------- 接口和类型定义 ---------------- */ |
| 9 | +type ResourceProps = { |
| 10 | + image: string; |
| 11 | + title: string; |
| 12 | + text: string; |
| 13 | + link: string; |
| 14 | + reverse?: boolean; |
| 15 | +}; |
| 16 | + |
| 17 | +const Resource: React.FC<ResourceProps> = ({ |
| 18 | + image, |
| 19 | + title, |
| 20 | + text, |
| 21 | + link, |
| 22 | + reverse, |
| 23 | +}) => { |
| 24 | + const navigate = useNavigate(); |
| 25 | + |
| 26 | + return ( |
| 27 | + <Card |
| 28 | + bordered |
| 29 | + style={{ |
| 30 | + margin: "1rem", |
| 31 | + borderRadius: "1rem", |
| 32 | + display: "flex", |
| 33 | + flexDirection: "column", |
| 34 | + height: "250px", |
| 35 | + justifyContent: "center", |
| 36 | + }} |
| 37 | + > |
| 38 | + <Row |
| 39 | + justify="space-between" |
| 40 | + align="middle" |
| 41 | + style={{ |
| 42 | + flexDirection: reverse ? "row-reverse" : "row", |
| 43 | + height: "100%", |
| 44 | + }} |
| 45 | + > |
| 46 | + <Col xs={24} sm={12} md={10}> |
| 47 | + <img |
| 48 | + src={image} |
| 49 | + alt="resource" |
| 50 | + style={{ |
| 51 | + width: "100%", |
| 52 | + height: "auto", |
| 53 | + borderRadius: "1rem", |
| 54 | + }} |
| 55 | + /> |
| 56 | + </Col> |
| 57 | + <Col xs={24} sm={12} md={13}> |
| 58 | + <Space direction="vertical" size="small" style={{ width: "100%" }}> |
| 59 | + <Title level={3} style={{ marginBottom: "0.5rem" }}> |
| 60 | + {title} |
| 61 | + </Title> |
| 62 | + <Paragraph style={{ fontSize: "14px", marginBottom: "1rem" }}> |
| 63 | + {text} |
| 64 | + </Paragraph> |
| 65 | + {link && ( |
| 66 | + <Button |
| 67 | + type="primary" |
| 68 | + onClick={() => |
| 69 | + link.includes("http") |
| 70 | + ? window.open(link, "_blank") |
| 71 | + : navigate(link) |
| 72 | + } |
| 73 | + > |
| 74 | + <RightCircleOutlined /> |
| 75 | + 点击进入 |
| 76 | + </Button> |
| 77 | + )} |
| 78 | + </Space> |
| 79 | + </Col> |
| 80 | + </Row> |
| 81 | + </Card> |
| 82 | + ); |
| 83 | +}; |
| 84 | + |
| 85 | +/* ---------------- 不随渲染刷新的常量 ---------------- */ |
| 86 | +const { Title, Paragraph } = Typography; |
| 87 | + |
| 88 | +/* ---------------- 主页面 ---------------- */ |
| 89 | +const TourGuidePage: React.FC<PageProps> = () => { |
| 90 | + /* ---------------- States 和常量 Hooks ---------------- */ |
| 91 | + const url = useUrl(); |
| 92 | + |
| 93 | + /* ---------------- 页面组件 ---------------- */ |
| 94 | + return ( |
| 95 | + <div style={{ padding: "1rem" }}> |
| 96 | + <Row gutter={[16, 16]}> |
| 97 | + <Col xs={24} sm={12} md={12}> |
| 98 | + <Resource |
| 99 | + image={`${process.env.REACT_APP_STATIC_URL}/public/images/help_contest.jpg`} |
| 100 | + title="赛事互动站" |
| 101 | + text="新版官网致力于为所有选手和赛事组织者提供更好的参赛体验,包括试玩功能、数据透视功能、以及全新设计的页面布局,让您轻松上手,玩转比赛!" |
| 102 | + link={url.link("contest/list", "site")} |
| 103 | + /> |
| 104 | + </Col> |
| 105 | + <Col xs={24} sm={12} md={12}> |
| 106 | + <Resource |
| 107 | + image={`${process.env.REACT_APP_STATIC_URL}/public/images/help_info.jpg`} |
| 108 | + title="信息化平台" |
| 109 | + text="信息化平台是与院系合作建设的学生操作平台,目前囊括了新生导师和奖学金申请功能,未来将覆盖学习生活的更多方面,敬请期待!" |
| 110 | + link={url.link("info/notices", "site")} |
| 111 | + /> |
| 112 | + </Col> |
| 113 | + <Col xs={24} sm={12} md={12}> |
| 114 | + <Resource |
| 115 | + image={`${process.env.REACT_APP_STATIC_URL}/public/images/help_share.jpg`} |
| 116 | + title="资源共享站" |
| 117 | + text="资源共享站是新版官网整合而成的全新子站,希望为同学们接入更多有趣的资源,包括课程资料、技术分享、以及娱乐活动等,让您的大学生活更加丰富多彩!" |
| 118 | + link={url.link("share/intro", "site")} |
| 119 | + /> |
| 120 | + </Col> |
| 121 | + <Col xs={24} sm={12} md={12}> |
| 122 | + <Resource |
| 123 | + image={`${process.env.REACT_APP_STATIC_URL}/public/images/help_dark.jpg`} |
| 124 | + title="暗色模式" |
| 125 | + text="此外还有炫酷的暗色模式,既护眼又极客,快来体验一下吧!" |
| 126 | + link="" |
| 127 | + /> |
| 128 | + </Col> |
| 129 | + </Row> |
| 130 | + </div> |
| 131 | + ); |
| 132 | +}; |
| 133 | + |
| 134 | +export default TourGuidePage; |
0 commit comments