refine code

This commit is contained in:
Pan 2017-08-22 15:09:25 +08:00 committed by 花裤衩
parent 62d2f62bff
commit b8ecda19d8
6 changed files with 11 additions and 17 deletions

View File

@ -1,22 +1,22 @@
import fetch from 'utils/fetch'; import fetch from 'utils/fetch'
export function loginByUsername(username, password) { export function loginByUsername(username, password) {
const data = { const data = {
username, username,
password password
}; }
return fetch({ return fetch({
url: '/login/login', url: '/login/login',
method: 'post', method: 'post',
data data
}); })
} }
export function logout() { export function logout() {
return fetch({ return fetch({
url: '/login/logout', url: '/login/logout',
method: 'post' method: 'post'
}); })
} }
export function getInfo(token) { export function getInfo(token) {
@ -24,6 +24,6 @@ export function getInfo(token) {
url: '/user/info', url: '/user/info',
method: 'get', method: 'get',
params: { token } params: { token }
}); })
} }

View File

@ -34,7 +34,7 @@ export default {
if (userMap[token]) { if (userMap[token]) {
return userMap[token]; return userMap[token];
} else { } else {
return Promise.reject('a'); return Promise.reject('error');
} }
}, },
logout: () => 'success' logout: () => 'success'

View File

@ -12,7 +12,7 @@ function hasPermission(roles, permissionRoles) {
} }
// register global progress. // register global progress.
const whiteList = ['/login', '/authredirect', '/reset', '/sendpwd']// 不重定向白名单 const whiteList = ['/login', '/authredirect']// 不重定向白名单
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() // 开启Progress NProgress.start() // 开启Progress
if (getToken()) { // 判断是否有token if (getToken()) { // 判断是否有token

View File

@ -40,12 +40,6 @@ const user = {
}, },
SET_ROLES: (state, roles) => { SET_ROLES: (state, roles) => {
state.roles = roles; state.roles = roles;
},
LOGIN_SUCCESS: () => {
console.log('login success')
},
LOGOUT_USER: state => {
state.user = '';
} }
}, },

View File

@ -24,7 +24,7 @@
<div class='tips'>账号:admin 密码随便填</div> <div class='tips'>账号:admin 密码随便填</div>
<div class='tips'>账号:editor 密码随便填</div> <div class='tips'>账号:editor 密码随便填</div>
<el-button class='thirdPart-button' type="primary" @click='showDialog=true'>打开第三方登录</el-button> <el-button class='thirdparty-button' type="primary" @click='showDialog=true'>打开第三方登录</el-button>
</el-form> </el-form>
<el-dialog title="第三方验证" :visible.sync="showDialog"> <el-dialog title="第三方验证" :visible.sync="showDialog">
@ -198,7 +198,7 @@
color: $dark_gray; color: $dark_gray;
cursor: pointer; cursor: pointer;
} }
.thirdPart-button{ .thirdparty-button{
position: absolute; position: absolute;
right: 35px; right: 35px;
bottom: 28px; bottom: 28px;