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