Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
InJoyU
vue-element-admin
提交
0094f449
V
vue-element-admin
项目概览
InJoyU
/
vue-element-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0094f449
编写于
8月 22, 2017
作者:
P
Pan
提交者:
花裤衩
8月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change login by username
上级
d06d476b
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
109 addition
and
93 deletion
+109
-93
src/api/login.js
src/api/login.js
+3
-3
src/assets/iconfont/iconfont.js
src/assets/iconfont/iconfont.js
+1
-1
src/mock/index.js
src/mock/index.js
+16
-18
src/mock/login.js
src/mock/login.js
+3
-3
src/store/modules/user.js
src/store/modules/user.js
+5
-5
src/utils/validate.js
src/utils/validate.js
+3
-3
src/views/dashboard/index.vue
src/views/dashboard/index.vue
+0
-1
src/views/login/index.vue
src/views/login/index.vue
+78
-59
未找到文件。
src/api/login.js
浏览文件 @
0094f449
import
fetch
from
'
utils/fetch
'
;
export
function
loginBy
Email
(
email
,
password
)
{
export
function
loginBy
Username
(
username
,
password
)
{
const
data
=
{
email
,
username
,
password
};
return
fetch
({
url
:
'
/login/login
byemail
'
,
url
:
'
/login/login
'
,
method
:
'
post
'
,
data
});
...
...
src/assets/iconfont/iconfont.js
浏览文件 @
0094f449
此差异已折叠。
点击以展开。
src/mock/index.js
浏览文件 @
0094f449
import
Mock
from
'
mockjs
'
;
import
loginAPI
from
'
./login
'
;
import
articleAPI
from
'
./article
'
;
import
article_tableAPI
from
'
./article_table
'
;
import
remoteSearchAPI
from
'
./remoteSearch
'
;
import
Mock
from
'
mockjs
'
import
loginAPI
from
'
./login
'
import
articleAPI
from
'
./article
'
import
article_tableAPI
from
'
./article_table
'
import
remoteSearchAPI
from
'
./remoteSearch
'
// 登录相关
Mock
.
mock
(
/
\/
login
\/
login
byemail/
,
'
post
'
,
loginAPI
.
loginByEmail
);
Mock
.
mock
(
/
\/
login
\/
logout/
,
'
post
'
,
loginAPI
.
logout
)
;
Mock
.
mock
(
/
\/
login
\/
login
/
,
'
post
'
,
loginAPI
.
loginByUsername
)
Mock
.
mock
(
/
\/
login
\/
logout/
,
'
post
'
,
loginAPI
.
logout
)
Mock
.
mock
(
/
\/
user
\/
info
\.
*/
,
'
get
'
,
loginAPI
.
getInfo
)
// // 文章相关
Mock
.
mock
(
/
\/
article
\/
list/
,
'
get
'
,
articleAPI
.
getList
);
Mock
.
mock
(
/
\/
article
\/
detail/
,
'
get
'
,
articleAPI
.
getArticle
);
// // table example相关
Mock
.
mock
(
/
\/
article_table
\/
list/
,
'
get
'
,
article_tableAPI
.
getList
);
Mock
.
mock
(
/
\/
article_table
\/
p/
,
'
get
'
,
article_tableAPI
.
getPv
);
// 文章相关
Mock
.
mock
(
/
\/
article
\/
list/
,
'
get
'
,
articleAPI
.
getList
)
Mock
.
mock
(
/
\/
article
\/
detail/
,
'
get
'
,
articleAPI
.
getArticle
)
// // 搜索相关
Mock
.
mock
(
/
\/
search
\/
user/
,
'
get
'
,
remoteSearchAPI
.
searchUser
);
// table example相关
Mock
.
mock
(
/
\/
article_table
\/
list/
,
'
get
'
,
article_tableAPI
.
getList
)
Mock
.
mock
(
/
\/
article_table
\/
p/
,
'
get
'
,
article_tableAPI
.
getPv
)
// 搜索相关
Mock
.
mock
(
/
\/
search
\/
user/
,
'
get
'
,
remoteSearchAPI
.
searchUser
)
export
default
Mock
;
export
default
Mock
src/mock/login.js
浏览文件 @
0094f449
...
...
@@ -25,9 +25,9 @@ const userMap = {
}
export
default
{
loginBy
Email
:
config
=>
{
const
{
email
}
=
JSON
.
parse
(
config
.
body
);
return
userMap
[
email
.
split
(
'
@
'
)[
0
]
];
loginBy
Username
:
config
=>
{
const
{
username
}
=
JSON
.
parse
(
config
.
body
);
return
userMap
[
username
];
},
getInfo
:
config
=>
{
const
{
token
}
=
param2Obj
(
config
.
url
);
...
...
src/store/modules/user.js
浏览文件 @
0094f449
import
{
loginBy
Email
,
logout
,
getInfo
}
from
'
api/login
'
;
import
{
loginBy
Username
,
logout
,
getInfo
}
from
'
api/login
'
;
import
{
getToken
,
setToken
,
removeToken
}
from
'
utils/auth
'
;
const
user
=
{
...
...
@@ -50,11 +50,11 @@ const user = {
},
actions
:
{
//
邮箱
登录
LoginBy
Email
({
commit
},
userInfo
)
{
const
email
=
userInfo
.
email
.
trim
();
//
用户名
登录
LoginBy
Username
({
commit
},
userInfo
)
{
const
username
=
userInfo
.
username
.
trim
();
return
new
Promise
((
resolve
,
reject
)
=>
{
loginBy
Email
(
email
,
userInfo
.
password
).
then
(
response
=>
{
loginBy
Username
(
username
,
userInfo
.
password
).
then
(
response
=>
{
const
data
=
response
.
data
;
setToken
(
response
.
data
.
token
);
commit
(
'
SET_TOKEN
'
,
data
.
token
);
...
...
src/utils/validate.js
浏览文件 @
0094f449
...
...
@@ -3,9 +3,9 @@
*/
/* 是否是公司邮箱*/
export
function
is
WscnEmail
(
str
)
{
const
reg
=
/^
[
a-z0-9
](?:[
-_.+
]?[
a-z0-9
]
+
)
*@wallstreetcn
\.
com$/i
;
return
reg
.
test
(
str
.
trim
())
;
export
function
is
validUsername
(
str
)
{
const
valid_map
=
[
'
admin
'
,
'
editor
'
]
return
valid_map
.
indexOf
(
str
.
trim
())
>=
0
;
}
/* 合法uri*/
...
...
src/views/dashboard/index.vue
浏览文件 @
0094f449
...
...
@@ -21,7 +21,6 @@
...
mapGetters
([
'
name
'
,
'
avatar
'
,
'
email
'
,
'
introduction
'
,
'
roles
'
])
...
...
src/views/login/index.vue
浏览文件 @
0094f449
<
template
>
<div
class=
"login-container"
>
<el-form
autoComplete=
"on"
:model=
"loginForm"
:rules=
"loginRules"
ref=
"loginForm"
label-position=
"left"
label-width=
"0px"
class=
"card-box login-form"
>
<el-form
class=
"card-box login-form"
autoComplete=
"on"
:model=
"loginForm"
:rules=
"loginRules"
ref=
"loginForm"
label-position=
"left"
>
<h3
class=
"title"
>
系统登录
</h3>
<el-form-item
prop=
"email"
>
<span
class=
"svg-container"
><icon-svg
icon-class=
"jiedianyoujian"
></icon-svg></span>
<el-input
name=
"email"
type=
"text"
v-model=
"loginForm.email"
autoComplete=
"on"
placeholder=
"邮箱"
></el-input>
<el-form-item
prop=
"username"
>
<span
class=
"svg-container svg-container_login"
>
<icon-svg
icon-class=
"yonghuming"
/>
</span>
<el-input
name=
"username"
type=
"text"
v-model=
"loginForm.username"
autoComplete=
"on"
placeholder=
"邮箱"
/>
</el-form-item>
<el-form-item
prop=
"password"
>
<span
class=
"svg-container"
><icon-svg
icon-class=
"mima"
></icon-svg></span>
<el-input
name=
"password"
type=
"password"
@
keyup.enter.native=
"handleLogin"
v-model=
"loginForm.password"
autoComplete=
"on"
placeholder=
"密码"
></el-input>
<span
class=
"svg-container"
>
<icon-svg
icon-class=
"mima"
/>
</span>
<el-input
name=
"password"
:type=
"pwdType"
@
keyup.enter.native=
"handleLogin"
v-model=
"loginForm.password"
autoComplete=
"on"
placeholder=
"密码"
/>
<span
class=
'show-pwd'
@
click=
'showPwd'
><icon-svg
icon-class=
"yanjing"
/></span>
</el-form-item>
<el-form-item>
<el-button
type=
"primary"
style=
"width:100%;"
:loading=
"loading"
@
click.native.prevent=
"handleLogin"
>
登录
</el-button>
</el-form-item>
<div
class=
'tips'
>
admin账号为:admin@wallstreetcn.com 密码随便填
</div>
<div
class=
'tips'
>
editor账号:editor@wallstreetcn.com 密码随便填
</div>
<el-button
type=
"primary"
style=
"width:100%;margin-bottom:30px;"
:loading=
"loading"
@
click.native.prevent=
"handleLogin"
>
登录
</el-button>
<div
class=
'tips'
>
账号:admin 密码随便填
</div>
<div
class=
'tips'
>
账号:editor 密码随便填
</div>
</el-form>
<el-dialog
title=
"第三方验证"
:visible.sync=
"showDialog"
>
邮箱登录成功,请选择第三方验证
<social-sign
></social-sign
>
<social-sign
/
>
</el-dialog>
</div>
</
template
>
<
script
>
import
{
is
WscnEmail
}
from
'
utils/validate
'
;
import
socialSign
from
'
./socialsignin
'
;
import
{
is
validUsername
}
from
'
utils/validate
'
import
socialSign
from
'
./socialsignin
'
export
default
{
components
:
{
socialSign
},
name
:
'
login
'
,
data
()
{
const
validate
Email
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
is
WscnEmail
(
value
))
{
callback
(
new
Error
(
'
请输入正确的
合法邮箱
'
));
const
validate
Username
=
(
rule
,
value
,
callback
)
=>
{
if
(
!
is
validUsername
(
value
))
{
callback
(
new
Error
(
'
请输入正确的
用户名
'
))
}
else
{
callback
()
;
callback
()
}
}
;
const
validatePass
=
(
rule
,
value
,
callback
)
=>
{
}
const
validatePass
word
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
.
length
<
6
)
{
callback
(
new
Error
(
'
密码不能小于6位
'
))
;
callback
(
new
Error
(
'
密码不能小于6位
'
))
}
else
{
callback
()
;
callback
()
}
}
;
}
return
{
loginForm
:
{
email
:
'
admin@wallstreetcn.com
'
,
password
:
''
username
:
'
admin
'
,
password
:
'
1111111
'
},
loginRules
:
{
email
:
[
{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
validateEmail
}
],
password
:
[
{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
validatePass
}
]
username
:
[{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
validateUsername
}],
password
:
[{
required
:
true
,
trigger
:
'
blur
'
,
validator
:
validatePassword
}]
},
pwdType
:
'
password
'
,
loading
:
false
,
showDialog
:
false
}
},
methods
:
{
showPwd
()
{
if
(
this
.
pwdType
===
'
password
'
)
{
this
.
pwdType
=
''
}
else
{
this
.
pwdType
=
'
password
'
}
},
handleLogin
()
{
this
.
$refs
.
loginForm
.
validate
(
valid
=>
{
if
(
valid
)
{
this
.
loading
=
true
;
this
.
$store
.
dispatch
(
'
LoginBy
Email
'
,
this
.
loginForm
).
then
(()
=>
{
this
.
loading
=
false
;
this
.
$router
.
push
({
path
:
'
/
'
})
;
// this.showDialog = true
;
this
.
loading
=
true
this
.
$store
.
dispatch
(
'
LoginBy
Username
'
,
this
.
loginForm
).
then
(()
=>
{
this
.
loading
=
false
this
.
$router
.
push
({
path
:
'
/
'
})
// this.showDialog = true
}).
catch
(()
=>
{
this
.
loading
=
false
;
})
;
this
.
loading
=
false
})
}
else
{
console
.
log
(
'
error submit!!
'
)
;
return
false
;
console
.
log
(
'
error submit!!
'
)
return
false
}
})
;
})
},
afterQRScan
()
{
// const hash = window.location.hash.slice(1)
;
// const hashObj = getQueryObject(hash)
;
// const originUrl = window.location.origin
;
// history.replaceState({}, '', originUrl)
;
// const hash = window.location.hash.slice(1)
// const hashObj = getQueryObject(hash)
// const originUrl = window.location.origin
// history.replaceState({}, '', originUrl)
// const codeMap = {
// wechat: 'code',
// tencent: 'code'
// }
;
// const codeName = hashObj[codeMap[this.auth_type]]
;
// }
// const codeName = hashObj[codeMap[this.auth_type]]
// if (!codeName) {
// alert('第三方登录失败')
;
// alert('第三方登录失败')
// } else {
// this.$store.dispatch('LoginByThirdparty', codeName).then(() => {
// this.$router.push({ path: '/' })
;
// })
;
// this.$router.push({ path: '/' })
// })
// }
}
},
created
()
{
// window.addEventListener('hashchange', this.afterQRScan)
;
// window.addEventListener('hashchange', this.afterQRScan)
},
destroyed
()
{
// window.removeEventListener('hashchange', this.afterQRScan)
;
// window.removeEventListener('hashchange', this.afterQRScan)
}
}
</
script
>
...
...
@@ -119,7 +127,7 @@
.tips
{
font-size
:
14px
;
color
:
#fff
;
margin-bottom
:
5
px
;
margin-bottom
:
10
px
;
}
.login-container
{
...
...
@@ -147,6 +155,12 @@
.svg-container
{
padding
:
6px
5px
6px
15px
;
color
:
#889aa4
;
vertical-align
:
middle
;
width
:
30px
;
display
:
inline-block
;
&
_login
{
font-size
:
20px
;
}
}
.title
{
font-size
:
26px
;
...
...
@@ -170,8 +184,13 @@
border-radius
:
5px
;
color
:
#454545
;
}
.forget-pwd
{
color
:
#fff
;
.show-pwd
{
position
:
absolute
;
right
:
10px
;
top
:
7px
;
font-size
:
16px
;
color
:
#889aa4
;
cursor
:
pointer
;
}
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录