|
@@ -7,6 +7,9 @@ Vue.use(Vuex)
|
|
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
const store = new Vuex.Store({
|
|
|
state: {
|
|
state: {
|
|
|
|
|
+ userAvatar: '',
|
|
|
|
|
+ userNickName: '',
|
|
|
|
|
+
|
|
|
info:'',
|
|
info:'',
|
|
|
backupInfo:'',
|
|
backupInfo:'',
|
|
|
showInfo:'',
|
|
showInfo:'',
|
|
@@ -28,6 +31,9 @@ const store = new Vuex.Store({
|
|
|
uploadStatusListVideo: [],
|
|
uploadStatusListVideo: [],
|
|
|
},
|
|
},
|
|
|
getters: {
|
|
getters: {
|
|
|
|
|
+ userAvatar: state => state.userAvatar,
|
|
|
|
|
+ userNickName: state => state.userNickName,
|
|
|
|
|
+
|
|
|
isEditing:state=>state.isEditing,
|
|
isEditing:state=>state.isEditing,
|
|
|
info:state=>state.info,
|
|
info:state=>state.info,
|
|
|
showInfo:state=>state.showInfo,
|
|
showInfo:state=>state.showInfo,
|
|
@@ -49,6 +55,17 @@ const store = new Vuex.Store({
|
|
|
uploadStatusListVideo: state => state.uploadStatusListVideo,
|
|
uploadStatusListVideo: state => state.uploadStatusListVideo,
|
|
|
},
|
|
},
|
|
|
mutations: {
|
|
mutations: {
|
|
|
|
|
+ SetUserAvatar(state, avatar) {
|
|
|
|
|
+ if (typeof avatar === 'string') {
|
|
|
|
|
+ state.userAvatar = avatar
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ SetUserNickName(state, nickName) {
|
|
|
|
|
+ if (typeof nickName === 'string') {
|
|
|
|
|
+ state.userNickName = nickName
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
SetTabList(state, list) {
|
|
SetTabList(state, list) {
|
|
|
state.tablist = list
|
|
state.tablist = list
|
|
|
},
|
|
},
|
|
@@ -96,7 +113,21 @@ const store = new Vuex.Store({
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
actions: {
|
|
actions: {
|
|
|
|
|
+ watchUserInfo(context) {
|
|
|
|
|
+ function cacheUserInfo() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const userInfo = JSON.parse(localStorage.getItem('info'))
|
|
|
|
|
+ context.commit('SetUserAvatar', userInfo.head)
|
|
|
|
|
+ context.commit('SetUserNickName', userInfo.nickName)
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ cacheUserInfo()
|
|
|
|
|
+ window.removeEventListener('store', cacheUserInfo)
|
|
|
|
|
+ window.addEventListener('storage', cacheUserInfo)
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
modules: {
|
|
modules: {
|
|
|
|
|
|