|
|
@ -36,7 +36,6 @@ const getPath = (route) => { |
|
|
|
return routePath |
|
|
|
} |
|
|
|
} |
|
|
|
const refresh = ref(true) |
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
name: 'CategoryHeader', |
|
|
@ -48,11 +47,17 @@ export default defineComponent({ |
|
|
|
const categoryRouters = unref(routers).filter(item=>item.meta.hidden!=true&&item.path!='/') |
|
|
|
console.log('categoryRouters==',categoryRouters) |
|
|
|
//默认展开第一行 |
|
|
|
if(categoryRouters.length>0){ |
|
|
|
appStore.setCategoryRoutePath(categoryRouters[0].path) |
|
|
|
const currentPath = useRouter().currentRoute.value.matched[0].path |
|
|
|
if(currentPath){ |
|
|
|
appStore.setCategoryRoutePath(currentPath) |
|
|
|
} |
|
|
|
return () => !refresh.value?(<span></span>):( |
|
|
|
<ElMenu v-if={refresh.value} |
|
|
|
|
|
|
|
const activeMenu = computed(() => { |
|
|
|
return appStore.getCategoryRoutePath |
|
|
|
}) |
|
|
|
return () => ( |
|
|
|
<ElMenu |
|
|
|
defaultActive={unref(activeMenu)} |
|
|
|
id={`${variables.namespace}-tool-header`} |
|
|
|
popperOffset={16} |
|
|
|
class={['categoryheader', |
|
|
@ -72,7 +77,6 @@ export default defineComponent({ |
|
|
|
default: () => { |
|
|
|
const { renderMenuTitle } = useRenderMenuTitle() |
|
|
|
|
|
|
|
|
|
|
|
{/* default: () => renderMenuTitle(onlyOneChild ? onlyOneChild?.meta : meta) */} |
|
|
|
return categoryRouters.map((v) => { |
|
|
|
const meta = (v.meta ?? {}) as RouteMeta |
|
|
@ -80,13 +84,9 @@ export default defineComponent({ |
|
|
|
const fullPath = isUrl(v.path) ? v.path : pathResolve('/', v.path) |
|
|
|
return ( |
|
|
|
<ElMenuItem index={fullPath} class={{ |
|
|
|
'is-active': appStore.getCategoryRoutePath === fullPath |
|
|
|
|
|
|
|
}} onClick={()=>{ |
|
|
|
refresh.value = false; |
|
|
|
appStore.setCategoryRoutePath(v.path) |
|
|
|
nextTick(()=>{ |
|
|
|
refresh.value = true |
|
|
|
}) |
|
|
|
}}> |
|
|
|
{{ |
|
|
|
default: () => renderMenuTitle(meta.title?meta:onlyOneChild?.meta) |
|
|
|