多余代码删除

main
xiangcongshuai 3 days ago
parent 814bdf1aa8
commit 7184f4c2ae

@ -74,21 +74,5 @@ export default [
children: []
}
]
},
{
path: "/redirect",
component: Layout,
meta: {
title: "加载中...",
showLink: false,
rank: 102
},
children: [
{
path: "/redirect/:path(.*)",
name: "Redirect",
component: () => import("@/layout/redirect.vue")
}
]
}
] as Array<RouteConfigsTable>;

@ -22,7 +22,6 @@ import { buildHierarchyTree } from "@/utils/tree";
import { sessionKey, type DataInfo } from "@/utils/auth";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { usePermissionStoreHook } from "@/store/modules/permission";
const IFrame = () => import("@/layout/frameView.vue");
// https://cn.vitejs.dev/guide/features.html#glob-import
const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
@ -150,36 +149,7 @@ function addPathMatch() {
}
/** 处理动态路由(后端返回的路由) */
function handleAsyncRoutes(routeList) {
if (routeList.length === 0) {
usePermissionStoreHook().handleWholeMenus(routeList);
} else {
formatFlatteningRoutes(addAsyncRoutes(routeList)).map(
(v: RouteRecordRaw) => {
// 防止重复添加路由
if (
router.options.routes[0].children?.findIndex(
value => value.path === v.path
) !== -1
) {
return;
} else {
// 切记将路由push到routes后还需要使用addRoute这样路由才能正常跳转
router.options.routes[0].children.push(v);
// 最终路由进行升序
ascending(router.options.routes[0].children);
if (!router.hasRoute(v?.name)) router.addRoute(v);
const flattenRouters: any = router
.getRoutes()
.find(n => n.path === "/");
router.addRoute(flattenRouters);
}
}
);
usePermissionStoreHook().handleWholeMenus(routeList);
}
addPathMatch();
}
function handleAsyncRoutes(routeList) {}
/** 初始化路由(`new Promise` 写法防止在异步请求中造成无限循环)*/
function initRouter() {
@ -294,28 +264,7 @@ function handleAliveRoute({ name }: ToRouteType, mode?: string) {
function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
if (!arrRoutes || !arrRoutes.length) return;
const modulesRoutesKeys = Object.keys(modulesRoutes);
arrRoutes.forEach((v: RouteRecordRaw) => {
// 将backstage属性加入meta标识此路由为后端返回路由
v.meta.backstage = true;
// 父级的redirect属性取值如果子级存在且父级的redirect属性不存在默认取第一个子级的path如果子级存在且父级的redirect属性存在取存在的redirect属性会覆盖默认值
if (v?.children && v.children.length && !v.redirect)
v.redirect = v.children[0].path;
// 父级的name属性取值如果子级存在且父级的name属性不存在默认取第一个子级的name如果子级存在且父级的name属性存在取存在的name属性会覆盖默认值注意测试中发现父级的name不能和子级name重复如果重复会造成重定向无效跳转404所以这里给父级的name起名的时候后面会自动加上`Parent`,避免重复)
if (v?.children && v.children.length && !v.name)
v.name = (v.children[0].name as string) + "Parent";
if (v.meta?.frameSrc) {
v.component = IFrame;
} else {
// 对后端传component组件路径和不传做兼容如果后端传component组件路径那么path可以随便写如果不传component组件路径会跟path保持一致
const index = v?.component
? modulesRoutesKeys.findIndex(ev => ev.includes(v.component as any))
: modulesRoutesKeys.findIndex(ev => ev.includes(v.path));
v.component = modulesRoutes[modulesRoutesKeys[index]];
}
if (v?.children && v.children.length) {
addAsyncRoutes(v.children);
}
});
arrRoutes.forEach((v: RouteRecordRaw) => {});
return arrRoutes;
}

@ -5,6 +5,12 @@ import editImg from "@/assets/live/edit.png";
const router = useRouter();
const liveName = ref("慧文的直播间");
const sidebarList = ref([
{ name: "直播商品" },
{ name: "互动脚本" },
{ name: "基础设置" }
]);
</script>
<template>
@ -22,6 +28,17 @@ const liveName = ref("慧文的直播间");
<el-button type="primary">进入直播间</el-button>
</div>
</div>
<div class="ai-content">
<div class="sidebar">
<div
v-for="(item, index) in sidebarList"
:key="index"
class="sidebar-item"
>
<span>{{ item.name }}</span>
</div>
</div>
</div>
</div>
</template>

@ -1,8 +1,5 @@
<script setup lang="ts">
import { useLayout } from "@/layout/hooks/useLayout";
import { message } from "@/utils/message";
import type { FormInstance } from "element-plus";
import { initRouter } from "@/router/utils";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { getLogin } from "@/api/user";
import { reactive, ref, nextTick, onMounted } from "vue";

Loading…
Cancel
Save