Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit ce86a46

Browse files
committed
chore: merge branch 'dev'
2 parents e584fbe + 855f5f1 commit ce86a46

File tree

22 files changed

+330
-68
lines changed

22 files changed

+330
-68
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

components/Pagi/index.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ import { Pagination } from 'antd'
99
import PropTypes from 'prop-types'
1010

1111
import { 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 */
1522
const 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
)}

components/Pagi/styles/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
1123
export const CustomText = styled.a`
1224
${cs.media.tablet`display: none`};
1325
`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
`

containers/Doraemon/ResultsList.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import R from 'ramda'
3+
import Highlighter from 'react-highlight-words'
34

45
import { ICON_CMD } from 'config'
56

@@ -29,7 +30,7 @@ const HintIcon = ({ index, active, cur, length }) => {
2930
return null
3031
}
3132

32-
const ResultsList = ({ searchThread, suggestions, activeRaw }) => (
33+
const ResultsList = ({ searchValue, searchThread, suggestions, activeRaw }) => (
3334
<Wrapper>
3435
<SuggestionWrapper empty={suggestions.length === 0}>
3536
{suggestions.map((suggestion, i) => (
@@ -47,7 +48,14 @@ const ResultsList = ({ searchThread, suggestions, activeRaw }) => (
4748
searchThread={searchThread}
4849
/>
4950
<ContentWraper>
50-
<Title>{suggestion.title}</Title>
51+
<Title>
52+
<Highlighter
53+
highlightClassName="doramon-search-highlighter"
54+
searchWords={[searchValue]}
55+
autoEscape
56+
textToHighlight={suggestion.title}
57+
/>
58+
</Title>
5159
<Desc>{suggestion.desc}</Desc>
5260
</ContentWraper>
5361
<HintIcon

containers/Doraemon/ThreadSelectBar.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react'
22

33
// import { ICON_CMD } from 'config'
44
import { THREAD } from 'utils'
5-
import { Wrapper, Selector } from './styles/thread_select_bar'
5+
import {
6+
Wrapper,
7+
Selector,
8+
VideoSelector,
9+
RepoSelector,
10+
} from './styles/thread_select_bar'
611
import { searchThreadOnChange } from './logic'
712

813
const ThreadSelectBar = ({ active }) => (
@@ -19,18 +24,18 @@ const ThreadSelectBar = ({ active }) => (
1924
>
2025
帖子
2126
</Selector>
22-
<Selector
27+
<VideoSelector
2328
onClick={searchThreadOnChange.bind(this, THREAD.VIDEO)}
2429
active={active === THREAD.VIDEO}
2530
>
2631
视频
27-
</Selector>
28-
<Selector
32+
</VideoSelector>
33+
<RepoSelector
2934
onClick={searchThreadOnChange.bind(this, THREAD.REPO)}
3035
active={active === THREAD.REPO}
3136
>
3237
项目
33-
</Selector>
38+
</RepoSelector>
3439
<Selector
3540
onClick={searchThreadOnChange.bind(this, THREAD.JOB)}
3641
active={active === THREAD.JOB}

containers/Doraemon/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class DoraemonContainer extends React.Component {
3535
const { doraemon } = this.props
3636
const {
3737
inputValue,
38+
inputValueRaw,
3839
suggestions,
3940
activeRaw,
4041
prefix,
@@ -64,6 +65,7 @@ class DoraemonContainer extends React.Component {
6465
<AlertBar value={inputValue} searchThread={searchThread} />
6566
)}
6667
<ResultsList
68+
searchValue={inputValueRaw}
6769
suggestions={suggestions}
6870
activeRaw={activeRaw}
6971
searchThread={searchThread}

containers/Doraemon/store.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ const DoraemonStore = t
7979
get curRoute() {
8080
return self.root.curRoute
8181
},
82+
get inputValueRaw() {
83+
if (R.startsWith('/', self.inputValue)) {
84+
return R.last(self.inputValue.split('/'))
85+
}
86+
if (R.startsWith('@', self.inputValue)) return self.inputValue.slice(1)
87+
88+
return self.inputValue
89+
},
8290
get curCmdChain() {
8391
if (!self.cmdChain && self.activeRaw) {
8492
return [self.activeRaw]

containers/Doraemon/styles/results_list.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ export const Title = styled.div`
112112
> a {
113113
color: ${theme('shell.link')};
114114
}
115+
116+
${cs.truncate('400px')};
117+
${cs.media.mobile`
118+
${cs.truncate('200px')};
119+
`};
115120
`
116121
export const Desc = styled.div`
117122
color: ${theme('shell.desc')};

containers/Doraemon/styles/thread_select_bar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export const Selector = styled.div`
2727
}
2828
`
2929

30+
export const VideoSelector = styled(Selector)`
31+
${cs.media.mobile`display: none;`};
32+
`
33+
export const RepoSelector = styled(Selector)`
34+
${cs.media.mobile`display: none;`};
35+
`
36+
3037
export const Info = styled.div`
3138
${cs.flexGrow()};
3239
`

0 commit comments

Comments
 (0)