Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
罗鑫霖
/
vion-tools
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 f6b11234
authored
Apr 09, 2020
by
周志凯
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[delete]: delete auth
1 parent
c586dfe1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
134 deletions
static/index.html
static/js/request.js
static/login.html
static/index.html
View file @
f6b1123
...
...
@@ -1085,7 +1085,6 @@
</div>
<script
src=
"./js/cookie.js"
></script>
<script
src=
"./js/permission.js"
></script>
<!-- import Vue before Element -->
<script
src=
"./js/vue.js"
></script>
<!-- import JavaScript -->
...
...
static/js/request.js
View file @
f6b1123
...
...
@@ -9,9 +9,9 @@ const Axios = axios.create({
Axios
.
interceptors
.
request
.
use
(
config
=>
{
const
atoken
=
Cookies
.
get
(
'atoken'
)
console
.
log
(
'atoken'
,
atoken
)
atoken
&&
(
config
.
headers
.
Authorization
=
atoken
)
//
const atoken = Cookies.get('atoken')
//
console.log('atoken', atoken)
//
atoken && (config.headers.Authorization = atoken)
return
config
},
error
=>
{
...
...
@@ -21,28 +21,26 @@ Axios.interceptors.request.use(
Axios
.
interceptors
.
response
.
use
(
res
=>
{
console
.
log
(
res
)
if
(
res
.
data
.
enote
||
res
.
data
.
code
===
401
)
{
ELEMENT
.
MessageBox
.
alert
(
'授权到期, 请重新登录'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
callback
:
action
=>
{
console
.
log
(
'action'
,
action
)
window
.
location
.
replace
(
window
.
location
.
href
+
'login.html'
)
}
});
}
else
{
return
Promise
.
resolve
(
res
.
data
)
}
// if (res.data.enote || res.data.code === 401) {
// ELEMENT.MessageBox.alert('授权到期, 请重新登录', '提示', {
// confirmButtonText: '确定',
// callback: action => {
// console.log('action', action)
// window.location.replace(window.location.href + 'login.html')
// }
// });
// } else {
return
Promise
.
resolve
(
res
.
data
)
// }
},
error
=>
{
console
.
log
(
error
)
console
.
error
(
error
)
return
Promise
.
reject
(
error
)
}
)
function
get
(
url
,
params
=
{},
config
=
{})
{
params
[
's'
]
=
+
new
Date
()
console
.
log
(
'params'
,
params
)
return
Axios
.
get
(
url
,
{
...
config
,
params
})
}
...
...
static/login.html
deleted
100644 → 0
View file @
c586dfe
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
/>
<link
rel=
"stylesheet"
href=
"./css/index.css"
/>
<link
rel=
"stylesheet"
href=
"./css/common.css"
>
<link
rel=
"stylesheet"
href=
"./css/page.css"
>
<script
src=
"./js/browser.min.js"
></script>
</head>
<body>
<!-- <div id="loginApp" v-cloak> -->
<div
id=
"loginApp"
>
<div
class=
"login-container"
>
<el-form
:model=
"loginForm"
:rules=
"rules"
ref=
"loginForm"
class=
"login-form"
>
<div
class=
"login-header"
>
<h3
class=
"login-title"
>
Login Form
</h3>
</div>
<el-form-item
prop=
"loginName"
>
<el-input
ref=
"username"
v-model
.
trim=
"loginForm.loginName"
></el-input>
</el-form-item>
<el-form-item
prop=
"password"
>
<el-input
ref=
"password"
type=
"password"
v-model
.
trim=
"loginForm.password"
>
</el-input>
</el-form-item>
<el-button
type=
"primary"
style=
"width: 100%;"
@
click=
"submitForm"
>
登 录
</el-button>
</el-form>
</div>
</div>
<!-- import Vue before Element -->
<script
src=
"./js/vue.js"
></script>
<!-- import JavaScript -->
<script
src=
"./js/index.js"
></script>
<script
src=
"./js/axios.js"
></script>
<script
src=
"./js/common.js"
type=
"text/javascript"
charset=
"utf-8"
></script>
<script
src=
"./js/cookie.js"
></script>
<script
src=
"./js/request.js"
></script>
<script>
new
Vue
({
el
:
'#loginApp'
,
data
()
{
const
validateUsername
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
value
)
{
callback
(
new
Error
(
'请输入用户名'
))
}
else
{
callback
()
}
}
const
validatePassword
=
(
rule
,
value
,
callback
)
=>
{
const
regexp
=
/^
(?![
A-Z
]
+$
)(?![
a-z
]
+$
)(?!\d
+$
)(?![\W
_
]
+$
)\S{6,16}
$/
if
(
!
value
)
{
callback
(
new
Error
(
'请输入密码'
))
}
else
if
(
!
regexp
.
test
(
value
))
{
callback
(
new
Error
(
'请输入不小于六位包含字母数字的密码!'
))
}
else
{
callback
()
}
}
return
{
loginForm
:
{
loginName
:
''
,
password
:
''
},
// paswordType: 'password',
rules
:
{
loginName
:
[
{
required
:
true
,
trigger
:
'blur'
,
validator
:
validateUsername
}
],
password
:
[
{
required
:
true
,
trigger
:
'blur'
,
validator
:
validatePassword
}
]
}
}
},
mounted
()
{
// console.log({ get, post })
// if (this.loginForm.name === '') {
// this.$refs.username.focus()
// } else if (this.loginForm.password === '') {
// this.$refs.password.focus()
// }
},
methods
:
{
submitForm
()
{
this
.
$refs
.
loginForm
.
validate
(
valid
=>
{
if
(
valid
)
{
post
(
window
.
_CONF_
.
reportApiUrl
+
'/users/login'
,
this
.
loginForm
).
then
(
res
=>
{
const
{
data
,
code
}
=
res
if
(
code
===
200
)
{
Cookies
.
set
(
'atoken'
,
data
.
atoken
)
const
currentPath
=
window
.
location
.
href
window
.
location
.
replace
(
currentPath
.
substr
(
0
,
currentPath
.
lastIndexOf
(
'/'
)
+
1
))
}
})
.
catch
(
err
=>
{
console
.
log
(
err
)
})
}
})
},
resetForm
()
{
this
.
loginForm
.
name
=
''
this
.
loginForm
.
password
=
''
this
.
$refs
.
loginForm
.
resetFields
()
},
}
})
</script>
</body>
</html>
\ No newline at end of file
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