From e983de6acfb311ce5508f4474fcfe574c4725f86 Mon Sep 17 00:00:00 2001 From: Hooray Hu <304327508@qq.com> Date: Thu, 28 Mar 2024 13:48:20 +0800 Subject: [PATCH] =?UTF-8?q?`menuStore.menus`=20=E8=BD=AC=E4=B8=BA=E5=86=85?= =?UTF-8?q?=E9=83=A8=E4=BD=BF=E7=94=A8=EF=BC=8C=E5=A4=96=E9=83=A8=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BD=BF=E7=94=A8=20`menuStore.allMenus`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/components/Search/index.vue | 44 ++++--------------------- src/store/modules/menu.ts | 1 - 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/src/layouts/components/Search/index.vue b/src/layouts/components/Search/index.vue index f491a9a8c..2e96ab846 100755 --- a/src/layouts/components/Search/index.vue +++ b/src/layouts/components/Search/index.vue @@ -4,13 +4,11 @@ import type { OverlayScrollbarsComponentRef } from 'overlayscrollbars-vue' import { OverlayScrollbarsComponent } from 'overlayscrollbars-vue' import { cloneDeep } from 'lodash-es' import hotkeys from 'hotkeys-js' -import type { RouteRecordRaw } from 'vue-router' import Breadcrumb from '../Breadcrumb/index.vue' import BreadcrumbItem from '../Breadcrumb/item.vue' import { resolveRoutePath } from '@/utils' import eventBus from '@/utils/eventBus' import useSettingsStore from '@/store/modules/settings' -import useRouteStore from '@/store/modules/route' import useMenuStore from '@/store/modules/menu' import type { Menu } from '@/types/global' @@ -40,7 +38,6 @@ const transitionClass = computed(() => { const router = useRouter() const settingsStore = useSettingsStore() -const routeStore = useRouteStore() const menuStore = useMenuStore() interface listTypes { @@ -149,26 +146,19 @@ onMounted(() => { function initSourceList() { sourceList.value = [] - if (settingsStore.settings.app.routeBaseOn !== 'filesystem') { - routeStore.routes.forEach((item) => { - item.children && getSourceList(item.children as RouteRecordRaw[]) - }) - } - else { - menuStore.menus.forEach((item) => { - getSourceListByMenus(item.children) - }) - } + menuStore.allMenus.forEach((item) => { + getSourceListByMenus(item.children) + }) } -function hasChildren(item: RouteRecordRaw) { +function hasChildren(item: Menu.recordRaw) { let flag = true if (item.children?.every(i => i.meta?.menu === false)) { flag = false } return flag } -function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) { +function getSourceListByMenus(arr: Menu.recordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) { arr.forEach((item) => { if (item.meta?.menu !== false) { const breadcrumbTemp = cloneDeep(breadcrumb) || [] @@ -176,7 +166,7 @@ function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, breadcrumbTemp.push({ title: item.meta?.title, }) - getSourceList(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp) + getSourceListByMenus(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp) } else { breadcrumbTemp.push({ @@ -193,28 +183,6 @@ function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, } }) } -function getSourceListByMenus(arr: Menu.recordRaw[], icon?: string, breadcrumb?: { title?: string | (() => string) }[]) { - arr.forEach((item) => { - const breadcrumbTemp = cloneDeep(breadcrumb) || [] - if (item.children && item.children.length > 0) { - breadcrumbTemp.push({ - title: item.meta?.title, - }) - getSourceListByMenus(item.children, item.meta?.icon ?? icon, breadcrumbTemp) - } - else { - breadcrumbTemp.push({ - title: item.meta?.title, - }) - sourceList.value.push({ - icon: item.meta?.icon ?? icon, - title: item.meta?.title, - path: item.path as string, - breadcrumb: breadcrumbTemp, - }) - } - }) -} function keyUp() { if (resultList.value.length) { diff --git a/src/store/modules/menu.ts b/src/store/modules/menu.ts index ac633a74e..0727e36f7 100755 --- a/src/store/modules/menu.ts +++ b/src/store/modules/menu.ts @@ -192,7 +192,6 @@ const useMenuStore = defineStore( } return { - menus, actived, allMenus, sidebarMenus,