import Cache from '../../common/cache.js'

export default {
	namespaced: true,
	state: {
		uploadAvatarTip: null,
		userInfo: {}
	},
	mutations: {
		setUserInfo(state, userInfo) {
			state.userInfo = userInfo
		},
		setUploadAvatarTip(state, yesOrNo) {
			state.uploadAvatarTip = yesOrNo
			Cache.put('uploadAvatarTip', yesOrNo)
		},
	},
	getters: {
    isLogin(state) {
      return state.userInfo?.id !== undefined
    },
		uploadAvatarTip(state) {
			if (state.uploadAvatarTip === null) {
				state.uploadAvatarTip = Cache.get('uploadAvatarTip')
			}
			return state.uploadAvatarTip
		},
	}
}
