[Fix-6649][UI] Get project according to code (#6649) (#6650)

Co-authored-by: linyanbin <linyanbin@lizhi.fm>
This commit is contained in:
Yanbin Lin 2021-11-06 10:12:01 +08:00 committed by lenboo
parent a007595dbc
commit 93ad2823f4
2 changed files with 5 additions and 6 deletions

View File

@ -54,10 +54,9 @@ const router = new Router({
},
beforeEnter: (to, from, next) => {
const blacklist = ['projects', 'projects-list']
if (!blacklist.includes(to.name) && to.params.projectId && to.params.projectId !== localStore.getItem('projectId')) {
store.dispatch('projects/getProjectById', {
projectId: to.params.projectId
}).then(res => {
const { projectCode } = to.params || {}
if (!blacklist.includes(to.name) && projectCode && projectCode !== localStore.getItem('projectCode')) {
store.dispatch('projects/getProjectByCode', projectCode).then(res => {
store.commit('dag/setProjectId', res.id)
store.commit('dag/setProjectCode', res.code)
store.commit('dag/setProjectName', res.name)

View File

@ -31,9 +31,9 @@ export default {
})
},
/**
* Get project by id
* Get project by code
*/
getProjectById ({ state }, payload) {
getProjectByCode ({ state }, payload) {
return new Promise((resolve, reject) => {
io.get(`projects/${payload}`, {}, res => {
resolve(res.data)