| | |
| | | // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理! |
| | | { path: '/home', component: _import('modules/user/user'), name: 'home', meta: { title: '首页' } }, |
| | | { path: '/prodInfo', component: _import('modules/prod/prodInfo'), name: 'prodInfo', meta: { title: '产品详情' } }, |
| | | { path: '/message', component: _import('message/index'), name: 'message', meta: { title: '产品详情' } } |
| | | { path: '/message', component: _import('message/index'), name: 'message', meta: { title: '产品详情' } }, |
| | | // 美股交割合约单:固定路由,不依赖 tz_sys_menu 配置 |
| | | { |
| | | path: '/us-spots-us-pickAddr', |
| | | component: _import('modules/us-spots/us-pickAddr'), |
| | | name: 'us-spots-us-pickAddr', |
| | | meta: { title: '交割合约单(US)', isTab: true, menuId: 1981 } |
| | | } |
| | | ], |
| | | beforeEnter (to, from, next) { |
| | | let authorization = Vue.cookie.get('Authorization') |
| | |
| | | appType:1 |
| | | }, |
| | | ) |
| | | }).then(({ data }) => { |
| | | }).then(({ data }) => { |
| | | const menuList = pinFixedUsPickAddrMenu(data.menuList || []) |
| | | sessionStorage.setItem('authorities', JSON.stringify(data.authorities || '[]')) |
| | | //sessionStorage.setItem('authorities', JSON.stringify(menu.authorities || '[]'))(本地模拟) |
| | | //fnAddDynamicMenuRoutes(menu.menuList)(本地模拟) |
| | | fnAddDynamicMenuRoutes(data.menuList) |
| | | fnAddDynamicMenuRoutes(menuList) |
| | | router.options.isAddDynamicMenuRoutes = true |
| | | sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]')) |
| | | //sessionStorage.setItem('menuList', JSON.stringify(menu.menuList || '[]'))(本地模拟) |
| | | sessionStorage.setItem('menuList', JSON.stringify(menuList || '[]')) |
| | | |
| | | // |
| | | let menuList = data.menuList |
| | | // console.log("menuList = " + JSON.stringify(menuList)); |
| | | let urls = [] |
| | | for(let i = 0 ;menuList && i < menuList.length ; i++){ |
| | |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | /** |
| | | * 固定注入「交割合约单(US)」到左侧菜单(orderNum>23),不依赖数据库菜单配置 |
| | | */ |
| | | function pinFixedUsPickAddrMenu (menuList) { |
| | | const url = 'us-spots/us-pickAddr' |
| | | if (menuTreeHasUrl(menuList, url)) { |
| | | return menuList |
| | | } |
| | | menuList.push({ |
| | | menuId: 1981, |
| | | parentId: 0, |
| | | name: '交割合约单(US)', |
| | | url: url, |
| | | perms: '', |
| | | type: 1, |
| | | icon: 'sql', |
| | | orderNum: 24, |
| | | list: null, |
| | | appType: '1' |
| | | }) |
| | | menuList.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0)) |
| | | return menuList |
| | | } |
| | | |
| | | function menuTreeHasUrl (list, url) { |
| | | if (!list || !list.length) { |
| | | return false |
| | | } |
| | | for (const node of list) { |
| | | if (node.url === url) { |
| | | return true |
| | | } |
| | | if (node.list && menuTreeHasUrl(node.list, url)) { |
| | | return true |
| | | } |
| | | } |
| | | return false |
| | | } |
| | | |
| | | function ensureEssentialUsRoutes (routes) { |
| | | const name = 'us-spots-us-pickAddr' |
| | | if (routes.some((r) => r.name === name)) { |
| | | return |
| | | } |
| | | routes.push({ |
| | | path: '/us-spots-us-pickAddr', |
| | | component: _import('modules/us-spots/us-pickAddr'), |
| | | name: name, |
| | | meta: { title: '交割合约单(US)', isTab: true, menuId: 1981, isDynamic: true, iframeUrl: '' } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 判断当前路由类型, global: 全局路由, main: 主入口路由 |
| | |
| | | if (temp.length >= 1) { |
| | | fnAddDynamicMenuRoutes(temp, routes) |
| | | } else { |
| | | ensureEssentialUsRoutes(routes) |
| | | const fixedChildren = mainRoutes.children.filter((r) => r.meta && !r.meta.isDynamic) |
| | | mainRoutes.name = 'main-dynamic' |
| | | mainRoutes.children = routes |
| | | mainRoutes.children = fixedChildren.concat( |
| | | routes.filter((r) => !fixedChildren.some((f) => f.name === r.name)) |
| | | ) |
| | | router.addRoutes([ |
| | | mainRoutes, |
| | | { path: '*', redirect: { name: '404' } } |