- 新增 router/view-glob.ts,动态菜单兜底的全量 glob 表改为按需动态加载, 入口 chunk 由 465KB 降至 393KB;Sidebar / TaskView 用 utils/path 的 resolveRoutePath 替换 path-browserify 静态引用 - 新增 utils/perf-probe 轻量探针(?perf=1 或 localStorage 开启),输出导航耗时、 资源分类统计、长任务与硬件信息;移除 text-rendering: optimizeLegibility, breadcrumb 过渡由 all 改为 opacity/transform,降低弱 CPU 与非 Chrome 内核开销 - Navbar 工单角标轮询在后台标签页跳过,通过 visibilitychange 回到前台补刷一次 - 库存详情、货位、条码、入库日志、出库日志与明细、收货日志、盘点记录等 详情面板由 el-table 迁移到 UpperTable,统一展开行、分页、选择与列插槽 - 11 处模板配置及内嵌表格开启行选择;转储、转退货、批量复核弹窗改用 SelectedTags 展示已选项并支持逐个移除,移除最后一个后自动关闭 - ImagesUpload 重构为「图库 + 上传区」面板,支持多选、最多 20 张、 单张 10MB 校验与数量提示 - 新增《跨浏览器性能-分析与优化清单》文档
176 lines
4.3 KiB
Vue
176 lines
4.3 KiB
Vue
<template>
|
||
<div v-if="!item.hidden && !(item.meta && item.meta.hidden)">
|
||
<template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
|
||
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
|
||
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown': !isNest}">
|
||
<component
|
||
:is="isNest ? SubItem : Item"
|
||
:icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"
|
||
:title="onlyOneChild.name?.replace(/_Child$/, '')"
|
||
:path="resolvePath(onlyOneChild.path)"
|
||
v-bind="isNest ? { showStar } : {}"
|
||
/>
|
||
</el-menu-item>
|
||
</app-link>
|
||
</template>
|
||
|
||
<el-sub-menu
|
||
v-else
|
||
ref="subMenu"
|
||
:index="resolvePath(item.path)"
|
||
popper-append-to-body
|
||
:popper-class="isHorizontal ? 'top-menu-popup' : ''"
|
||
>
|
||
<template #title>
|
||
<component
|
||
:is="isNest ? SubItem : Item"
|
||
v-if="item.meta"
|
||
:icon="item.meta.icon"
|
||
:title="item.name?.replace(/_Child$/, '')"
|
||
:path="resolvePath(item.path)"
|
||
v-bind="isNest ? { showStar } : {}"
|
||
/>
|
||
</template>
|
||
<sidebar-item
|
||
v-for="child in item.children"
|
||
:key="child.path"
|
||
:is-nest="true"
|
||
:show-star="true"
|
||
:item="child"
|
||
:base-path="resolvePath(child.path)"
|
||
:is-horizontal="isHorizontal"
|
||
class="nest-menu"
|
||
/>
|
||
</el-sub-menu>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref } from 'vue'
|
||
import { resolveRoutePath } from '@/utils/path'
|
||
import { isExternal } from '@/utils/validate'
|
||
import Item from './Item.vue'
|
||
import SubItem from './SubItem.vue'
|
||
import AppLink from './Link.vue'
|
||
|
||
defineOptions({
|
||
name: 'SidebarItem'
|
||
})
|
||
|
||
const props = defineProps({
|
||
item: {
|
||
type: Object,
|
||
required: true
|
||
},
|
||
isNest: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
basePath: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
isHorizontal: {
|
||
type: Boolean,
|
||
default: false
|
||
},
|
||
/**
|
||
* 当前层是否显示星标(收藏)按钮。
|
||
* 递归子项时固定传 true,只有顶部「更多」下拉的一级选项会传 false。
|
||
*/
|
||
showStar: {
|
||
type: Boolean,
|
||
default: true
|
||
}
|
||
})
|
||
|
||
const onlyOneChild = ref<any>(null)
|
||
|
||
const hasOneShowingChild = (children: any[] = [], parent: any) => {
|
||
const showingChildren = children.filter(item => {
|
||
if (item.hidden || (item.meta && item.meta.hidden)) {
|
||
return false
|
||
} else {
|
||
onlyOneChild.value = item
|
||
return true
|
||
}
|
||
})
|
||
|
||
if (showingChildren.length === 1) {
|
||
return true
|
||
}
|
||
|
||
if (showingChildren.length === 0) {
|
||
onlyOneChild.value = { ...parent, path: '', noShowingChildren: true, name: parent.name }
|
||
return true
|
||
}
|
||
|
||
return false
|
||
}
|
||
|
||
const resolvePath = (routePath: string) => {
|
||
if (isExternal(routePath)) {
|
||
return routePath
|
||
}
|
||
if (isExternal(props.basePath)) {
|
||
return props.basePath
|
||
}
|
||
return resolveRoutePath(props.basePath, routePath)
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
/* Element Plus Menu Item Styles Override */
|
||
:deep(.el-sub-menu__title),
|
||
:deep(.el-menu-item) {
|
||
height: auto !important;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-direction: column;
|
||
padding: 8px 10px !important;
|
||
line-height: normal;
|
||
}
|
||
|
||
/* Horizontal Mode Adjustment */
|
||
:deep(.el-menu--horizontal) {
|
||
.el-menu-item, .el-sub-menu__title {
|
||
flex-direction: row !important;
|
||
height: 50px !important;
|
||
padding: 0 20px !important;
|
||
}
|
||
}
|
||
|
||
/* Nested menu indentation */
|
||
.nest-menu {
|
||
:deep(.el-menu-item),
|
||
:deep(.el-sub-menu__title) {
|
||
padding-left: 20px !important;
|
||
flex-direction: row !important;
|
||
height: 40px !important;
|
||
}
|
||
|
||
/* 叶子项:星标靠最右,与展开箭头同一列 */
|
||
:deep(.el-menu-item) {
|
||
padding-right: 12px !important;
|
||
}
|
||
|
||
/* 带子项:星标(若有)+ 展开箭头,右侧留足 34px */
|
||
:deep(.el-sub-menu__title) {
|
||
padding-right: 34px !important;
|
||
}
|
||
|
||
/* 展开箭头:与项目蓝色强调色一致,hover 时高亮 */
|
||
:deep(.el-sub-menu__icon-arrow) {
|
||
right: 12px;
|
||
font-size: 12px;
|
||
color: #909399;
|
||
transition: transform 0.25s ease, color 0.2s ease;
|
||
}
|
||
|
||
:deep(.el-sub-menu__title:hover .el-sub-menu__icon-arrow) {
|
||
color: #2f80ed;
|
||
}
|
||
}
|
||
</style>
|