feat(dashboard): getRoles改为promise

This commit is contained in:
woody 2025-05-13 10:47:07 +08:00
parent a028c90cf2
commit c50e06ad7d
2 changed files with 21 additions and 14 deletions

View File

@ -148,11 +148,13 @@ export default {
} }
}, },
mounted() { mounted() {
this.getMemberSummary() this.getRoles().then(() => {
this.getDailyPerformance() this.getMemberSummary()
this.getMonthlyPerformance() this.getDailyPerformance()
this.getApprovalStatus() this.getMonthlyPerformance()
this.userInfo = JSON.parse(localStorage.getItem('userInfo')) this.getApprovalStatus()
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
})
}, },
methods: { methods: {
getMemberSummary() { getMemberSummary() {

View File

@ -52,16 +52,21 @@ export default {
}) })
}, },
getRoles() { getRoles() {
getRouters().then((res) => { return new Promise((resolve, reject) => {
this.roleMenu = res.data || [] getRouters().then((res) => {
if (!this.roleMenu.find((item) => item.routeName === 'summaryDashboard')) { this.roleMenu = res.data || []
this.topList.splice(0, 1) if (!this.roleMenu.find((item) => item.routeName === 'summaryDashboard')) {
if (this.$route.name === 'summaryDashboard') { this.topList.splice(0, 1)
this.$router.replace({ if (this.$route.name === 'SummaryDashboard') {
name: 'Dashboard' this.$router.replace({
}) name: 'Dashboard'
})
}
reject()
return
} }
} resolve()
})
}) })
} }
} }