Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitd9e5e58

Browse files
committed
Merge branch 'user-menu' into dev
2 parentse6f5e17 +b70d731 commitd9e5e58

File tree

5 files changed

+147
-20
lines changed

5 files changed

+147
-20
lines changed

‎containers/Header/UserAccount.js‎

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,84 @@
11
importReactfrom'react'
22

33
import{ICON_CMD}from'config/assets'
4-
import*aslogicfrom'./logic'
4+
importPopoverfrom'components/Popover'
55

6-
import{Wrapper,DefaultUserIcon,AvatarIcon}from'./styles/user_account'
6+
import{onLogin,onLogout,previewAccount}from'./logic'
77

8-
constUserAccount=({ isLogin, accountInfo})=>{
9-
return(
10-
<React.Fragment>
11-
{isLogin ?(
12-
<WrapperonClick={logic.previewAccount.bind(this,'account')}>
8+
import{
9+
Wrapper,
10+
PopMenu,
11+
MenuItem,
12+
MenuLink,
13+
LoginBadge,
14+
LoginDesc,
15+
LoginName,
16+
DefaultUserIcon,
17+
LogoutItem,
18+
AvatarIcon,
19+
MenuDivider,
20+
}from'./styles/user_account'
21+
22+
constUserAccount=({ isLogin, accountInfo})=>(
23+
<React.Fragment>
24+
{isLogin ?(
25+
<Popover
26+
placement="bottomLeft"
27+
trigger="hover"
28+
content={
29+
<PopMenu>
30+
<LoginBadge>
31+
<LoginDesc>使用 Github 登陆:</LoginDesc>
32+
<LoginName>{accountInfo.login}</LoginName>
33+
</LoginBadge>
34+
<MenuDivider/>
35+
<MenuItemonClick={previewAccount.bind(this,'account')}>
36+
预览
37+
</MenuItem>
38+
<MenuLink
39+
href={`/user/${accountInfo.login}`}
40+
rel="noopener noreferrer"
41+
target="_blank"
42+
>
43+
我的主页
44+
</MenuLink>
45+
<MenuLink
46+
href={`/user/${accountInfo.login}?tab=favorites`}
47+
rel="noopener noreferrer"
48+
target="_blank"
49+
>
50+
我的收藏
51+
</MenuLink>
52+
<MenuLink
53+
href={`/user/${accountInfo.login}?tab=billing`}
54+
rel="noopener noreferrer"
55+
target="_blank"
56+
>
57+
我的账单
58+
</MenuLink>
59+
<MenuDivider/>
60+
<MenuLink
61+
href={`/user/${accountInfo.login}?tab=settings`}
62+
rel="noopener noreferrer"
63+
target="_blank"
64+
>
65+
设置
66+
</MenuLink>
67+
<MenuItem>帮助</MenuItem>
68+
<LogoutItemonClick={onLogout}>登出</LogoutItem>
69+
</PopMenu>
70+
}
71+
>
72+
<Wrapper>
1373
<AvatarIconsrc={accountInfo.avatar}/>
1474
</Wrapper>
15-
) :(
16-
<WrapperonClick={logic.login}>
17-
<DefaultUserIconsrc={`${ICON_CMD}/default_user.svg`}/>
18-
</Wrapper>
19-
)}
20-
</React.Fragment>
21-
)
22-
}
75+
</Popover>
76+
) :(
77+
<WrapperonClick={onLogin}>
78+
<DefaultUserIconsrc={`${ICON_CMD}/default_user.svg`}/>
79+
</Wrapper>
80+
)}
81+
</React.Fragment>
82+
)
2383

2484
exportdefaultUserAccount

‎containers/Header/logic.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
thread2Subpath,
1313
atomizeValues,
1414
errRescue,
15+
Global,
1516
// getParameterByName,
1617
}from'utils'
1718

@@ -45,7 +46,15 @@ export const onThreadChange = thread => {
4546
store.setViewing({ activeThread})
4647
}
4748

48-
exportconstlogin=()=>dispatchEvent(EVENT.LOGIN_PANEL)
49+
exportconstonLogin=()=>dispatchEvent(EVENT.LOGIN_PANEL)
50+
exportconstonLogout=()=>{
51+
store.logout()
52+
53+
setTimeout(()=>{
54+
Global.location.reload(false)
55+
},2000)
56+
}
57+
4958
exportconstopenDoraemon=()=>store.openDoraemon()
5059
exportconstupgradeHepler=()=>store.upgradeHepler()
5160

‎containers/Header/store.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const HeaderStore = t
5757
},
5858
}))
5959
.actions(self=>({
60+
logout(){
61+
self.root.account.logout()
62+
},
6063
updateSesstion(state){
6164
self.root.account.updateSesstion(state)
6265
},

‎containers/Header/styles/user_account.js‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,68 @@
11
importstyledfrom'styled-components'
22

33
importImgfrom'components/Img'
4-
import{theme}from'utils'
4+
import{theme,cs}from'utils'
55

66
exportconstWrapper=styled.div`
77
margin-right: 20px;
88
`
9+
10+
exportconstPopMenu=styled.div`
11+
${cs.flexColumn()};
12+
`
13+
14+
exportconstMenuItem=styled.div`
15+
padding: 4px 13px;
16+
color:${theme('thread.articleTitle')};
17+
opacity: 0.9;
18+
&:hover {
19+
background:${theme('thread.articleHover')};
20+
opacity: 1;
21+
cursor: pointer;
22+
}
23+
`
24+
25+
exportconstMenuLink=styled.a`
26+
padding: 4px 13px;
27+
color:${theme('thread.articleTitle')};
28+
opacity: 0.9;
29+
&:hover {
30+
background:${theme('thread.articleHover')};
31+
opacity: 1;
32+
cursor: pointer;
33+
text-decoration: underline;
34+
}
35+
`
36+
37+
exportconstLoginBadge=styled.div`
38+
padding: 7px 13px;
39+
`
40+
exportconstLoginDesc=styled.div`
41+
color:${theme('thread.articleDigest')};
42+
`
43+
exportconstLoginName=styled.div`
44+
color:${theme('thread.articleTitle')};
45+
font-weight: bold;
46+
`
47+
48+
exportconstLogoutItem=styled.div`
49+
padding: 5px 13px;
50+
padding-bottom: 6px;
51+
color:${theme('thread.articleTitle')};
52+
&:hover {
53+
color:${theme('baseColor.error')};
54+
background:${theme('thread.articleHover')};
55+
cursor: pointer;
56+
}
57+
`
58+
59+
exportconstMenuDivider=styled.div`
60+
margin-top: 3px;
61+
margin-bottom: 3px;
62+
border-bottom: 2px solid;
63+
border-bottom-color:${theme('thread.articleDivider')};
64+
`
65+
966
exportconstAvatarIcon=styled.img`
1067
width: 20px;
1168
height: 20px;

‎containers/schemas/pages/user.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ export const sessionState = `
6969
sessionState {
7070
isValid
7171
user {
72-
id
72+
${F.author}
7373
geoCity
74-
nickname
75-
avatar
7674
bio
7775
fromGithub
7876
location

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp