|
@ -1,3 +1,4 @@ |
|
|
|
|
|
// router/routes.ts
|
|
|
import n_audit from 'assets/images/menuIcon/n-audit.svg' |
|
|
import n_audit from 'assets/images/menuIcon/n-audit.svg' |
|
|
import n_debug from 'assets/images/menuIcon/n-debug.svg' |
|
|
import n_debug from 'assets/images/menuIcon/n-debug.svg' |
|
|
import n_disinfect from 'assets/images/menuIcon/n-disinfect.svg' |
|
|
import n_disinfect from 'assets/images/menuIcon/n-disinfect.svg' |
|
@ -14,156 +15,134 @@ import s_seal from 'assets/images/menuIcon/s-seal.svg' |
|
|
import s_setting from 'assets/images/menuIcon/s-setting.svg' |
|
|
import s_setting from 'assets/images/menuIcon/s-setting.svg' |
|
|
import { useDeviceStore } from 'stores/deviceStore' |
|
|
import { useDeviceStore } from 'stores/deviceStore' |
|
|
import pinia from 'stores/index' |
|
|
import pinia from 'stores/index' |
|
|
import type { Ref } from 'vue' |
|
|
|
|
|
import { ref, watchEffect } from 'vue' |
|
|
|
|
|
import type { RouteRecordRaw } from 'vue-router' |
|
|
import type { RouteRecordRaw } from 'vue-router' |
|
|
|
|
|
|
|
|
const authRoutes: Ref<RouteRecordRaw[]> = ref<RouteRecordRaw[]>([ |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/home', |
|
|
|
|
|
name: 'home', |
|
|
|
|
|
component: () => import('views/home/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '消毒', |
|
|
|
|
|
icon: n_disinfect, |
|
|
|
|
|
activeIcon: s_disinfect, |
|
|
|
|
|
}, |
|
|
|
|
|
children: [ |
|
|
|
|
|
{ |
|
|
|
|
|
path: 'config', |
|
|
|
|
|
name: 'config', |
|
|
|
|
|
component: () => import('components/home/config.vue'), |
|
|
|
|
|
|
|
|
export function generateRoutes(): RouteRecordRaw[] { |
|
|
|
|
|
const deviceStore = useDeviceStore(pinia) |
|
|
|
|
|
const userData = localStorage.getItem('user') |
|
|
|
|
|
const userInfo = userData ? JSON.parse(userData) : {} |
|
|
|
|
|
const userRole = userInfo.roleType || '' |
|
|
|
|
|
const deviceType = __DEVICE_TYPE__ |
|
|
|
|
|
|
|
|
|
|
|
const allRoutes: RouteRecordRaw[] = [ |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/home', |
|
|
|
|
|
name: 'home', |
|
|
|
|
|
component: () => import('views/home/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '消毒', |
|
|
|
|
|
icon: n_disinfect, |
|
|
|
|
|
activeIcon: s_disinfect, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
|
|
|
path: 'chart', |
|
|
|
|
|
name: 'chart', |
|
|
|
|
|
component: () => import('views/home/chart.vue'), |
|
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
{ |
|
|
|
|
|
path: 'config', |
|
|
|
|
|
name: 'config', |
|
|
|
|
|
component: () => import('components/home/config.vue'), |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: 'chart', |
|
|
|
|
|
name: 'chart', |
|
|
|
|
|
component: () => import('views/home/chart.vue'), |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/liquid', |
|
|
|
|
|
name: 'liquid', |
|
|
|
|
|
component: () => import('views/liquid/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '消毒液', |
|
|
|
|
|
icon: n_liquid, |
|
|
|
|
|
activeIcon: s_liquid, |
|
|
|
|
|
keepAlive: true, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/liquid', |
|
|
|
|
|
name: 'liquid', |
|
|
|
|
|
component: () => import('views/liquid/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '消毒液', |
|
|
|
|
|
icon: n_liquid, |
|
|
|
|
|
activeIcon: s_liquid, |
|
|
|
|
|
keepAlive: true, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/seal', |
|
|
|
|
|
name: 'seal', |
|
|
|
|
|
component: () => import('views/seal/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '密封测试', |
|
|
|
|
|
icon: n_seal, |
|
|
|
|
|
activeIcon: s_seal, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
path: '/seal', |
|
|
|
|
|
name: 'seal', |
|
|
|
|
|
component: () => import('views/seal/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '密封测试', |
|
|
|
|
|
icon: n_seal, |
|
|
|
|
|
activeIcon: s_seal, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/formula', |
|
|
|
|
|
name: 'formula', |
|
|
|
|
|
component: () => import('views/formula/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '配方', |
|
|
|
|
|
icon: n_formula, |
|
|
|
|
|
activeIcon: s_formula, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
path: '/formula', |
|
|
|
|
|
name: 'formula', |
|
|
|
|
|
component: () => import('views/formula/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '配方', |
|
|
|
|
|
icon: n_formula, |
|
|
|
|
|
activeIcon: s_formula, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/debug', |
|
|
|
|
|
name: 'debug', |
|
|
|
|
|
component: () => import('views/debug/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '测试', |
|
|
|
|
|
icon: n_debug, |
|
|
|
|
|
activeIcon: s_debug, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
path: '/debug', |
|
|
|
|
|
name: 'debug', |
|
|
|
|
|
component: () => import('views/debug/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '测试', |
|
|
|
|
|
icon: n_debug, |
|
|
|
|
|
activeIcon: s_debug, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/audit', |
|
|
|
|
|
name: 'audit', |
|
|
|
|
|
component: () => import('views/audit/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '审计', |
|
|
|
|
|
icon: n_audit, |
|
|
|
|
|
activeIcon: s_audit, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
path: '/audit', |
|
|
|
|
|
name: 'audit', |
|
|
|
|
|
component: () => import('views/audit/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '审计', |
|
|
|
|
|
icon: n_audit, |
|
|
|
|
|
activeIcon: s_audit, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/setting', |
|
|
|
|
|
name: 'setting', |
|
|
|
|
|
component: () => import('views/setting/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '设置', |
|
|
|
|
|
icon: n_setting, |
|
|
|
|
|
activeIcon: s_setting, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
path: '/setting', |
|
|
|
|
|
name: 'setting', |
|
|
|
|
|
component: () => import('views/setting/index.vue'), |
|
|
|
|
|
meta: { |
|
|
|
|
|
isDefault: true, |
|
|
|
|
|
title: '设置', |
|
|
|
|
|
icon: n_setting, |
|
|
|
|
|
activeIcon: s_setting, |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
|
|
|
const deviceStore = useDeviceStore(pinia) |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
if (__DEVICE_TYPE__ === deviceStore.deviceTypeMap.LargeSpaceDM_B) { |
|
|
|
|
|
// 大空间标准版
|
|
|
|
|
|
authRoutes.value = authRoutes.value.filter((item) => { |
|
|
|
|
|
return item.name !== 'seal' && item.name !== 'liquid' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
else if (__DEVICE_TYPE__ === deviceStore.deviceTypeMap.LargeSpaceDM) { |
|
|
|
|
|
// 大空间
|
|
|
|
|
|
authRoutes.value = authRoutes.value.filter((item) => { |
|
|
|
|
|
return item.name !== 'seal' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
else if (__DEVICE_TYPE__ === deviceStore.deviceTypeMap.SmallSpaceDM) { |
|
|
|
|
|
// 小空间
|
|
|
|
|
|
authRoutes.value = authRoutes.value.filter((item) => { |
|
|
|
|
|
return item.name !== 'seal' |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const filteredRoutes = allRoutes.filter((item) => { |
|
|
|
|
|
if ( |
|
|
|
|
|
(deviceType === deviceStore.deviceTypeMap.LargeSpaceDM_B && (item.name === 'seal' || item.name === 'liquid')) |
|
|
|
|
|
|| (deviceType === deviceStore.deviceTypeMap.LargeSpaceDM && item.name === 'seal') |
|
|
|
|
|
|| (deviceType === deviceStore.deviceTypeMap.SmallSpaceDM && item.name === 'seal') |
|
|
|
|
|
|| (deviceType === deviceStore.deviceTypeMap.DrawBarDM && item.name === 'liquid') |
|
|
|
|
|
) { |
|
|
|
|
|
return false |
|
|
} |
|
|
} |
|
|
else if (__DEVICE_TYPE__ === deviceStore.deviceTypeMap.DrawBarDM) { |
|
|
|
|
|
// 拉杆箱
|
|
|
|
|
|
authRoutes.value = authRoutes.value.filter((item) => { |
|
|
|
|
|
return item.name !== 'liquid' |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
if (item.name === 'debug' && userRole !== 'admin') { |
|
|
|
|
|
return false |
|
|
} |
|
|
} |
|
|
// if (!deviceStore.deviceState.loginUser.roleType.includes('admin')) { // 测试菜单
|
|
|
|
|
|
// authRoutes.value = authRoutes.value.filter((item) => {
|
|
|
|
|
|
// return item.name !== 'debug'
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }
|
|
|
|
|
|
/* else { // 管道式 |
|
|
|
|
|
authRoutes.value = authRoutes.value.filter((item) => { |
|
|
|
|
|
return item.name !== 'liquid' |
|
|
|
|
|
}) |
|
|
|
|
|
} */ |
|
|
|
|
|
}, 2000) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
return true |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
const routes: RouteRecordRaw[] = [ |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/login', |
|
|
|
|
|
name: 'login', |
|
|
|
|
|
component: () => import('../views/login/index.vue'), |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/', |
|
|
|
|
|
component: () => import('../layouts/default.vue'), |
|
|
|
|
|
redirect: '/home', |
|
|
|
|
|
children: authRoutes.value, |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
export { authRoutes } |
|
|
|
|
|
export default routes |
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/', |
|
|
|
|
|
component: () => import('../layouts/default.vue'), |
|
|
|
|
|
redirect: '/home', |
|
|
|
|
|
children: filteredRoutes, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
path: '/login', |
|
|
|
|
|
name: 'login', |
|
|
|
|
|
component: () => import('../views/login/index.vue'), |
|
|
|
|
|
}, |
|
|
|
|
|
] |
|
|
|
|
|
} |