Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-system
/
micro-portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1e3b9c74
authored
Nov 10, 2020
by
冒粤蓉
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix menu and config
1 parent
8c283f3a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
11 deletions
src/components/DesktopLeftSider/Sub/Menu.vue
src/components/HomeContent/Sub/LoginForm.vue
src/store/getters.js
src/store/modules/app.js
src/store/modules/menu.js
src/utils/http/http.js
src/components/DesktopLeftSider/Sub/Menu.vue
View file @
1e3b9c7
This diff is collapsed.
Click to expand it.
src/components/HomeContent/Sub/LoginForm.vue
View file @
1e3b9c7
...
@@ -135,11 +135,8 @@ export default {
...
@@ -135,11 +135,8 @@ export default {
await
loginService
.
loginAction
(
params
).
then
((
res
)
=>
{
await
loginService
.
loginAction
(
params
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
const
{
token
,
user
}
=
res
.
data
;
const
{
token
,
user
}
=
res
.
data
;
localStorage
.
setItem
(
'token'
,
token
);
localStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
user
));
store
.
dispatch
(
'app/setUserInfo'
,
user
);
store
.
dispatch
(
'app/setUserInfo'
,
user
);
store
.
dispatch
(
'app/setToken'
,
token
);
store
.
dispatch
(
'app/setToken'
,
token
);
console
.
log
(
'save token'
,
token
);
}
else
{
}
else
{
const
{
message
}
=
res
;
const
{
message
}
=
res
;
state
.
alertArr
.
push
(
message
);
state
.
alertArr
.
push
(
message
);
...
...
src/store/getters.js
View file @
1e3b9c7
...
@@ -7,7 +7,8 @@ const getters = {
...
@@ -7,7 +7,8 @@ const getters = {
showLoading
:
state
=>
state
.
app
.
showLoading
,
showLoading
:
state
=>
state
.
app
.
showLoading
,
menu
:
state
=>
state
.
menu
.
menu
,
menu
:
state
=>
state
.
menu
.
menu
,
curBreadCrumb
:
state
=>
state
.
menu
.
curBreadCrumb
,
curBreadCrumb
:
state
=>
state
.
menu
.
curBreadCrumb
,
commonData
:
state
=>
state
.
app
.
commonData
commonData
:
state
=>
state
.
app
.
commonData
,
updateMenu
:
state
=>
state
.
menu
.
updateMenu
}
}
export
default
getters
;
export
default
getters
;
\ No newline at end of file
\ No newline at end of file
src/store/modules/app.js
View file @
1e3b9c7
...
@@ -12,10 +12,14 @@ let state = {
...
@@ -12,10 +12,14 @@ let state = {
};
};
try
{
try
{
const
userInfoStorage
=
localStorage
.
getItem
(
'userInfo'
);
const
userInfoStorage
=
localStorage
.
getItem
(
'userInfo'
),
token
=
localStorage
.
getItem
(
'token'
);
if
(
userInfoStorage
)
{
if
(
userInfoStorage
)
{
state
.
userInfo
=
JSON
.
parse
(
userInfoStorage
);
state
.
userInfo
=
JSON
.
parse
(
userInfoStorage
);
}
}
if
(
token
)
{
state
.
token
=
token
;
}
}
catch
(
error
)
{
}
catch
(
error
)
{
}
}
...
@@ -33,6 +37,7 @@ export default {
...
@@ -33,6 +37,7 @@ export default {
// 设置token
// 设置token
SET_TOKEN
(
state
,
data
)
{
SET_TOKEN
(
state
,
data
)
{
state
.
token
=
data
;
state
.
token
=
data
;
localStorage
.
setItem
(
'token'
,
data
);
},
},
// 设置菜单栏展开/收起
// 设置菜单栏展开/收起
SET_COLLAPSED
(
state
,
data
)
{
SET_COLLAPSED
(
state
,
data
)
{
...
@@ -40,6 +45,7 @@ export default {
...
@@ -40,6 +45,7 @@ export default {
},
},
SET_USER_INFO
(
state
,
data
)
{
SET_USER_INFO
(
state
,
data
)
{
state
.
userInfo
=
data
;
state
.
userInfo
=
data
;
localStorage
.
setItem
(
'userInfo'
,
JSON
.
stringify
(
data
));
},
},
SHOW_LOADING
(
state
,
data
)
{
SHOW_LOADING
(
state
,
data
)
{
state
.
showLoading
=
data
;
state
.
showLoading
=
data
;
...
...
src/store/modules/menu.js
View file @
1e3b9c7
let
state
=
{
let
state
=
{
is_collapse
:
false
,
// 折叠状态
is_collapse
:
false
,
// 折叠状态
menu
:
[],
// 菜单数据
menu
:
[],
// 菜单数据
curBreadCrumb
:
{}
curBreadCrumb
:
{},
updateMenu
:
false
};
};
try
{
try
{
...
@@ -29,6 +30,10 @@ export default {
...
@@ -29,6 +30,10 @@ export default {
SET_BREAD_CRUMB
(
state
,
data
)
{
SET_BREAD_CRUMB
(
state
,
data
)
{
state
.
curBreadCrumb
=
data
;
state
.
curBreadCrumb
=
data
;
},
},
// 子系统操作更新菜单
UPDATE_MENU
(
state
,
data
)
{
state
.
updateMenu
=
data
;
},
},
},
actions
:
{
actions
:
{
// 推入用户菜单
// 推入用户菜单
...
@@ -43,5 +48,9 @@ export default {
...
@@ -43,5 +48,9 @@ export default {
setBreadCrumb
({
commit
},
data
)
{
setBreadCrumb
({
commit
},
data
)
{
commit
(
'SET_BREAD_CRUMB'
,
data
)
commit
(
'SET_BREAD_CRUMB'
,
data
)
},
},
// 子系统操作更新菜单
updateMenu
({
commit
},
data
)
{
commit
(
'UPDATE_MENU'
,
data
)
}
}
}
}
}
\ No newline at end of file
\ No newline at end of file
src/utils/http/http.js
View file @
1e3b9c7
...
@@ -19,18 +19,22 @@ instance.interceptors.request.use(config => {
...
@@ -19,18 +19,22 @@ instance.interceptors.request.use(config => {
if
(
localStorage
.
getItem
(
'token'
)){
if
(
localStorage
.
getItem
(
'token'
)){
config
.
headers
[
'Authorization'
]
=
localStorage
.
getItem
(
'token'
)
||
''
;
config
.
headers
[
'Authorization'
]
=
localStorage
.
getItem
(
'token'
)
||
''
;
}
}
// store.dispatch('app/showLoading', true);
return
config
return
config
},
error
=>
{
},
error
=>
{
console
.
log
(
'请求错误,原因:'
,
error
)
console
.
log
(
'请求错误,原因:'
,
error
)
// store.dispatch('app/showLoading', false);
return
Promise
.
reject
(
error
)
return
Promise
.
reject
(
error
)
})
})
/** 添加响应拦截器 **/
/** 添加响应拦截器 **/
instance
.
interceptors
.
response
.
use
(
response
=>
{
instance
.
interceptors
.
response
.
use
(
response
=>
{
// store.dispatch('app/showLoading', false);
// store.dispatch('app/showLoading', false);
const
serverCode
=
response
.
data
.
code
;
// 登录接口从data内拿token,其他接口一律从请求头获取并更新存储
const
serverCode
=
response
.
data
.
code
,
token
=
response
.
headers
[
'authorization'
];
if
(
token
||
token
===
''
)
{
store
.
dispatch
(
'app/setToken'
,
token
);
}
if
(
serverCode
===
200
||
response
.
status
===
200
)
{
if
(
serverCode
===
200
||
response
.
status
===
200
)
{
if
(
serverCode
!==
200
)
{
if
(
serverCode
!==
200
)
{
checkStatus
(
serverCode
);
checkStatus
(
serverCode
);
...
@@ -45,7 +49,6 @@ instance.interceptors.response.use(response => {
...
@@ -45,7 +49,6 @@ instance.interceptors.response.use(response => {
return
Promise
.
reject
(
response
.
data
.
message
)
return
Promise
.
reject
(
response
.
data
.
message
)
}
}
},
error
=>
{
},
error
=>
{
// store.dispatch('app/showLoading', false);
const
errRes
=
error
.
response
;
const
errRes
=
error
.
response
;
if
(
errRes
)
{
if
(
errRes
)
{
const
{
data
,
config
,
status
,
statusText
}
=
errRes
;
const
{
data
,
config
,
status
,
statusText
}
=
errRes
;
...
@@ -103,7 +106,7 @@ const getBaseUrl = () => {
...
@@ -103,7 +106,7 @@ const getBaseUrl = () => {
const
resBaseURL
=
resData
.
axios
.
baseURL
;
const
resBaseURL
=
resData
.
axios
.
baseURL
;
store
.
dispatch
(
'app/updateBaseURL'
,
resBaseURL
);
store
.
dispatch
(
'app/updateBaseURL'
,
resBaseURL
);
localStorage
.
setItem
(
'BASE_URL'
,
resBaseURL
);
localStorage
.
setItem
(
'BASE_URL'
,
resBaseURL
);
baseFlag
=
!
!
resBaseURL
;
baseFlag
=
!
resBaseURL
;
resolve
(
resBaseURL
);
resolve
(
resBaseURL
);
}
else
{
}
else
{
baseFlag
=
true
;
baseFlag
=
true
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment