Commit 32f29cc1 authored by 范骋宇's avatar 范骋宇 🇺🇸

登陆之后绕过导航页面,直接跳转文档中心

parent 717a5684
...@@ -144,11 +144,17 @@ export const constantRoutes = [ ...@@ -144,11 +144,17 @@ export const constantRoutes = [
// component: () => import('@/views/general/page/index.vue'), // component: () => import('@/views/general/page/index.vue'),
// hidden: true // hidden: true
// }, // },
// {
// path: '/',
// name: 'navigation',
// meta: { disnav: true },
// component: () => import('@/views/navigation/index'),
// hidden: true
// },
{ {
path: '/', path: '/',
name: 'navigation',
meta: { disnav: true }, meta: { disnav: true },
component: () => import('@/views/navigation/index'), component: () => import('@/views/login/index'),
hidden: true hidden: true
}, },
// { // {
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
</template> </template>
<script> <script>
import { getPageByWorkspaceId } from '@/api/usercenter'
// import CryptoJS from 'crypto-js' // import CryptoJS from 'crypto-js'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import RSA from '@/utils/rsa.js' import RSA from '@/utils/rsa.js'
...@@ -131,7 +132,7 @@ export default { ...@@ -131,7 +132,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['supportedLanguages']) ...mapGetters(['supportedLanguages', 'activeWorkSpace', 'permMenus'])
}, },
watch: { watch: {
'loginForm.account'(val) { 'loginForm.account'(val) {
...@@ -185,7 +186,7 @@ export default { ...@@ -185,7 +186,7 @@ export default {
validate.then(x => { validate.then(x => {
const params = JSON.parse(JSON.stringify(this.loginForm)) const params = JSON.parse(JSON.stringify(this.loginForm))
params.password = password params.password = password
this.$store.dispatch('user/login', params).then((res) => { this.$store.dispatch('user/login', params).then(async(res) => {
// 记录认证方式和认证方式对应的token字段名称 // 记录认证方式和认证方式对应的token字段名称
this.$utils.setTokenName() this.$utils.setTokenName()
this.$utils.setAuthType() this.$utils.setAuthType()
...@@ -203,7 +204,9 @@ export default { ...@@ -203,7 +204,9 @@ export default {
this.$store.dispatch('tagsView/delAllCachedViews', params) this.$store.dispatch('tagsView/delAllCachedViews', params)
this.$store.dispatch('permission/clearPermissionList') this.$store.dispatch('permission/clearPermissionList')
// this.$router.push({ path: this.redirect || '/' }) // this.$router.push({ path: this.redirect || '/' })
this.$router.push({ path: '/' }) // this.$router.push({ path: '/' })
await this.$store.dispatch('menu/getMenus')
this.getMenusPerm()
} }
}) })
// 清除剪切板 // 清除剪切板
...@@ -211,6 +214,181 @@ export default { ...@@ -211,6 +214,181 @@ export default {
}).catch(e => { }).catch(e => {
}) })
} }
},
getMenusPerm() {
getPageByWorkspaceId({ id: this.activeWorkSpace.id }).then(res => {
const allApps = res.items.sourceDxAppWorkLink ? res.items.sourceDxAppWorkLink.map(r => {
return r.target
}) : []
let dxAppWorkGroups = []
const tabs = []
if (Array.isArray(res.items.dxAppWorkGroups) && res.items.dxAppWorkGroups.length > 0) {
dxAppWorkGroups = res.items.dxAppWorkGroups || []
}
dxAppWorkGroups.forEach((group, idx) => {
tabs.push({
name: group.groupName,
id: group.id + '',
dxApplications: group.sourceDxAppWorkGroupLink && group.sourceDxAppWorkGroupLink.length ? this.getPermAppMenu(group.sourceDxAppWorkGroupLink.map(r => {
r.target && allApps.push(r.target)
r.target.pWorkGroupName = group.groupName
return r.target
})) : []
})
})
const obj = {}
const apps = this.getPermAppMenu(allApps.reduce(function(item, next) {
obj[next.id] ? '' : obj[next.id] = true && item.push(next)
return item
}, []))
if (apps.length > 0) {
const docApp = apps.find(a => a.innerName === 'dcs-doc')
if (docApp) {
this.goContent(docApp)
} else {
this.$utils.showMessageWarning('请在应用中心配置菜单页面')
}
} else {
this.$utils.showMessageWarning('请在应用中心配置菜单页面')
}
})
},
goContent(app) {
if (!app.dxApplicationMenus) {
return this.$utils.showMessageWarning('请在应用中心配置菜单页面')
}
const menu = this.$utils.generateTree(app.dxApplicationMenus, {
pid: 'parentId'
})
console.log({ menu })
if (this.activeWorkSpace) {
const params = {
'openProps': [
{
'name': 'dxApplicationPage'
}
],
'searchItems': {
'items': [
{
'fieldName': 'dxWorkspaceId',
'operator': 'EQ',
'value': this.activeWorkSpace.id
},
{
'fieldName': 'dxApplicationId',
'operator': 'EQ',
'value': app.id
}
],
'operator': 'AND'
}
}
this.$api.searchApi('DxSpaceStartPage', params).then(res => {
if (res.items.content && res.items.content.length) {
const activePage = res.items.content[0].dxApplicationPage
console.log({ activePage })
let toPage
if (activePage.type === '1') {
toPage = {
path: `/page/${activePage.pageKey}`,
query: {}
}
} else if (activePage.type === '2') {
toPage = {
path: activePage.route,
query: {}
}
}
if (activePage.name) {
toPage.query.title = activePage.name
}
toPage.query.menuRootAppId = app.id
this.setMenu(menu || [])
localStorage.setItem('moduleName', app.name)
this.$router.push(toPage)
} else {
this.topage(menu, app)
}
})
} else {
this.topage(menu, app)
}
},
getPermAppMenu(dxApplications) {
console.log({ dxApplications })
console.log(' this.permMenus', this.permMenus)
const permMenus = this.permMenus.filter(m => m.dxApplicationId)
const apps = []
dxApplications.forEach(app => {
const menuIdx = permMenus.findIndex(g => g.dxApplicationId === app.id)
if (menuIdx > -1) {
app.dxApplicationMenus = permMenus.filter(h => h.parentId && h.dxApplicationId === app.id)
apps.push(app)
}
})
return apps
},
setMenu(menu) {
// this.$store.dispatch('menu/updateMenu', menu)
// localStorage.setItem('menu', JSON.stringify(menu))
},
topage(menu, app) {
console.log({ menu, app })
const activePage = this.getActiveTab(menu)
console.log({ activePage })
if (!activePage) return
// this.$store.dispatch('tagsView/addCachedMenuPages', {
// menuId: menu.id,
// pageId: activePage.id
// })
// if (!item.permFlag) {
// return
// }
let toPage
if (activePage.type === '1') {
toPage = {
path: `/page/${activePage.pageKey}`,
query: {}
}
} else if (activePage.type === '2') {
toPage = {
path: activePage.route,
query: {}
}
}
if (activePage.name) {
toPage.query.title = activePage.name
}
toPage.query.menuRootAppId = app.id
this.setMenu(menu || [])
localStorage.setItem('moduleName', app.name)
this.$router.push(toPage)
},
getActiveTab(menus) {
for (let i = 0; i < menus.length; i++) {
const menu = menus[i]
if (
menu.dxApplicationPage &&
menu.dxApplicationPage.subTypeName === 'DxApplicationPage' &&
menu.permFlag
) {
return menu.dxApplicationPage
} else if (menu.children && menu.children.length > 0 && menu.permFlag) {
for (let j = 0; j < menu.children.length; j++) {
const item = menu.children[j]
if (
item.dxApplicationPage &&
item.dxApplicationPage.subTypeName === 'DxApplicationPage'
) {
return item.dxApplicationPage
} else if (item.children && item.children.length > 0) {
return this.getActiveTab(item)
}
}
}
}
} }
/** /**
* AES加密方法 * AES加密方法
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment