From d91f3a866189530368c204ce264f231818b1e715 Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Mon, 20 Jul 2020 18:11:13 +0800 Subject: [PATCH] chore: optimize the code of workplace; :star2: --- src/main.js | 9 +-- src/mock/user/current.js | 20 ++----- src/mock/user/login.js | 2 - src/pages/dashboard/workplace/WorkPlace.vue | 62 ++++++--------------- src/store/index.js | 11 +++- src/store/modules/account.js | 7 ++- 6 files changed, 41 insertions(+), 70 deletions(-) diff --git a/src/main.js b/src/main.js index b445040..1235c30 100644 --- a/src/main.js +++ b/src/main.js @@ -6,7 +6,6 @@ import Antd from 'ant-design-vue' import Viser from 'viser-vue' import '@/mock' import store from './store' -import PouchDB from 'pouchdb' import 'animate.css/source/animate.css' import VueI18n from 'vue-i18n' import Plugins from '@/plugins' @@ -17,6 +16,8 @@ Vue.use(Antd) Vue.use(VueI18n) Vue.use(Plugins) + + const i18n = new VueI18n({ locale: 'CN', fallbackLocale: 'US', @@ -28,10 +29,4 @@ new Vue({ store, i18n, render: h => h(App), - mounted () { - let db = new PouchDB('adminDb') - db.get('currUser').then(doc => { - this.$store.commit('account/setUser', doc.user) - }) - }, }).$mount('#app') diff --git a/src/mock/user/current.js b/src/mock/user/current.js index db0aeaf..e8aa19f 100644 --- a/src/mock/user/current.js +++ b/src/mock/user/current.js @@ -1,19 +1,11 @@ import Mock from 'mockjs' import '@/mock/extend' -const userDB = Mock.mock({ - 'list|2-10': [ - { - name: '@ADMIN', - avatar: '@AVATAR', - address: '@CITY', - welcome: '@WELCOME', - timeFix: '@TIMEFIX', - position: '@position' - } - ] -}).list +const welcome = Mock.mock({ + timeFix: '@TIMEFIX', + message: '@WELCOME' +}) -Mock.mock('/user/current', 'get', () => { - return userDB[0] +Mock.mock('/user/welcome', 'get', () => { + return welcome }) diff --git a/src/mock/user/login.js b/src/mock/user/login.js index 394cca8..56fc8da 100644 --- a/src/mock/user/login.js +++ b/src/mock/user/login.js @@ -5,8 +5,6 @@ const user = Mock.mock({ name: '@ADMIN', avatar: '@AVATAR', address: '@CITY', - welcome: '@WELCOME', - timeFix: '@TIMEFIX', position: '@POSITION' }) diff --git a/src/pages/dashboard/workplace/WorkPlace.vue b/src/pages/dashboard/workplace/WorkPlace.vue index e346022..af7cb89 100644 --- a/src/pages/dashboard/workplace/WorkPlace.vue +++ b/src/pages/dashboard/workplace/WorkPlace.vue @@ -1,8 +1,8 @@