chore: optimize the code of workplace; 🌟

This commit is contained in:
chenghongxing
2020-07-20 18:11:13 +08:00
parent 82e5955c3b
commit d91f3a8661
6 changed files with 42 additions and 71 deletions

View File

@@ -2,12 +2,21 @@ import Vue from 'vue'
import Vuex from 'vuex'
import account from './modules/account'
import setting from './modules/setting'
import PouchDB from 'pouchdb'
const db = new PouchDB('adminDb')
Vue.use(Vuex)
export default new Vuex.Store({
const store = new Vuex.Store({
modules: {
account,
setting
}
})
// 读取用户信息
db.get('currUser')
.then(doc => store.commit('account/setUser', doc.user))
.catch(() => {})
export default store

View File

@@ -5,7 +5,12 @@ let db = new PouchDB('adminDb')
export default {
namespaced: true,
state: {
user: {}
user: {
name: '',
avatar: '',
position: '',
address: ''
}
},
mutations: {
setUser (state, user) {