Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Redmine
Redmine
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
other-project
frontend
Commits
2cd01905
Commit
2cd01905
authored
Jan 17, 2020
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆修改完成
parent
ad024d07
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
47 deletions
+22
-47
index.js
src/router/index.js
+3
-3
httpRequest.js
src/utils/httpRequest.js
+3
-3
login.vue
src/views/common/login.vue
+9
-34
main.vue
src/views/main.vue
+5
-5
vue.config.js
vue.config.js
+2
-2
No files found.
src/router/index.js
View file @
2cd01905
...
...
@@ -61,23 +61,23 @@ router.beforeEach((to, from, next) => {
next
()
}
else
{
http
({
url
:
http
.
adornUrl
(
'/sys/menu/nav'
),
url
:
http
.
adornUrl
(
'/
api/
sys/menu/nav'
),
method
:
'get'
,
params
:
http
.
adornParams
()
}).
then
(({
data
})
=>
{
if
(
data
&&
data
.
code
===
200
)
{
if
(
data
&&
!
data
.
errorCode
)
{
fnAddDynamicMenuRoutes
(
data
.
menuList
)
router
.
options
.
isAddDynamicMenuRoutes
=
true
sessionStorage
.
setItem
(
'menuList'
,
JSON
.
stringify
(
data
.
menuList
||
'[]'
))
sessionStorage
.
setItem
(
'permissions'
,
JSON
.
stringify
(
data
.
permissions
||
'[]'
))
next
({
...
to
,
replace
:
true
})
}
else
{
this
.
$message
.
error
(
data
.
message
)
sessionStorage
.
setItem
(
'menuList'
,
'[]'
)
sessionStorage
.
setItem
(
'permissions'
,
'[]'
)
next
()
}
}).
catch
((
e
)
=>
{
console
.
log
(
`%c
${
e
}
请求菜单列表和权限失败,跳转至登录页!!`
,
'color:blue'
)
router
.
push
({
name
:
'login'
})
})
}
...
...
src/utils/httpRequest.js
View file @
2cd01905
...
...
@@ -4,7 +4,7 @@ import router from '@/router'
import
qs
from
'qs'
import
merge
from
'lodash/merge'
import
{
clearLoginInfo
}
from
'@/utils'
const
baseUrl
=
'/
wx
'
const
baseUrl
=
'/
backend-java
'
const
http
=
axios
.
create
({
timeout
:
1000
*
30
,
...
...
@@ -18,7 +18,7 @@ const http = axios.create({
* 请求拦截
*/
http
.
interceptors
.
request
.
use
(
config
=>
{
config
.
headers
[
'
toke
n'
]
=
Vue
.
cookie
.
get
(
'token'
)
// 请求头带上token
config
.
headers
[
'
Authorizatio
n'
]
=
Vue
.
cookie
.
get
(
'token'
)
// 请求头带上token
return
config
},
error
=>
{
return
Promise
.
reject
(
error
)
...
...
@@ -28,7 +28,7 @@ http.interceptors.request.use(config => {
* 响应拦截
*/
http
.
interceptors
.
response
.
use
(
response
=>
{
if
(
response
.
data
&&
response
.
data
.
code
===
401
)
{
// 401, token失效
if
(
response
.
data
&&
response
.
data
.
code
===
"401"
)
{
// 401, token失效
clearLoginInfo
()
router
.
push
({
name
:
'login'
})
}
...
...
src/views/common/login.vue
View file @
2cd01905
...
...
@@ -15,17 +15,6 @@
<el-form-item
prop=
"password"
>
<el-input
v-model=
"dataForm.password"
type=
"password"
placeholder=
"密码"
></el-input>
</el-form-item>
<el-form-item
prop=
"captcha"
>
<el-row
:gutter=
"20"
>
<el-col
:span=
"14"
>
<el-input
v-model=
"dataForm.captcha"
placeholder=
"验证码"
>
</el-input>
</el-col>
<el-col
:span=
"10"
class=
"login-captcha"
>
<img
:src=
"captchaPath"
@
click=
"getCaptcha()"
alt=
""
>
</el-col>
</el-row>
</el-form-item>
<el-form-item>
<el-button
class=
"login-btn-submit"
type=
"primary"
@
click=
"dataFormSubmit()"
>
登录
</el-button>
</el-form-item>
...
...
@@ -43,9 +32,7 @@
return
{
dataForm
:
{
userName
:
''
,
password
:
''
,
uuid
:
''
,
captcha
:
''
password
:
''
},
dataRule
:
{
userName
:
[
...
...
@@ -53,16 +40,12 @@
],
password
:
[
{
required
:
true
,
message
:
'密码不能为空'
,
trigger
:
'blur'
}
],
captcha
:
[
{
required
:
true
,
message
:
'验证码不能为空'
,
trigger
:
'blur'
}
]
},
captchaPath
:
''
}
}
},
created
()
{
this
.
getCaptcha
()
},
methods
:
{
// 提交表单
...
...
@@ -70,30 +53,22 @@
this
.
$refs
[
'dataForm'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
$http
({
url
:
this
.
$http
.
adornUrl
(
'/sys/login'
),
url
:
this
.
$http
.
adornUrl
(
'/
api/
sys/login'
),
method
:
'post'
,
data
:
this
.
$http
.
adornData
({
'username'
:
this
.
dataForm
.
userName
,
'password'
:
this
.
dataForm
.
password
,
'uuid'
:
this
.
dataForm
.
uuid
,
'captcha'
:
this
.
dataForm
.
captcha
'password'
:
this
.
dataForm
.
password
})
}).
then
(({
data
})
=>
{
if
(
data
&&
data
.
code
===
200
)
{
this
.
$cookie
.
set
(
'token'
,
data
.
toke
n
)
if
(
data
&&
data
.
authorization
)
{
this
.
$cookie
.
set
(
'token'
,
data
.
authorizatio
n
)
this
.
$router
.
replace
({
name
:
'home'
})
}
else
{
this
.
getCaptcha
()
this
.
$message
.
error
(
data
.
msg
)
}
else
{
this
.
$message
.
error
(
data
.
message
)
}
})
}
})
},
// 获取验证码
getCaptcha
()
{
this
.
dataForm
.
uuid
=
getUUID
()
this
.
captchaPath
=
this
.
$http
.
adornUrl
(
`/captcha.jpg?uuid=
${
this
.
dataForm
.
uuid
}
`
)
}
}
}
...
...
src/views/main.vue
View file @
2cd01905
...
...
@@ -74,15 +74,15 @@
// 获取当前管理员信息
getUserInfo
()
{
this
.
$http
({
url
:
this
.
$http
.
adornUrl
(
'/sys/user/info'
),
url
:
this
.
$http
.
adornUrl
(
'/
api/
sys/user/info'
),
method
:
'get'
,
params
:
this
.
$http
.
adornParams
()
}).
then
(({
data
})
=>
{
if
(
data
&&
data
.
code
===
200
)
{
this
.
loading
=
false
this
.
userId
=
data
.
user
.
userI
d
this
.
userName
=
data
.
user
.
user
name
}
this
.
userId
=
data
.
i
d
this
.
userName
=
data
.
username
})
}
}
...
...
vue.config.js
View file @
2cd01905
...
...
@@ -2,8 +2,8 @@ module.exports = {
publicPath
:
"./"
,
devServer
:
{
proxy
:
{
'/
wx
'
:
{
target
:
'http://localhost:808
8
/'
'/
backend-java
'
:
{
target
:
'http://localhost:808
0
/'
}
},
port
:
8001
,
...
...
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