feat: add account state

This commit is contained in:
chenghx
2018-08-13 11:38:29 +08:00
parent f2a11aa058
commit fef089a8b5
7 changed files with 45 additions and 31 deletions

View File

@@ -124,28 +124,23 @@ export default {
PageHeader},
data () {
return {
currUser: {},
projects: [],
loading: true,
activities: [],
teams: []
}
},
computed: {
currUser () {
return this.$store.state.account.user
}
},
mounted () {
this.currentUser()
this.getProjectList()
this.getActivites()
this.getTeams()
},
methods: {
currentUser () {
this.$axios({
method: 'get',
url: '/user/current'
}).then(res => {
this.currUser = res.data
})
},
getProjectList () {
this.$axios({
method: 'get',

View File

@@ -36,25 +36,9 @@ const AMenuDivider = AMenu.Divider
export default {
name: 'HeaderAvatar',
components: {AMenu, AMenuItem, AMenuDivider, AIcon, AAvatar, ADropdown},
data () {
return {
currUser: {
name: 'XXXXX',
avatar: ''
}
}
},
mounted () {
this.currentUser()
},
methods: {
currentUser () {
this.$axios({
method: 'get',
url: '/user/current'
}).then(res => {
this.currUser = res.data
})
computed: {
currUser () {
return this.$store.state.account.user
}
}
}

View File

@@ -120,7 +120,9 @@ export default {
this.logging = false
const result = res.data
if (result.code >= 0) {
const user = result.data.user
this.$router.push('/dashboard/workplace')
this.$store.commit('account/setuser', user)
this.$message.success(result.message, 3)
} else {
this.error = result.message