Skip to content

Commit de83969

Browse files
committed
fix(router): login and logout
1 parent 0de980c commit de83969

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

src/common/dao/CommonDao.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@ import Dao from '@/base/dao';
22

33
class CommonDao extends Dao {
44
async login(options = {}) {
5+
const { data = {} } = options;
6+
57
return this.delay(1000)
68
.then(() => {
7-
return {
8-
code: 'SUCCESS'
9-
};
9+
if (data.username === 'admin' && data.password === '123456') {
10+
return {
11+
code: 'SUCCESS'
12+
};
13+
} else {
14+
return {
15+
code: 'ERROR'
16+
};
17+
}
1018
})
1119
.then(this.checkCode);
1220
}

src/common/layout/aside/AppAside.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div class="app-layout-aside">
33
<div class="app-layout-aside-logo">
4-
<a href="/">
4+
<router-link to="/">
55
<img :src="logoImg" />
66
<h1>{{ ui.appName }}</h1>
7-
</a>
7+
</router-link>
88
</div>
99
<el-menu
1010
:default-active="currentNav"

src/common/layout/header/AppHeader.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114

115115
<script>
116116
import { mapActions, mapState, mapGetters } from 'vuex';
117-
import { CommonUtil } from '@/common/utils';
118117
import defaultAvatarImg from '@/static/images/avatar.png';
119118
import AppDrawer from './AppDrawer';
120119
@@ -176,7 +175,7 @@ export default {
176175
177176
logout() {
178177
this.removeGlobalAppData().then(() => {
179-
CommonUtil.gotoLoginURL();
178+
this.$router.push('/login');
180179
});
181180
}
182181
}

src/common/router/interceptors/AuthInterceptor.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export default function AuthInterceptor(store) {
44
if (store.getters.isLoginedUser) {
55
next();
66
} else {
7-
// next('/login');
8-
window.location.href = '/login';
9-
next(false);
7+
next('/login');
108
}
119
};
1210

src/modules/home/pages/login/Login.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ export default {
9090
userLoginData() {
9191
const { username, password } = this;
9292
93-
return `username=${username}&password=${password}`;
93+
return {
94+
username,
95+
password
96+
};
9497
}
9598
},
9699

src/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const afterEachHooks = [PageTitle(store)];
1717

1818
const router = new Router({
1919
config: {
20-
mode: 'history',
20+
mode: 'hash',
2121
base: process.env.BASE_URL || '/',
2222
routes: routes
2323
},

0 commit comments

Comments
 (0)