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

Commit 6fe5989

Browse files
committed
chore: merge branch 'dev'
2 parents f20cb46 + d485ed7 commit 6fe5989

File tree

14 files changed

+129
-50
lines changed

14 files changed

+129
-50
lines changed

components/Navigator/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ import BriefView from './BriefView'
1616
const debug = makeDebugger('c:Navigator:index')
1717

1818
const Navigator = ({ curCommunity, layout, curRoute }) => {
19+
const { mainPath, subPath } = curRoute
20+
1921
if (
20-
R.contains(curRoute.mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
21-
R.contains(curRoute.subPath, [
22-
ROUTE.POST,
23-
ROUTE.JOB,
24-
ROUTE.VIDEO,
25-
ROUTE.REPO,
26-
])
22+
R.contains(mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
23+
R.contains(subPath, [ROUTE.POST, ROUTE.JOB, ROUTE.VIDEO, ROUTE.REPO])
2724
) {
2825
return <DigestView />
2926
}

components/Pagi/index.js

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

1111
import { makeDebugger } from 'utils'
12-
import { PagiWrapper, BottomMsg } from './styles'
12+
import { PagiWrapper, CustomText, BottomMsg } from './styles'
1313

1414
/* eslint-disable-next-line */
1515
const debug = makeDebugger('c:Pagi:index')
@@ -19,9 +19,9 @@ const hasExtraPage = (totalCount, pageSize) => totalCount > pageSize
1919
export const PagiCustomRender = (current, type, originalElement) => {
2020
/* eslint-disable */
2121
if (type === 'prev') {
22-
return <a>上一页</a>
22+
return <CustomText>上一页</CustomText>
2323
} else if (type === 'next') {
24-
return <a>下一页</a>
24+
return <CustomText>下一页</CustomText>
2525
}
2626
/* eslint-enable */
2727
return originalElement

components/Pagi/styles/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styled from 'styled-components'
2-
import { theme } from 'utils'
2+
import { theme, cs } from 'utils'
33

44
export const PagiWrapper = styled.div`
55
text-align: center;
@@ -8,6 +8,10 @@ export const PagiWrapper = styled.div`
88
margin-left: ${({ left }) => left};
99
`
1010

11+
export const CustomText = styled.a`
12+
${cs.media.tablet`display: none`};
13+
`
14+
1115
export const BottomMsg = styled.div`
1216
font-size: 1.1rem;
1317
color: ${theme('thread.articleDigest')};

containers/BodyLayout/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
/*
2-
*
3-
* BodyLayout
4-
*
5-
*/
2+
*
3+
* BodyLayout
4+
*
5+
*/
66

77
import React from 'react'
88
import PropTypes from 'prop-types'
99
import { inject, observer } from 'mobx-react'
1010
import keydown from 'react-keydown'
1111

1212
// import Link from 'next/link'
13+
import { ICON_CMD } from 'config'
1314

1415
import { storePlug } from 'utils'
1516

16-
import Wrapper from './styles'
17+
import { Wrapper, SubCommunitiesExpander, ExpanderIcon } from './styles'
1718
import * as logic from './logic'
1819

1920
class BodyLayoutContainer extends React.Component {
@@ -38,6 +39,9 @@ class BodyLayoutContainer extends React.Component {
3839

3940
return (
4041
<Wrapper sidebarPin={sidebarPin} noSidebar={noSidebar}>
42+
<SubCommunitiesExpander onClick={logic.queryDoraemon.bind(this, '/')}>
43+
<ExpanderIcon src={`${ICON_CMD}/expander_more.svg`} />
44+
</SubCommunitiesExpander>
4145
{children}
4246
</Wrapper>
4347
)

containers/BodyLayout/logic.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { makeDebugger } from 'utils'
1+
import { makeDebugger, dispatchEvent, EVENT } from 'utils'
22

33
/* eslint-disable-next-line */
44
const debug = makeDebugger('L:BodyLayout')
55

66
let store = null
77

88
export const openDoraemon = () => store.openDoraemon()
9+
export const queryDoraemon = data =>
10+
dispatchEvent(EVENT.QUERY_DORAMON, { data })
911

1012
export const init = _store => {
1113
if (store) return false

containers/BodyLayout/styles/index.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import styled from 'styled-components'
22
import { theme, cs } from 'utils'
33

4+
import Img from 'components/Img'
5+
46
// transition: background-color 0.2s;
5-
const Wrapper = styled.div`
7+
export const Wrapper = styled.div`
68
${cs.flexColumn()};
79
padding-left: ${({ noSidebar }) => (noSidebar ? '0' : '56px')};
810
position: relative;
@@ -12,8 +14,32 @@ const Wrapper = styled.div`
1214
margin-left: ${({ sidebarPin }) => (sidebarPin ? '180px' : '0')};
1315
transition: all 0.2s;
1416
overflow-x: ${({ sidebarPin }) => (sidebarPin ? 'hidden' : '')};
15-
${cs.media.tablet`padding-left: 0`};
17+
${cs.media.tablet`
18+
position: relative;
19+
padding-left: 0;
20+
`};
21+
`
22+
export const SubCommunitiesExpander = styled.div`
23+
display: none;
24+
${cs.media.tablet`
25+
${cs.flex('align-both')};
26+
width: 30px;
27+
position: fixed;
28+
top: 10%;
29+
left: 0;
30+
z-index: 100;
31+
border: 1px solid;
32+
border-color: ${theme('content.cardBg')};
33+
border-radius: 0 10px 10px 0;
34+
height: 40px;
35+
background-color: ${theme('banner.numberHoverBg')};
36+
box-shadow: ${theme('preview.shadow')};
37+
`};
1638
`
17-
/* overflow-x: hidden; */
1839

19-
export default Wrapper
40+
// expander_more
41+
export const ExpanderIcon = styled(Img)`
42+
fill ${theme('banner.desc')};
43+
width: 18px;
44+
height: 20px;
45+
`

containers/Doraemon/helper/swissArmyKnife.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const anyNil = R.any(R.isNil)
1414
export class SwissArmyKnife {
1515
constructor(store) {
1616
this.store = store
17-
this.communities = R.keys(store.communities)
17+
this.communities = R.pluck('raw', store.subscribedCommunities)
1818
}
1919

2020
completeInput = (into = false) => {
@@ -71,8 +71,14 @@ export class SwissArmyKnife {
7171
}
7272

7373
// TODO rename to linker
74-
communityLinker = cmdpath =>
75-
R.and(R.contains(R.head(cmdpath), this.communities), lengthE1(cmdpath))
74+
communityLinker = cmdpath => {
75+
// console.log('communityLinker: ', cmdpath)
76+
// console.log('communityLinker this.communities: ', this.communities)
77+
return R.and(
78+
R.contains(R.head(cmdpath), this.communities),
79+
lengthE1(cmdpath)
80+
)
81+
}
7682

7783
communityInsideLinker = cmdpath =>
7884
R.and(R.contains(R.head(cmdpath), this.communities), lengthE2(cmdpath))

containers/Doraemon/logic.js

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import {
1313
EVENT,
1414
TYPE,
1515
ERR,
16+
ROUTE,
1617
prettyNum,
18+
thread2Subpath,
1719
THREAD,
1820
cutFrom,
1921
errRescue,
@@ -180,17 +182,29 @@ const initSpecCmdResolver = () => {
180182
{
181183
match: SAK.communityLinker,
182184
action: cmdpath => {
183-
debug('communityLinker: ', cmdpath)
185+
const community = cmdpath[0]
186+
const { mainPath, subPath } = store.curRoute
187+
188+
if (
189+
R.contains(mainPath, [ROUTE.USER, ROUTE.COMMUNITIES]) ||
190+
R.contains(subPath, [ROUTE.POST, ROUTE.JOB, ROUTE.VIDEO, ROUTE.REPO])
191+
) {
192+
Global.location.href = `/${community}/posts`
193+
return hidePanel()
194+
}
184195

185-
// Router.push(url, as)
186-
// TODO: use route store method
187-
Router.push(
188-
{
189-
pathname: '/',
190-
query: { main: cmdpath[0] },
191-
},
192-
cmdpath[0]
193-
)
196+
store.setViewing({
197+
community: { raw: community },
198+
activeThread: THREAD.POST,
199+
post: {},
200+
})
201+
202+
store.markRoute({
203+
mainPath: community,
204+
subPath: thread2Subpath(THREAD.POST),
205+
})
206+
207+
dispatchEvent(EVENT.COMMUNITY_CHANGE)
194208
hidePanel()
195209
},
196210
},
@@ -207,6 +221,8 @@ const doSpecCmd = () => {
207221
const cmd = store.curCmdChain
208222
if (!cmd) return
209223

224+
debug('doSpecCmd cmd: ', cmd)
225+
210226
/* Do not use forEach, cause forEach will not break */
211227
for (let i = 0; i < cmdResolver.length; i += 1) {
212228
if (cmdResolver[i].match(cmd)) {
@@ -434,7 +450,11 @@ const DataSolver = [
434450
match: asyncRes(EVENT.QUERY_DORAMON),
435451
action: res => {
436452
const { data } = res[EVENT.QUERY_DORAMON]
437-
store.open()
453+
const forcus = false
454+
store.open(forcus)
455+
456+
/* "doraemonInputbar" */
457+
438458
store.markState({ inputValue: data })
439459
queryPocket()
440460
},

containers/Doraemon/store.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ const DoraemonStore = t
7676
get root() {
7777
return getParent(self)
7878
},
79+
get curRoute() {
80+
return self.root.curRoute
81+
},
7982
get curCmdChain() {
8083
if (!self.cmdChain && self.activeRaw) {
8184
return [self.activeRaw]
@@ -126,6 +129,9 @@ const DoraemonStore = t
126129
},
127130
}))
128131
.actions(self => ({
132+
markRoute(query) {
133+
self.root.markRoute(query)
134+
},
129135
toast(type, options) {
130136
self.root.toast(type, options)
131137
},
@@ -184,14 +190,12 @@ const DoraemonStore = t
184190
activeRaw: nextActiveRaw,
185191
})
186192
},
187-
activeTo(raw) {
188-
self.markState({
189-
activeRaw: raw,
190-
})
193+
activeTo(activeRaw) {
194+
self.markState({ activeRaw })
191195
},
192-
open() {
196+
open(forcus = true) {
193197
self.visible = true
194-
focusDoraemonBar()
198+
if (forcus) focusDoraemonBar()
195199
},
196200
handleLogin() {
197201
self.open()
@@ -205,6 +209,9 @@ const DoraemonStore = t
205209
self.clearSuggestions()
206210
hideDoraemonBarRecover()
207211
},
212+
setViewing(sobj) {
213+
self.root.setViewing(sobj)
214+
},
208215
markState(sobj) {
209216
markStates(sobj, self)
210217
},

containers/Footer/MobilBottomInfo.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ThxTitle,
1414
} from './styles/mobile_bottom_info'
1515

16-
import { toggleBusBanner, openDoraemon } from './logic'
16+
import { toggleBusBanner, queryDoraemon } from './logic'
1717

1818
const MobileBottomInfo = () => (
1919
<React.Fragment>
@@ -22,9 +22,7 @@ const MobileBottomInfo = () => (
2222
所有社区
2323
</ItemBtn>
2424
<DotDivider radius="4px" />
25-
<ItemBtn onClick={openDoraemon.bind(this, '/')}>我的关注</ItemBtn>
26-
<DotDivider radius="4px" />
27-
<ItemBtn onClick={openDoraemon.bind(this, '/theme/')}>切换主题</ItemBtn>
25+
<ItemBtn onClick={queryDoraemon.bind(this, '/theme/')}>切换主题</ItemBtn>
2826
</LinkInfoWrapper>
2927

3028
<SiteInfoWrapper>

0 commit comments

Comments
 (0)