Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
72969146
Commit
72969146
authored
Dec 23, 2020
by
Bill
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into test
parents
89a7ece2
8a3511ae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
85 deletions
+100
-85
OuterSide.tsx
src/layouts/components/OuterSide.tsx
+13
-7
RightContent.tsx
src/layouts/components/RightContent.tsx
+1
-4
MenuSlider.less
src/layouts/styles/MenuSlider.less
+6
-2
index.tsx
src/pages/home/components/UserCenter/index.tsx
+7
-5
index.ts
src/store/user/index.ts
+73
-67
No files found.
src/layouts/components/OuterSide.tsx
View file @
72969146
import
React
from
'react'
import
React
from
'react'
import
{
Layout
,
Menu
}
from
'antd'
import
{
Layout
,
Menu
,
Avatar
,
Image
}
from
'antd'
import
{
AppstoreOutlined
}
from
'@ant-design/icons'
import
{
AppstoreOutlined
}
from
'@ant-design/icons'
import
{
Link
}
from
'umi'
import
{
Link
}
from
'umi'
import
styles
from
'../styles/MenuSlider.less'
import
styles
from
'../styles/MenuSlider.less'
import
{
getRouters
}
from
'@/utils/auth'
import
{
getRouters
}
from
'@/utils/auth'
import
{
isDev
}
from
'@/constants'
import
{
isDev
}
from
'@/constants'
import
{
observer
,
inject
}
from
'mobx-react'
;
const
{
Sider
}
=
Layout
const
{
Sider
}
=
Layout
export
interface
OuterSiderProps
{
export
interface
OuterSiderProps
{
...
@@ -14,7 +14,7 @@ export interface OuterSiderProps {
...
@@ -14,7 +14,7 @@ export interface OuterSiderProps {
}
}
const
OuterSider
:
React
.
FC
<
OuterSiderProps
>
=
(
props
)
=>
{
const
OuterSider
:
React
.
FC
<
OuterSiderProps
>
=
observer
(
(
props
)
=>
{
const
{
menuData
,
pathname
=
"/"
}
=
props
const
{
menuData
,
pathname
=
"/"
}
=
props
const
authRouters
=
getRouters
()
const
authRouters
=
getRouters
()
let
defaultSelectedKeys
:
string
=
""
let
defaultSelectedKeys
:
string
=
""
...
@@ -45,7 +45,13 @@ const OuterSider: React.FC<OuterSiderProps> = (props) => {
...
@@ -45,7 +45,13 @@ const OuterSider: React.FC<OuterSiderProps> = (props) => {
const
siderMenu
=
getSubMenu
()
const
siderMenu
=
getSubMenu
()
return
<>
return
<>
<
Sider
collapsed=
{
true
}
collapsedWidth=
{
64
}
className=
{
styles
.
wrapperSilder
}
>
<
Sider
collapsed=
{
true
}
collapsedWidth=
{
64
}
className=
{
styles
.
wrapperSilder
}
>
<
div
className=
{
styles
.
userPic
}
/>
{
props
.
UserStore
.
avatar
?
<
div
className=
{
styles
.
userPic
}
>
<
img
src=
{
props
.
UserStore
.
avatar
}
className=
{
styles
.
avatar
}
/>
</
div
>
:
<
div
className=
{
styles
.
userPic
}
/>
}
<
ul
className=
{
styles
.
menuBox
}
>
<
ul
className=
{
styles
.
menuBox
}
>
{
{
siderMenu
.
map
(
item
=>
(
siderMenu
.
map
(
item
=>
(
...
@@ -60,8 +66,9 @@ const OuterSider: React.FC<OuterSiderProps> = (props) => {
...
@@ -60,8 +66,9 @@ const OuterSider: React.FC<OuterSiderProps> = (props) => {
</
ul
>
</
ul
>
</
Sider
>
</
Sider
>
</>
</>
}
}
)
OuterSider
.
defaultProps
=
{}
OuterSider
.
defaultProps
=
{}
export
default
OuterSider
// export default OuterSider
\ No newline at end of file
export
default
inject
(
'UserStore'
)(
OuterSider
)
src/layouts/components/RightContent.tsx
View file @
72969146
...
@@ -33,11 +33,8 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
...
@@ -33,11 +33,8 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
if
(
SOCKET_URL
&&
(
!
ws
.
current
||
ws
.
current
.
readyState
===
3
)
&&
userInfo
)
{
if
(
SOCKET_URL
&&
(
!
ws
.
current
||
ws
.
current
.
readyState
===
3
)
&&
userInfo
)
{
const
url
=
`
${
SOCKET_URL
}
/report/websocket?memberId=
${
userInfo
.
memberId
}
&roleId=
${
userInfo
.
memberRoleId
}
&token=
${
userInfo
.
token
}
&source=
${
1
}
`
;
const
url
=
`
${
SOCKET_URL
}
/report/websocket?memberId=
${
userInfo
.
memberId
}
&roleId=
${
userInfo
.
memberRoleId
}
&token=
${
userInfo
.
token
}
&source=
${
1
}
`
;
ws
.
current
=
new
WebSocket
(
url
);
ws
.
current
=
new
WebSocket
(
url
);
ws
.
current
.
onopen
=
(
e
)
=>
{
ws
.
current
.
onopen
=
(
e
)
=>
{}
console
.
log
(
e
)
}
ws
.
current
.
onmessage
=
(
e
)
=>
{
ws
.
current
.
onmessage
=
(
e
)
=>
{
console
.
log
(
e
)
const
data
=
JSON
.
parse
(
e
.
data
);
const
data
=
JSON
.
parse
(
e
.
data
);
if
(
data
.
type
===
NOT_READ_MESSAGE
)
{
if
(
data
.
type
===
NOT_READ_MESSAGE
)
{
setMessage
(
data
.
data
);
setMessage
(
data
.
data
);
...
...
src/layouts/styles/MenuSlider.less
View file @
72969146
...
@@ -48,6 +48,11 @@
...
@@ -48,6 +48,11 @@
background: rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.2);
margin: 16px;
margin: 16px;
border-radius: 50%;
border-radius: 50%;
overflow: hidden;
.avatar {
width: 32px;
height: 32px;
}
}
}
.wrapperSilder {
.wrapperSilder {
...
@@ -117,4 +122,4 @@
...
@@ -117,4 +122,4 @@
height: 48px !important;
height: 48px !important;
line-height: 48px !important;
line-height: 48px !important;
}
}
}
}
\ No newline at end of file
src/pages/home/components/UserCenter/index.tsx
View file @
72969146
...
@@ -12,6 +12,7 @@ import StatusTag from '@/components/StatusTag';
...
@@ -12,6 +12,7 @@ import StatusTag from '@/components/StatusTag';
import
home_user
from
'@/assets/imgs/home_user.png'
;
import
home_user
from
'@/assets/imgs/home_user.png'
;
import
{
UPLOAD_TYPE
}
from
'@/constants'
import
{
UPLOAD_TYPE
}
from
'@/constants'
import
{
PublicApi
}
from
'@/services/api'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
observer
,
inject
}
from
'mobx-react'
;
interface
Iprops
{}
interface
Iprops
{}
const
WEEKDAYS
=
[
"天"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
];
const
WEEKDAYS
=
[
"天"
,
"一"
,
"二"
,
"三"
,
"四"
,
"五"
,
"六"
];
...
@@ -31,12 +32,11 @@ function reducer(state, action) {
...
@@ -31,12 +32,11 @@ function reducer(state, action) {
}
}
}
}
const
UserCenter
:
React
.
FC
<
Iprops
>
=
()
=>
{
const
UserCenter
:
React
.
FC
<
Iprops
>
=
(
props
)
=>
{
// const [uploadLoading, setUpload]
const
today
=
moment
();
const
today
=
moment
();
const
userAuth
=
getAuth
();
const
userAuth
=
getAuth
();
const
hasChangeMemberAuth
=
userAuth
?.
urls
.
includes
(
EDIT_USER_URL
);
//
const hasChangeMemberAuth = userAuth?.urls.includes(EDIT_USER_URL);
const
hasCenterAuth
=
userAuth
?.
urls
.
includes
(
USER_CENTER_URL
);
//
const hasCenterAuth = userAuth?.urls.includes(USER_CENTER_URL);
const
currentRole
=
userAuth
.
roles
.
filter
((
item
)
=>
item
.
memberRoleId
===
userAuth
.
memberRoleId
)
const
currentRole
=
userAuth
.
roles
.
filter
((
item
)
=>
item
.
memberRoleId
===
userAuth
.
memberRoleId
)
const
[
state
,
dispatch
]
=
useReducer
(
reducer
,
{
loading
:
false
,
logo
:
userAuth
.
logo
})
const
[
state
,
dispatch
]
=
useReducer
(
reducer
,
{
loading
:
false
,
logo
:
userAuth
.
logo
})
if
(
!
userAuth
)
{
if
(
!
userAuth
)
{
...
@@ -65,6 +65,7 @@ const UserCenter: React.FC<Iprops> = () => {
...
@@ -65,6 +65,7 @@ const UserCenter: React.FC<Iprops> = () => {
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
===
1000
)
{
if
(
res
.
code
===
1000
)
{
dispatch
({
type
:
'done'
,
payload
:
{
url
:
data
}})
dispatch
({
type
:
'done'
,
payload
:
{
url
:
data
}})
props
.
UserStore
.
setUserAvatar
(
data
)
}
}
})
})
}
}
...
@@ -146,4 +147,5 @@ const UserCenter: React.FC<Iprops> = () => {
...
@@ -146,4 +147,5 @@ const UserCenter: React.FC<Iprops> = () => {
)
)
}
}
export
default
UserCenter
// export default UserCenter
export
default
inject
(
'UserStore'
)(
observer
(
UserCenter
))
src/store/user/index.ts
View file @
72969146
import
{
action
,
computed
,
observable
,
runInAction
}
from
'mobx'
import
{
action
,
computed
,
observable
,
runInAction
}
from
'mobx'
import
{
ILoginModule
}
from
'@/module/userModule'
import
{
ILoginModule
}
from
'@/module/userModule'
import
{
getAuth
}
from
'@/utils/auth'
import
{
getAuth
}
from
'@/utils/auth'
import
{
localStorage
}
from
'@/utils/storage'
import
{
localStorage
}
from
'@/utils/storage'
// import { userDetailGet } from '@/services/user'
// import { userDetailGet } from '@/services/user'
// const userInfo = localStorage.getItem('userInfo')
// const userInfo = localStorage.getItem('userInfo')
class
LoginStore
implements
ILoginModule
{
class
LoginStore
implements
ILoginModule
{
@
observable
public
username
:
string
=
'admin'
;
@
observable
public
username
:
string
=
'admin'
;
@
observable
public
password
:
string
=
"123456"
;
@
observable
public
password
:
string
=
"123456"
;
@
observable
public
res
:
object
=
{};
@
observable
public
res
:
object
=
{};
@
observable
public
userInfo
=
getAuth
()
@
observable
public
userInfo
=
getAuth
();
@
observable
public
avatar
=
this
.
userInfo
.
logo
;
// 可以改变对应的状态值
// @todo 接入更新用户信息接口
// 可以改变对应的状态值
@
action
.
bound
// @todo 接入更新用户信息接口
public
async
updateUserInfo
()
{
@
action
.
bound
// try {
public
async
updateUserInfo
()
{
// const res = await userDetailGet()
// try {
// runInAction(() => {
// const res = await userDetailGet()
// this.userInfo = res.data;
// runInAction(() => {
// localStorage.setItem('userInfo', JSON.stringify(this.userInfo))
// this.userInfo = res.data;
// })
// localStorage.setItem('userInfo', JSON.stringify(this.userInfo))
// } catch (error) {
// })
// return error
// } catch (error) {
// }
// return error
}
// }
}
// 当有时需要拼接状态,但又不希望改变原有状态,可以采取如下, 类似vue中的computed
@
computed
// 当有时需要拼接状态,但又不希望改变原有状态,可以采取如下, 类似vue中的computed
public
get
printInfo
():
string
{
@
computed
return
`hello,
${
this
.
username
}
, your password is
${
this
.
password
}
`
public
get
printInfo
():
string
{
}
return
`hello,
${
this
.
username
}
, your password is
${
this
.
password
}
`
}
// 可以改变对应的状态值
@
action
.
bound
// 可以改变对应的状态值
public
setUsername
(
username
:
string
)
{
@
action
.
bound
this
.
username
=
username
;
public
setUsername
(
username
:
string
)
{
}
this
.
username
=
username
;
}
@
action
.
bound
public
setPassword
(
password
:
string
)
{
@
action
.
bound
this
.
password
=
password
;
public
setPassword
(
password
:
string
)
{
}
this
.
password
=
password
;
}
// 异步修改数据, 需要使用bound,保持this指向当前store
@
action
.
bound
// 异步修改数据, 需要使用bound,保持this指向当前store
public
async
handleLogin
()
{
@
action
.
bound
try
{
public
async
handleLogin
()
{
let
params
=
{
try
{
username
:
this
.
username
,
let
params
=
{
password
:
this
.
password
username
:
this
.
username
,
}
password
:
this
.
password
const
result
=
{}
}
runInAction
(()
=>
{
const
result
=
{}
this
.
res
=
result
runInAction
(()
=>
{
})
this
.
res
=
result
})
return
result
}
catch
(
error
)
{
return
result
return
error
}
catch
(
error
)
{
}
return
error
}
}
}
}
// 改变用户的头像
export
default
LoginStore
@
action
.
bound
public
setUserAvatar
(
link
:
string
)
{
this
.
avatar
=
link
;
}
}
export
default
LoginStore
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment