perf: 修改 tickets orgs (#1691)

* perf: 修改 tickets orgs

* perf: 修改 orgs 切换

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot 2022-04-20 15:27:04 +08:00 committed by GitHub
parent 12a85da6f7
commit a162a206bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 3 deletions

View File

@ -113,7 +113,13 @@ const actions = {
commit('SET_MFA_VERIFY') commit('SET_MFA_VERIFY')
}, },
changeToView({ commit }, viewName) { changeToView({ commit }, viewName) {
const usingOrgs = state[`${viewName}Orgs`] || state.consoleOrgs const mapper = {
console: state.consoleOrgs,
audit: state.auditOrgs,
workbench: state.workbenchOrgs,
tickets: state.consoleOrgs
}
const usingOrgs = mapper[viewName] || state.consoleOrgs
Vue.$log.debug('Set using orgs: ', viewName, usingOrgs) Vue.$log.debug('Set using orgs: ', viewName, usingOrgs)
commit('SET_USING_ORGS', usingOrgs) commit('SET_USING_ORGS', usingOrgs)
} }

View File

@ -82,6 +82,7 @@ export function hasActionPerm(route, action) {
export function getPermedViews() { export function getPermedViews() {
const viewShowMapper = [ const viewShowMapper = [
['console', store.getters.consoleOrgs.length > 0], ['console', store.getters.consoleOrgs.length > 0],
['tickets', store.getters.consoleOrgs.length > 0],
['audit', store.getters.auditOrgs.length > 0], ['audit', store.getters.auditOrgs.length > 0],
['workbench', true] ['workbench', true]
] ]

View File

@ -10,7 +10,7 @@ function getPropOrg() {
if (defaultOrg) { if (defaultOrg) {
return defaultOrg return defaultOrg
} }
return orgs[0] return orgs.filter(item => !item.is_root)[0]
} }
function change2PropOrg() { function change2PropOrg() {

View File

@ -120,7 +120,7 @@ export async function checkUserFirstLogin({ to, from, next }) {
export async function changeCurrentViewIfNeed({ to, from, next }) { export async function changeCurrentViewIfNeed({ to, from, next }) {
let viewName = to.path.split('/')[1] let viewName = to.path.split('/')[1]
// 这几个是需要检测的, 切换视图组织时,避免 404 // 这几个是需要检测的, 切换视图组织时,避免 404
if (['console', 'audit', 'workbench', ''].indexOf(viewName) === -1) { if (['console', 'audit', 'workbench', 'tickets', ''].indexOf(viewName) === -1) {
Vue.$log.debug('Current view no need check', viewName) Vue.$log.debug('Current view no need check', viewName)
return return
} }