修改保险后端代码,政府前端代码

This commit is contained in:
2025-09-22 17:56:30 +08:00
parent 3143c3ad0b
commit 02a25515a9
206 changed files with 35119 additions and 43073 deletions

View File

@@ -56,15 +56,24 @@ const openKeys = ref([])
// 菜单项
const menuItems = computed(() => {
const userRole = userStore.getUserRoleName()
return getMenuItems(routes, userRole)
try {
const userRole = userStore.getUserRoleName() || 'user'
return getMenuItems(routes, userRole)
} catch (error) {
console.error('获取菜单项失败:', error)
return []
}
})
// 处理菜单点击
const handleMenuClick = ({ key }) => {
const menuItem = findMenuItem(menuItems.value, key)
if (menuItem && menuItem.path) {
router.push(menuItem.path)
try {
const menuItem = findMenuItem(menuItems.value, key)
if (menuItem && menuItem.path) {
router.push(menuItem.path)
}
} catch (error) {
console.error('菜单点击处理失败:', error)
}
}
@@ -75,28 +84,43 @@ const handleOpenChange = (keys) => {
// 查找菜单项
const findMenuItem = (items, key) => {
for (const item of items) {
if (item.key === key) {
return item
try {
if (!Array.isArray(items)) {
return null
}
if (item.children) {
const found = findMenuItem(item.children, key)
if (found) return found
for (const item of items) {
if (item && item.key === key) {
return item
}
if (item && item.children) {
const found = findMenuItem(item.children, key)
if (found) return found
}
}
return null
} catch (error) {
console.error('查找菜单项失败:', error)
return null
}
return null
}
// 监听路由变化,自动展开对应的子菜单
watch(
() => route.path,
(newPath) => {
const pathSegments = newPath.split('/').filter(Boolean)
if (pathSegments.length > 1) {
const parentKey = pathSegments[0]
if (!openKeys.value.includes(parentKey)) {
openKeys.value = [parentKey]
try {
if (!newPath) return
const pathSegments = newPath.split('/').filter(Boolean)
if (pathSegments.length > 1) {
const parentKey = pathSegments[0]
if (parentKey && !openKeys.value.includes(parentKey)) {
openKeys.value = [parentKey]
}
}
} catch (error) {
console.error('路由监听处理失败:', error)
}
},
{ immediate: true }
@@ -106,12 +130,34 @@ watch(
<style scoped>
.ant-menu {
border-right: none;
height: 100%;
overflow-y: auto;
overflow-x: hidden;
}
.ant-menu::-webkit-scrollbar {
width: 6px;
}
.ant-menu::-webkit-scrollbar-track {
background: #001529;
}
.ant-menu::-webkit-scrollbar-thumb {
background: #1890ff;
border-radius: 3px;
}
.ant-menu::-webkit-scrollbar-thumb:hover {
background: #40a9ff;
}
.ant-menu-item,
.ant-menu-submenu-title {
display: flex;
align-items: center;
height: 48px;
line-height: 48px;
}
.ant-menu-item .anticon,
@@ -135,4 +181,20 @@ watch(
.ant-menu-submenu-open > .ant-menu-submenu-title {
color: #1890ff;
}
/* 折叠状态下的样式优化 */
.ant-menu-inline-collapsed .ant-menu-item {
padding: 0 24px;
text-align: center;
}
.ant-menu-inline-collapsed .ant-menu-submenu-title {
padding: 0 24px;
text-align: center;
}
.ant-menu-inline-collapsed .ant-menu-item .anticon,
.ant-menu-inline-collapsed .ant-menu-submenu-title .anticon {
margin-right: 0;
}
</style>