diff --git a/src/api/login.js b/src/api/login.js index cc8599b5..cfcff27d 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,12 +1,12 @@ import fetch from 'utils/fetch'; -export function loginByEmail(email, password) { +export function loginByUsername(username, password) { const data = { - email, + username, password }; return fetch({ - url: '/login/loginbyemail', + url: '/login/login', method: 'post', data }); diff --git a/src/assets/iconfont/iconfont.js b/src/assets/iconfont/iconfont.js index 8b1ffad9..927b19d7 100644 --- a/src/assets/iconfont/iconfont.js +++ b/src/assets/iconfont/iconfont.js @@ -1 +1 @@ -(function(window){var svgSprite=""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+''+""+''+""+''+""+""+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+"";var script=function(){var scripts=document.getElementsByTagName("script");return scripts[scripts.length-1]}();var shouldInjectCss=script.getAttribute("data-injectcss");var ready=function(fn){if(document.addEventListener){if(~["complete","loaded","interactive"].indexOf(document.readyState)){setTimeout(fn,0)}else{var loadFn=function(){document.removeEventListener("DOMContentLoaded",loadFn,false);fn()};document.addEventListener("DOMContentLoaded",loadFn,false)}}else if(document.attachEvent){IEContentLoaded(window,fn)}function IEContentLoaded(w,fn){var d=w.document,done=false,init=function(){if(!done){done=true;fn()}};var polling=function(){try{d.documentElement.doScroll("left")}catch(e){setTimeout(polling,50);return}init()};polling();d.onreadystatechange=function(){if(d.readyState=="complete"){d.onreadystatechange=null;init()}}}};var before=function(el,target){target.parentNode.insertBefore(el,target)};var prepend=function(el,target){if(target.firstChild){before(el,target.firstChild)}else{target.appendChild(el)}};function appendSvg(){var div,svg;div=document.createElement("div");div.innerHTML=svgSprite;svgSprite=null;svg=div.getElementsByTagName("svg")[0];if(svg){svg.setAttribute("aria-hidden","true");svg.style.position="absolute";svg.style.width=0;svg.style.height=0;svg.style.overflow="hidden";prepend(svg,document.body)}}if(shouldInjectCss&&!window.__iconfont__svg__cssinject__){window.__iconfont__svg__cssinject__=true;try{document.write("")}catch(e){console&&console.log(e)}}ready(appendSvg)})(window) \ No newline at end of file +(function(window){var svgSprite=""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+''+""+''+""+''+""+""+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+''+""+''+""+""+""+"";var script=function(){var scripts=document.getElementsByTagName("script");return scripts[scripts.length-1]}();var shouldInjectCss=script.getAttribute("data-injectcss");var ready=function(fn){if(document.addEventListener){if(~["complete","loaded","interactive"].indexOf(document.readyState)){setTimeout(fn,0)}else{var loadFn=function(){document.removeEventListener("DOMContentLoaded",loadFn,false);fn()};document.addEventListener("DOMContentLoaded",loadFn,false)}}else if(document.attachEvent){IEContentLoaded(window,fn)}function IEContentLoaded(w,fn){var d=w.document,done=false,init=function(){if(!done){done=true;fn()}};var polling=function(){try{d.documentElement.doScroll("left")}catch(e){setTimeout(polling,50);return}init()};polling();d.onreadystatechange=function(){if(d.readyState=="complete"){d.onreadystatechange=null;init()}}}};var before=function(el,target){target.parentNode.insertBefore(el,target)};var prepend=function(el,target){if(target.firstChild){before(el,target.firstChild)}else{target.appendChild(el)}};function appendSvg(){var div,svg;div=document.createElement("div");div.innerHTML=svgSprite;svgSprite=null;svg=div.getElementsByTagName("svg")[0];if(svg){svg.setAttribute("aria-hidden","true");svg.style.position="absolute";svg.style.width=0;svg.style.height=0;svg.style.overflow="hidden";prepend(svg,document.body)}}if(shouldInjectCss&&!window.__iconfont__svg__cssinject__){window.__iconfont__svg__cssinject__=true;try{document.write("")}catch(e){console&&console.log(e)}}ready(appendSvg)})(window) \ No newline at end of file diff --git a/src/mock/index.js b/src/mock/index.js index dea59284..1ac3a8c2 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -1,25 +1,23 @@ -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\/loginbyemail/, '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); +// 文章相关 +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); +// 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); +// 搜索相关 +Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser) - -export default Mock; +export default Mock diff --git a/src/mock/login.js b/src/mock/login.js index a8d0dea5..9baab9a1 100644 --- a/src/mock/login.js +++ b/src/mock/login.js @@ -25,9 +25,9 @@ const userMap = { } export default { - loginByEmail: config => { - const { email } = JSON.parse(config.body); - return userMap[email.split('@')[0]]; + loginByUsername: config => { + const { username } = JSON.parse(config.body); + return userMap[username]; }, getInfo: config => { const { token } = param2Obj(config.url); diff --git a/src/store/modules/user.js b/src/store/modules/user.js index d65175eb..7582434b 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,4 +1,4 @@ -import { loginByEmail, logout, getInfo } from 'api/login'; +import { loginByUsername, logout, getInfo } from 'api/login'; import { getToken, setToken, removeToken } from 'utils/auth'; const user = { @@ -50,11 +50,11 @@ const user = { }, actions: { - // 邮箱登录 - LoginByEmail({ commit }, userInfo) { - const email = userInfo.email.trim(); + // 用户名登录 + LoginByUsername({ commit }, userInfo) { + const username = userInfo.username.trim(); return new Promise((resolve, reject) => { - loginByEmail(email, userInfo.password).then(response => { + loginByUsername(username, userInfo.password).then(response => { const data = response.data; setToken(response.data.token); commit('SET_TOKEN', data.token); diff --git a/src/utils/validate.js b/src/utils/validate.js index 3dbc5fec..3deb7eed 100644 --- a/src/utils/validate.js +++ b/src/utils/validate.js @@ -3,9 +3,9 @@ */ /* 是否是公司邮箱*/ -export function isWscnEmail(str) { - const reg = /^[a-z0-9](?:[-_.+]?[a-z0-9]+)*@wallstreetcn\.com$/i; - return reg.test(str.trim()); +export function isvalidUsername(str) { + const valid_map = ['admin', 'editor'] + return valid_map.indexOf(str.trim()) >= 0; } /* 合法uri*/ diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index f7722bde..da0c60cd 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -21,7 +21,6 @@ ...mapGetters([ 'name', 'avatar', - 'email', 'introduction', 'roles' ]) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 15d2686d..54b35292 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -1,115 +1,123 @@ - + 系统登录 - - - + + + + + + + - - + + + + + - - - 登录 - - - admin账号为:admin@wallstreetcn.com 密码随便填 - editor账号:editor@wallstreetcn.com 密码随便填 + + 登录 + + 账号:admin 密码随便填 + 账号:editor 密码随便填 邮箱登录成功,请选择第三方验证 - + @@ -119,7 +127,7 @@ .tips { font-size: 14px; color: #fff; - margin-bottom: 5px; + margin-bottom: 10px; } .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; } }