Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ranger page mobile adapet #1199

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/pages/ranger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { Navigation,Pagination } from 'swiper/modules';
import 'swiper/swiper-bundle.css';
import { useState, useRef, useEffect } from 'react'
import ThirdPartyComponent from './_components/map';
import { judgeIsMobile } from '../../utils/jsUtils';
import './style.css'

function getImgUrl(str) {
return `https://files.seeedstudio.com/wiki/ranger/${str}.png`
}
Expand Down Expand Up @@ -206,7 +208,7 @@ function getData(key) {
return res.data
})
}
const rangerPersonRender = () => {
const rangerPersonRender = (isMobile) => {
const [list, setList] = useState([]);
function queryData() {
getData('wiki-ranger-person').then((rangerList) => {
Expand All @@ -228,7 +230,7 @@ const rangerPersonRender = () => {
modules={[Navigation,Pagination]}
autoplay={true}
navigation
slidesPerView={2} // 每次显示的幻灯片数量
slidesPerView={isMobile?1:2} // 每次显示的幻灯片数量
spaceBetween={40}
pagination={{ clickable: true }} // 显示分页器
>
Expand All @@ -253,7 +255,7 @@ const rangerPersonRender = () => {
</div>
)
}
const blogPersonRender = () => {
const blogPersonRender = (isMobile) => {
const [list, setList] = useState([]);
function queryData() {
getData('wiki-ranger-blog').then((rangerList) => {
Expand All @@ -272,7 +274,7 @@ const blogPersonRender = () => {
<Swiper
modules={[Navigation,Pagination]}
navigation
slidesPerView={3} // 每次显示的幻灯片数量
slidesPerView={isMobile?1:3} // 每次显示的幻灯片数量
spaceBetween={24}
pagination={{ clickable: true }} // 显示分页器
>
Expand Down Expand Up @@ -306,16 +308,19 @@ const blogPersonRender = () => {
)
}
export default function Ranger(): JSX.Element {

const [isMobile,setIsMobile]=useState(false)
useEffect(()=>{
setIsMobile(judgeIsMobile())
},[])
return (
<Layout>
<div className={clsx(styles.ranger_page, 'ranger_page')}>
{bannerRender()}
{topJoinRender()}
{whatDoRender()}
{centerJoinRender()}
{rangerPersonRender()}
{blogPersonRender()}
{rangerPersonRender(isMobile)}
{blogPersonRender(isMobile)}
{doesRender()}
{emailRender()}
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/pages/ranger/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@
.ranger_page .swiper-pagination-bullets.swiper-pagination-horizontal {
bottom: -30px;
}
@media (max-width: 768px) {
.ranger_page .swiper-button-prev:after,
.ranger_page .swiper-button-next:after {
font-size: 30px;
}
.ranger_page .person .swiper-button-next {
right: -24px;
}
.ranger_page .person .swiper-button-prev {
left: -24px;
}
}
Loading
Loading