From 40ded001f8c7862a4fb7d02b579b042d64571caa Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 16 Jun 2020 15:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home.vue | 15 +++++++++++++++ src/components/Login.vue | 9 ++++++--- src/router/index.js | 6 ++++++ vue.config.js | 8 ++++---- 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 src/components/Home.vue 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 } }