Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
liuzhen@situdata.com
/
yunxiao-admin-fe
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
88207ae8
authored
2020-12-17 15:45:23 +0800
by
zhen
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:添加AES加密方法
1 parent
d75a8525
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
3 deletions
package-lock.json
package.json
src/store/index.js
src/utils/aes.js
src/views/login/index.vue
package-lock.json
View file @
88207ae
...
...
@@ -6055,6 +6055,11 @@
"randomfill"
:
"^1.0.3"
}
},
"crypto-js"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz"
,
"integrity"
:
"sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg=="
},
"css-color-names"
:
{
"version"
:
"0.0.4"
,
"resolved"
:
"https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz"
,
...
...
package.json
View file @
88207ae
...
...
@@ -14,6 +14,7 @@
"axios"
:
"^0.18.1"
,
"captcha-mini"
:
"^1.1.0"
,
"core-js"
:
"^2.6.11"
,
"crypto-js"
:
"^4.0.0"
,
"echarts"
:
"^4.8.0"
,
"element-ui"
:
"^2.13.2"
,
"js-cookie"
:
"^2.2.1"
,
...
...
src/store/index.js
View file @
88207ae
...
...
@@ -50,7 +50,7 @@ export default new Vuex.Store({
const
{
username
,
password
}
=
userinfo
const
res
=
await
login
({
username
:
username
.
trim
(),
password
:
password
password
})
if
(
res
.
code
===
0
)
{
commit
(
'SET_ROLES'
,
res
.
result
.
role
)
...
...
src/utils/aes.js
0 → 100644
View file @
88207ae
import
CryptoJS
from
'crypto-js'
const
AES_KEY
=
'94a80df2633b4944'
export
function
aesEncode
(
str
)
{
const
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
AES_KEY
)
const
word
=
CryptoJS
.
enc
.
Utf8
.
parse
(
str
)
const
encrypted
=
CryptoJS
.
AES
.
encrypt
(
word
,
key
,
{
mode
:
CryptoJS
.
mode
.
ECB
,
padding
:
CryptoJS
.
pad
.
Pkcs7
})
return
encrypted
.
toString
()
}
export
function
aesDecode
(
passPhrase
)
{
const
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
AES_KEY
)
const
decrypt
=
CryptoJS
.
AES
.
decrypt
(
passPhrase
,
key
,
{
mode
:
CryptoJS
.
mode
.
ECB
,
padding
:
CryptoJS
.
pad
.
Pkcs7
})
return
CryptoJS
.
enc
.
Utf8
.
stringify
(
decrypt
).
toString
()
}
src/views/login/index.vue
View file @
88207ae
<
template
lang=
"pug"
>
.login
LoginForm(class="login-card" ref="loginRef" @on-success-valid="handleLogin" :loading="btnLoading")
.login
LoginForm.login-card(
ref='loginRef',
@on-success-valid='handleLogin',
:loading='btnLoading'
)
</
template
>
<
script
>
import
LoginForm
from
'_c/loginForm'
import
{
mapActions
,
mapState
,
mapMutations
}
from
'vuex'
import
{
aesEncode
}
from
'@/utils/aes'
export
default
{
components
:
{
...
...
@@ -28,6 +33,7 @@ export default {
async
handleLogin
({
username
,
password
})
{
try
{
this
.
btnLoading
=
true
// const passPhrase = aesEncode(password)
const
{
code
}
=
await
this
.
login
({
username
,
password
})
if
(
code
===
0
)
{
this
.
$router
.
push
({
path
:
'/'
})
...
...
Write
Preview
Styling with
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