diff --git a/public/config.js b/public/config.js index 82f5d57..2d1e4c9 100644 --- a/public/config.js +++ b/public/config.js @@ -1,11 +1,25 @@ // @ts-ignore window._CONFIG = { + // 地图用图片资源地址 ImageryProviderUrl: '/map/mapWX/{z}/{x}/{y}.jpg', RoadProviderUrl: '', TerrainProviderUrl: '/map/mapTerrain/', + + // 显示系统菜单 + showSystemMenu: true, + + // 使用第三方登录 + useThirdLogin: false, + // 第三方登录地址 thirdLoginUrl: 'http://127.0.0.1:8080/thirdLogin', + // 第三方注册AppId clientId: '0123456789', - evaluationSrc: 'http://192.168.0.189:8088/thirdLogin/thirdLoginPage?username=admin', - VUE_APP_API_URL: 'http://192.168.0.225:8099', - VUE_APP_WEBSOCKET_URL: 'ws://192.168.0.225:8099', + + // 评估子系统 内嵌iframe地址 + evaluationSrc: 'http://192.168.0.53:8088/thirdLogin/thirdLoginPage?username=admin', + + // 服务端地址 + VUE_APP_API_URL: 'http://192.168.0.53:8099', + // websocket服务地址 + VUE_APP_WEBSOCKET_URL: 'ws://192.168.0.53:8099', } diff --git a/src/permission.js b/src/permission.js index b0ba92c..df88cc0 100644 --- a/src/permission.js +++ b/src/permission.js @@ -11,7 +11,7 @@ import openThirdLogin from './utils/openThirdLogin' NProgress.configure({ showSpinner: false }) // NProgress Configuration -const allowList = ['thirdLogin', 'login', 'register', 'registerResult'] // no redirect allowList +const allowList = ['login', 'Welcome'] // no redirect allowList const loginRoutePath = '/user/login' const defaultRoutePath = '/user/welcome' @@ -58,11 +58,11 @@ router.beforeEach((to, from, next) => { }) // 失败时,获取用户信息失败时,调用登出,来清空历史保留信息 store.dispatch('Logout').then(() => { - // if (process.env.NODE_ENV === 'production') { - // openThirdLogin() - // } else { - next({ path: loginRoutePath, query: { redirect: to.fullPath } }) - // } + if (window._CONFIG.useThirdLogin) { + openThirdLogin() + } else { + next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + } }) }) } else { @@ -74,11 +74,11 @@ router.beforeEach((to, from, next) => { // 在免登录名单,直接进入 next() } else { - // if (process.env.NODE_ENV === 'production') { - // openThirdLogin() - // } else { - next({ path: loginRoutePath, query: { redirect: to.fullPath } }) - // } + if (window._CONFIG.useThirdLogin) { + openThirdLogin() + } else { + next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + } NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it } } diff --git a/src/router/generator-routers.js b/src/router/generator-routers.js index 78cac3e..9c11eac 100644 --- a/src/router/generator-routers.js +++ b/src/router/generator-routers.js @@ -10,13 +10,13 @@ const constantRouterComponents = { BlankLayout: BlankLayout, RouteView: RouteView, PageView: PageView, - '403': () => import(/* webpackChunkName: "error" */ '@/views/exception/403'), - '404': () => import(/* webpackChunkName: "error" */ '@/views/exception/404'), - '500': () => import(/* webpackChunkName: "error" */ '@/views/exception/500'), + 403: () => import(/* webpackChunkName: "error" */ '@/views/exception/403'), + 404: () => import(/* webpackChunkName: "error" */ '@/views/exception/404'), + 500: () => import(/* webpackChunkName: "error" */ '@/views/exception/500'), // 你需要动态引入的页面组件 WorkplaceEquipment: () => import('@/views/dashboard/WorkplaceEquipment'), - Analysis: () => import('@/views/dashboard/Analysis') + Analysis: () => import('@/views/dashboard/Analysis'), // 'TestWork': () => import(/* webpackChunkName: "TestWork" */ '@/views/dashboard/TestWork') } @@ -24,7 +24,7 @@ const constantRouterComponents = { const notFoundRouter = { path: '*', redirect: '/404', - hidden: true + hidden: true, } // 根级菜单 @@ -36,9 +36,72 @@ const rootRouter = { component: 'BasicLayout', // redirect: '/dashboard/equipment', meta: { - title: '首页' + title: '首页', }, - children: [] + children: [], +} + +const systemNav = { + id: '_67ed94a37b03415c8ee77a8991e79745', + title: '系统管理', + key: 'System', + name: '系统管理', + component: 'BasicLayout', + redirect: '/system/userlist', + parentId: '', + icon: 'dashboard', + children: [ + { + id: '_1', + title: '菜单管理', + key: 'MenuList', + name: '菜单管理', + component: 'isystem/menuList', + redirect: null, + parentId: '67ed94a37b03415c8ee77a8991e79745', + icon: 'dashboard', + }, + { + id: '_5114bf6a963f41149ab2435c86551927', + title: '用户管理', + key: 'UserList', + name: '用户管理', + component: 'isystem/userList', + redirect: null, + parentId: '67ed94a37b03415c8ee77a8991e79745', + icon: 'dashboard', + }, + { + id: '_230a5ebe7cdc41acb997122d6de2d86f', + title: '角色管理', + key: 'RoleList', + name: '角色管理', + component: 'isystem/roleList', + redirect: null, + parentId: '67ed94a37b03415c8ee77a8991e79745', + icon: 'dashboard', + }, + { + id: '_2fd1683b13c241be84c34185ff55028e', + title: '字典管理', + key: 'DictIndex', + name: '字典管理', + component: 'isystem/dict/dictlist', + redirect: null, + parentId: '67ed94a37b03415c8ee77a8991e79745', + icon: 'dashboard', + }, + { + id: '_85924f8619f1451e847c9f69705f360f', + title: '系统日志', + key: 'LogList', + name: '系统日志', + component: 'isystem/logList', + redirect: null, + parentId: '67ed94a37b03415c8ee77a8991e79745', + icon: 'dashboard', + }, + ], } /** @@ -75,11 +138,11 @@ const rootRouter = { // }) // }) // } -export const generatorDynamicRouter = token => { +export const generatorDynamicRouter = (token) => { return new Promise((resolve, reject) => { loginService .getCurrentUserNav() - .then(res => { + .then((res) => { console.log('generatorDynamicRouter response:', res) const data = res.data const childrenNav = [] @@ -87,11 +150,14 @@ export const generatorDynamicRouter = token => { // 后端数据, 根级树数组, 根级 PID listToTree(data, childrenNav, '') console.log('childrenNav', childrenNav) + if (window._CONFIG.showSystemMenu) { + childrenNav.push(systemNav) + } const routers = generator(childrenNav) console.log('routers', routers) resolve(routers) }) - .catch(err => { + .catch((err) => { reject(err) }) }) @@ -104,8 +170,8 @@ export const generatorDynamicRouter = token => { * @param parent * @returns {*} */ - export const generator = (routerMap, parent) => { - return routerMap.map(item => { +export const generator = (routerMap, parent) => { + return routerMap.map((item) => { const { title, show, hideChildren, hiddenHeaderContent, target, icon } = item || item.meta || {} const currentRouter = { // 如果路由设置了 path,则作为默认 path,否则 路由地址 动态拼接生成如 /dashboard/workplace @@ -123,9 +189,9 @@ export const generatorDynamicRouter = token => { title: title, icon: icon || undefined, hiddenHeaderContent: hiddenHeaderContent, - target: target + target: target, // permission: item.name - } + }, } // 是否设置了隐藏菜单 if (show === false) { @@ -157,13 +223,13 @@ export const generatorDynamicRouter = token => { * @param parentId 父ID */ const listToTree = (list, tree, parentId) => { - list.forEach(item => { + list.forEach((item) => { // 判断是否为父级菜单 if (item.parentId === parentId) { const child = { ...item, key: item.key || item.name, - children: [] + children: [], } // 迭代 list, 找到当前菜单相符合的所有子菜单 listToTree(list, child.children, item.id) diff --git a/src/utils/openThirdLogin.js b/src/utils/openThirdLogin.js index fdd5771..ef5efef 100644 --- a/src/utils/openThirdLogin.js +++ b/src/utils/openThirdLogin.js @@ -1,5 +1,5 @@ export default () => { - const redirectUri = window.location.origin + '/user/thirdLogin' + const redirectUri = window.location.origin + '/user/welcome' window.location.href = window._CONFIG.thirdLoginUrl + '?response_type=code&active_type=user&state=' + diff --git a/src/utils/request.js b/src/utils/request.js index ec63cf6..8cc2324 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -26,7 +26,10 @@ const errorHandler = (error) => { description: data.message, }) } - if (error.response.status === 401 && !(data.result && data.result.isLogin)) { + if ( + (error.response.status === 500 && error.response.data.message === '未找到授权信息') || + (error.response.status === 401 && !(data.result && data.result.isLogin)) + ) { notification.error({ message: '温馨提示', description: '登录过期,请重新登录', @@ -35,13 +38,21 @@ const errorHandler = (error) => { if (token) { store.dispatch('Logout').then(() => { setTimeout(() => { - // if (process.env.NODE_ENV === 'production') { - // openThirdLogin() - // } else { - window.location.reload() - // } - }, 1500) + if (window._CONFIG.useThirdLogin) { + openThirdLogin() + } else { + window.location = '/user/login?redirect=' + window.location.pathname + } + }, 1000) }) + } else { + setTimeout(() => { + if (window._CONFIG.useThirdLogin) { + openThirdLogin() + } else { + window.location = '/user/login?redirect=' + window.location.pathname + } + }, 1000) } } } diff --git a/src/views/simulationScene/database/bzhjsjk.vue b/src/views/simulationScene/database/bzhjsjk.vue index e3179cd..f2899d4 100644 --- a/src/views/simulationScene/database/bzhjsjk.vue +++ b/src/views/simulationScene/database/bzhjsjk.vue @@ -38,8 +38,15 @@ :pageConfig="qxhj.pageConfig" :showTool="qxhj.showTool" > + + @@ -91,6 +98,7 @@ diff --git a/src/views/user/ThirdLogin.vue b/src/views/user/ThirdLogin.vue index dd6dca0..9092932 100644 --- a/src/views/user/ThirdLogin.vue +++ b/src/views/user/ThirdLogin.vue @@ -129,7 +129,7 @@ export default { onCancel() {}, }) } - if (process.env.NODE_ENV === 'production') { + if (window._CONFIG.useThirdLogin) { this.$store.dispatch('Logout').then(() => { openThirdLogin() }) diff --git a/src/views/user/Welcome.vue b/src/views/user/Welcome.vue index 61fd5a1..bbd0239 100644 --- a/src/views/user/Welcome.vue +++ b/src/views/user/Welcome.vue @@ -23,6 +23,7 @@