refactor: 优化代码逻辑

This commit is contained in:
hooray
2022-10-13 14:15:23 +08:00
parent c0881951d3
commit c2e9b16917
+4 -9
View File
@@ -190,15 +190,10 @@ const useMenuStore = defineStore(
}
else {
// 如果是 string 类型,则认为是路由,需要查找对应的主导航索引
this.allMenus.forEach((item, index) => {
if (
item.children.some((r) => {
return data.indexOf(`${r.path}/`) === 0 || data === r.path
})
) {
this.actived = index
}
})
const findIndex = this.allMenus.findIndex(item => item.children.some(r => data.indexOf(`${r.path}/`) === 0 || data === r.path))
if (findIndex >= 0) {
this.actived = findIndex
}
}
},
},