Skip to content

Commit e983de6

Browse files
committed
menuStore.menus 转为内部使用,外部统一使用 menuStore.allMenus
1 parent 5b85bdd commit e983de6

File tree

2 files changed

+6
-39
lines changed

2 files changed

+6
-39
lines changed

src/layouts/components/Search/index.vue

+6-38
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import type { OverlayScrollbarsComponentRef } from 'overlayscrollbars-vue'
44
import { OverlayScrollbarsComponent } from 'overlayscrollbars-vue'
55
import { cloneDeep } from 'lodash-es'
66
import hotkeys from 'hotkeys-js'
7-
import type { RouteRecordRaw } from 'vue-router'
87
import Breadcrumb from '../Breadcrumb/index.vue'
98
import BreadcrumbItem from '../Breadcrumb/item.vue'
109
import { resolveRoutePath } from '@/utils'
1110
import eventBus from '@/utils/eventBus'
1211
import useSettingsStore from '@/store/modules/settings'
13-
import useRouteStore from '@/store/modules/route'
1412
import useMenuStore from '@/store/modules/menu'
1513
import type { Menu } from '@/types/global'
1614
@@ -40,7 +38,6 @@ const transitionClass = computed(() => {
4038
4139
const router = useRouter()
4240
const settingsStore = useSettingsStore()
43-
const routeStore = useRouteStore()
4441
const menuStore = useMenuStore()
4542
4643
interface listTypes {
@@ -149,34 +146,27 @@ onMounted(() => {
149146
150147
function initSourceList() {
151148
sourceList.value = []
152-
if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
153-
routeStore.routes.forEach((item) => {
154-
item.children && getSourceList(item.children as RouteRecordRaw[])
155-
})
156-
}
157-
else {
158-
menuStore.menus.forEach((item) => {
159-
getSourceListByMenus(item.children)
160-
})
161-
}
149+
menuStore.allMenus.forEach((item) => {
150+
getSourceListByMenus(item.children)
151+
})
162152
}
163153
164-
function hasChildren(item: RouteRecordRaw) {
154+
function hasChildren(item: Menu.recordRaw) {
165155
let flag = true
166156
if (item.children?.every(i => i.meta?.menu === false)) {
167157
flag = false
168158
}
169159
return flag
170160
}
171-
function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
161+
function getSourceListByMenus(arr: Menu.recordRaw[], basePath?: string, icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
172162
arr.forEach((item) => {
173163
if (item.meta?.menu !== false) {
174164
const breadcrumbTemp = cloneDeep(breadcrumb) || []
175165
if (item.children && hasChildren(item)) {
176166
breadcrumbTemp.push({
177167
title: item.meta?.title,
178168
})
179-
getSourceList(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp)
169+
getSourceListByMenus(item.children, resolveRoutePath(basePath, item.path), item.meta?.icon ?? icon, breadcrumbTemp)
180170
}
181171
else {
182172
breadcrumbTemp.push({
@@ -193,28 +183,6 @@ function getSourceList(arr: RouteRecordRaw[], basePath?: string, icon?: string,
193183
}
194184
})
195185
}
196-
function getSourceListByMenus(arr: Menu.recordRaw[], icon?: string, breadcrumb?: { title?: string | (() => string) }[]) {
197-
arr.forEach((item) => {
198-
const breadcrumbTemp = cloneDeep(breadcrumb) || []
199-
if (item.children && item.children.length > 0) {
200-
breadcrumbTemp.push({
201-
title: item.meta?.title,
202-
})
203-
getSourceListByMenus(item.children, item.meta?.icon ?? icon, breadcrumbTemp)
204-
}
205-
else {
206-
breadcrumbTemp.push({
207-
title: item.meta?.title,
208-
})
209-
sourceList.value.push({
210-
icon: item.meta?.icon ?? icon,
211-
title: item.meta?.title,
212-
path: item.path as string,
213-
breadcrumb: breadcrumbTemp,
214-
})
215-
}
216-
})
217-
}
218186
219187
function keyUp() {
220188
if (resultList.value.length) {

src/store/modules/menu.ts

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ const useMenuStore = defineStore(
192192
}
193193

194194
return {
195-
menus,
196195
actived,
197196
allMenus,
198197
sidebarMenus,

0 commit comments

Comments
 (0)