refactor: ♻️ 项目重构(临时提交)

Former-commit-id: 14e64324f7556c095c38ad289690367cdac0ec56
This commit is contained in:
郝先瑞
2023-11-16 22:46:28 +08:00
parent c1725e0b09
commit 12c78f96d7
34 changed files with 2129 additions and 399 deletions

View File

@@ -5,7 +5,6 @@
</template>
<script setup lang="ts">
import SvgIcon from "@/components/SvgIcon/index.vue";
import { translateRouteTitle } from "@/utils/i18n";
defineProps({

View File

@@ -2,6 +2,7 @@
import path from "path-browserify";
import { isExternal } from "@/utils/index";
import AppLink from "./Link.vue";
import { RouteRecordRaw } from "vue-router";
import Item from "./Item.vue";
@@ -38,15 +39,19 @@ const onlyOneChild = ref(); // 临时变量,唯一子路由
* @param children 子路由数组
* @param parent 当前路由
*/
function hasOneShowingChild(children = [], parent: any) {
function hasOneShowingChild(
children: RouteRecordRaw[] = [],
parent: RouteRecordRaw
) {
// 子路由集合
const showingChildren = children.filter((item: any) => {
if (item.meta?.hidden) {
const showingChildren = children.filter((route: RouteRecordRaw) => {
if (route.meta?.hidden) {
// 过滤不显示的子路由
return false;
} else {
route.meta!.hidden = false;
// 临时变量(多个子路由 onlyOneChild 变量是用不上的)
onlyOneChild.value = item;
onlyOneChild.value = route;
return true;
}
});
@@ -87,7 +92,7 @@ function resolvePath(routePath: string) {
<!-- 无子路由 || 目录只有一个子路由并配置始终显示为否(alwaysShow=false) -->
<template
v-if="
hasOneShowingChild(item.children, item) &&
hasOneShowingChild(item.children, item as RouteRecordRaw) &&
(!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
!item.meta?.alwaysShow
"

View File

@@ -61,13 +61,6 @@ onMounted(() => {
</template>
</template>
</el-menu-item>
<!-- <sidebar-item
v-for="route in topMenu"
:key="route.path"
:item="route"
:base-path="route.path"
:is-collapse="false"
/> -->
</el-menu>
</el-scrollbar>
</template>