This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +124
-8
lines changed Expand file tree Collapse file tree 4 files changed +124
-8
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { Button } from 'antd'
3+
4+ // import { ICON_CMD } from '../../config'
5+ import {
6+ Wrapper ,
7+ IndexPage ,
8+ SelectorWrapper ,
9+ CurPageNumber ,
10+ } from './styles/mobile_pagination'
11+
12+ const hasExtraPage = ( totalCount , pageSize ) => totalCount > pageSize
13+
14+ const MobilePagination = ( { current, pageSize, total, onChange } ) => {
15+ console . log ( 'current: ' , current )
16+
17+ return (
18+ < Wrapper >
19+ { current !== 1 && hasExtraPage ( total , pageSize ) ? (
20+ < IndexPage onClick = { onChange . bind ( this , 1 ) } > 首页</ IndexPage >
21+ ) : (
22+ < div />
23+ ) }
24+
25+ < SelectorWrapper >
26+ { current !== 1 && (
27+ < React . Fragment >
28+ < Button
29+ type = "primary"
30+ ghost
31+ onClick = { onChange . bind ( this , Math . max ( current - 1 , 1 ) ) }
32+ >
33+ 上一页
34+ </ Button >
35+ </ React . Fragment >
36+ ) }
37+ { current !== 1 &&
38+ current < Math . floor ( total / pageSize ) && (
39+ < CurPageNumber > { current } </ CurPageNumber >
40+ ) }
41+
42+ { current < Math . floor ( total / pageSize ) && (
43+ < Button
44+ type = "primary"
45+ ghost
46+ onClick = { onChange . bind ( this , current + 1 ) }
47+ >
48+ 下一页
49+ </ Button >
50+ ) }
51+ </ SelectorWrapper >
52+ { hasExtraPage ( total , pageSize ) && (
53+ < IndexPage onClick = { onChange . bind ( this , Math . floor ( total / pageSize ) ) } >
54+ 末页(
55+ { Math . floor ( total / pageSize ) } )
56+ </ IndexPage >
57+ ) }
58+ </ Wrapper >
59+ )
60+ }
61+
62+ export default MobilePagination
Original file line number Diff line number Diff line change @@ -9,7 +9,14 @@ import { Pagination } from 'antd'
99import PropTypes from 'prop-types'
1010
1111import { makeDebugger } from 'utils'
12- import { PagiWrapper , CustomText , BottomMsg } from './styles'
12+ import MobilePagination from './MobilePagination'
13+ import {
14+ PagiWrapper ,
15+ DesktopPagiWrapper ,
16+ MobilePagiWrapper ,
17+ CustomText ,
18+ BottomMsg ,
19+ } from './styles'
1320
1421/* eslint-disable-next-line */
1522const debug = makeDebugger ( 'c:Pagi:index' )
@@ -54,13 +61,26 @@ const Pagi = ({
5461 return (
5562 < PagiWrapper left = { left } top = { top } bottom = { bottom } >
5663 { hasExtraPage ( totalCount , pageSize ) ? (
57- < Pagination
58- current = { pageNumber }
59- pageSize = { pageSize }
60- total = { totalCount }
61- itemRender = { PagiCustomRender }
62- onChange = { onChange }
63- />
64+ < React . Fragment >
65+ < DesktopPagiWrapper >
66+ < Pagination
67+ current = { pageNumber }
68+ pageSize = { pageSize }
69+ total = { totalCount }
70+ itemRender = { PagiCustomRender }
71+ onChange = { onChange }
72+ />
73+ </ DesktopPagiWrapper >
74+ < MobilePagiWrapper >
75+ < MobilePagination
76+ current = { pageNumber }
77+ pageSize = { pageSize }
78+ total = { totalCount }
79+ itemRender = { PagiCustomRender }
80+ onChange = { onChange }
81+ />
82+ </ MobilePagiWrapper >
83+ </ React . Fragment >
6484 ) : (
6585 < BottomFooter show = { showBottomMsg } msg = { noMoreMsg } />
6686 ) }
Original file line number Diff line number Diff line change @@ -8,6 +8,18 @@ export const PagiWrapper = styled.div`
88 margin-left: ${ ( { left } ) => left } ;
99`
1010
11+ export const DesktopPagiWrapper = styled . div `
12+ ${ cs . media . mobile `
13+ display: none;
14+ ` } ;
15+ `
16+ export const MobilePagiWrapper = styled . div `
17+ display: none;
18+ ${ cs . media . mobile `
19+ display: block;
20+ ` } ;
21+ `
22+
1123export const CustomText = styled . a `
1224 ${ cs . media . tablet `display: none` } ;
1325`
Original file line number Diff line number Diff line change 1+ import styled from 'styled-components'
2+
3+ // import Img from '../../../components/Img'
4+ import { theme , cs } from '../../../utils'
5+
6+ export const Wrapper = styled . div `
7+ ${ cs . flex ( 'justify-between' ) } ;
8+ align-items: center;
9+ margin-left: 12px;
10+ margin-right: 0;
11+ `
12+ export const IndexPage = styled . div `
13+ color: ${ theme ( 'thread.articleTitle' ) } ;
14+ `
15+ export const SelectorWrapper = styled . div `
16+ ${ cs . flex ( 'align-center' ) } ;
17+ `
18+ export const CurPageNumber = styled . div `
19+ color: ${ theme ( 'thread.articleDigest' ) } ;
20+ margin-left: 4px;
21+ margin-right: 4px;
22+ `
You can’t perform that action at this time.
0 commit comments