Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcdj-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
25da4210
authored
2022-08-08 17:32:53 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
架构
1 parent
d88e515f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
57 deletions
src/store/getters.js
src/store/modules/user.js
src/store/getters.js
View file @
25da421
...
...
@@ -6,15 +6,8 @@ const getters = {
token
:
state
=>
state
.
user
.
token
,
avatar
:
state
=>
state
.
user
.
avatar
,
name
:
state
=>
state
.
user
.
name
,
introduction
:
state
=>
state
.
user
.
introduction
,
permission_routes
:
state
=>
state
.
permission
.
routes
,
addRoutes
:
state
=>
state
.
permission
.
addRoutes
,
errorLogs
:
state
=>
state
.
errorLog
.
logs
,
fdglSaveInfo
:
state
=>
state
.
organizationmanage
.
fdgl
,
cardTypeOption
:
state
=>
state
.
dictionaries
.
cardTypeOption
,
xingzuoTypeOption
:
state
=>
state
.
dictionaries
.
xingzuoTypeOption
,
sysInfo
:
state
=>
state
.
dictionariesAll
.
sysInfo
,
centralizationData
:
state
=>
state
.
housemap
.
centralizationData
,
distributedData
:
state
=>
state
.
housemap
.
distributedData
,
errorLogs
:
state
=>
state
.
errorLog
.
logs
}
export
default
getters
...
...
src/store/modules/user.js
View file @
25da421
...
...
@@ -5,13 +5,9 @@ import Cookies from 'js-cookie';
const
state
=
{
name
:
Cookies
.
get
(
'username'
),
avatar
:
'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
,
introduction
:
''
,
userInfo
:
null
}
const
mutations
=
{
SET_INTRODUCTION
:
(
state
,
introduction
)
=>
{
state
.
introduction
=
introduction
},
SET_NAME
:
(
state
,
name
)
=>
{
state
.
name
=
name
},
...
...
@@ -24,51 +20,6 @@ const mutations = {
}
const
actions
=
{
// user login
login
({
commit
},
userInfo
)
{
const
{
username
,
password
,
code
,
num
,
location
}
=
userInfo
return
new
Promise
((
resolve
,
reject
)
=>
{
login
({
username
:
username
.
trim
(),
password
:
password
,
code
:
code
,
location
:
location
}).
then
(
response
=>
{
const
{
result
,
code
,
msg
}
=
response
if
(
code
===
200
)
{
Cookies
.
set
(
'token'
,
result
.
token
)
commit
(
'SET_USERINFO'
,
result
.
userInfo
)
Cookies
.
set
(
"userInfo"
,
result
.
userInfo
.
id
,
{
expires
:
720
})
Cookies
.
set
(
"username"
,
result
.
userInfo
.
username
,
{
expires
:
720
})
commit
(
'SET_NAME'
,
result
.
userInfo
.
username
)
}
else
{
Message
.
error
(
msg
);
}
resolve
(
response
)
}).
catch
(
error
=>
{
reject
(
error
)
})
})
},
// user logout
logout
({
commit
,
state
,
dispatch
})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// logout(state.token).then(() => {
commit
(
'SET_USERINFO'
,
null
)
Cookies
.
remove
(
"userInfo"
)
Cookies
.
remove
(
"routerTo"
)
Cookies
.
remove
(
'token'
)
resetRouter
()
store
.
dispatch
(
'permission/resetRoutes'
)
// reset visited views and cached views
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
dispatch
(
'tagsView/delAllViews'
,
null
,
{
root
:
true
})
resolve
()
})
},
// remove token
resetToken
({
commit
})
{
return
new
Promise
(
resolve
=>
{
commit
(
'SET_USERINFO'
,
null
)
Cookies
.
remove
(
"userInfo"
)
resolve
()
})
},
}
export
default
{
namespaced
:
true
,
...
...
Please
register
or
sign in
to post a comment