diff --git a/src/components/Home.vue b/src/components/Home.vue new file mode 100644 index 0000000..8fd8f99 --- /dev/null +++ b/src/components/Home.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/src/components/Login.vue b/src/components/Login.vue index d9887a7..03d6eef 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -26,8 +26,8 @@ export default { data () { return { loginForm: { - username: '', - password: '' + username: 'admin', + password: '123456' }, loginFormRules: { username: [ @@ -49,8 +49,11 @@ export default { } const { data: res } = await this.$http.post('login', this.loginForm) if (res.meta.status !== 200) { - return console.log('login fail') + return this.$message.error('登录失败') } + sessionStorage.setItem('token', res.data.token) + this.$message.success('登录成功') + await this.$router.push('/home') }) }, reset () { diff --git a/src/router/index.js b/src/router/index.js index d7f5ca6..dff2277 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,8 @@ import Vue from 'vue' import VueRouter from 'vue-router' import Login from '../components/Login' +import Home from '../components/Home' + Vue.use(VueRouter) const routes = [ @@ -10,6 +12,10 @@ const routes = [ { path: '/login', component: Login + }, + { + path: '/home', + component: Home } ] diff --git a/vue.config.js b/vue.config.js index e1374e5..a5bf827 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,6 +1,6 @@ -module.exports={ - devServer:{ - port:8887, - open:true, +module.exports = { + devServer: { + port: 8887, + open: true } }