mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 22:31:21 +00:00
refactor: 移除调试日志并优化代码结构
移除多处console.log和console.error调试日志 优化路由标签页的自动滚动逻辑,确保当前激活标签可见 调整权限检查逻辑,移除重复的权限检查 更新菜单搜索组件,排除更多路由并优化加载逻辑 清理未使用的文件列表相关代码 添加Element Plus组件样式自动导入
This commit is contained in:
@@ -137,7 +137,7 @@ const permissionStore = usePermissionStore();
|
||||
const isModalVisible = ref(false);
|
||||
const searchKeyword = ref("");
|
||||
const searchInputRef = ref();
|
||||
const excludedRoutes = ref(["/redirect", "/login", "/401", "/404"]);
|
||||
const excludedRoutes = ref(["/redirect", "/login", "/401", "/404", "/500", "/:pathMatch(.*)*"]);
|
||||
const menuItems = ref<SearchItem[]>([]);
|
||||
const searchResults = ref<SearchItem[]>([]);
|
||||
const activeIndex = ref(-1);
|
||||
@@ -290,14 +290,35 @@ function navigateToRoute(item: SearchItem) {
|
||||
|
||||
function loadRoutes(routes: RouteRecordRaw[], parentPath = "") {
|
||||
routes.forEach((route) => {
|
||||
// 计算完整路径
|
||||
const path = route.path.startsWith("/")
|
||||
? route.path
|
||||
: `${parentPath}${parentPath.endsWith("/") ? "" : "/"}${route.path}`;
|
||||
if (excludedRoutes.value.includes(route.path) || isExternal(route.path)) return;
|
||||
|
||||
// 检查是否需要排除
|
||||
if (excludedRoutes.value.includes(route.path) || isExternal(route.path) || route.meta?.hidden) return;
|
||||
|
||||
// 处理有子路由的情况
|
||||
if (route.children) {
|
||||
// 如果父路由本身有title,也添加到menuItems中
|
||||
if (route.meta?.title) {
|
||||
const title = route.meta.title === "dashboard" ? "首页" : route.meta.title;
|
||||
menuItems.value.push({
|
||||
title,
|
||||
path,
|
||||
name: typeof route.name === "string" ? route.name : undefined,
|
||||
icon: route.meta.icon,
|
||||
redirect: typeof route.redirect === "string" ? route.redirect : undefined,
|
||||
params: route.meta.params
|
||||
? JSON.parse(JSON.stringify(toRaw(route.meta.params)))
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
// 递归处理子路由
|
||||
loadRoutes(route.children, path);
|
||||
} else if (route.meta?.title) {
|
||||
}
|
||||
// 处理没有子路由但有title的情况
|
||||
else if (route.meta?.title) {
|
||||
const title = route.meta.title === "dashboard" ? "首页" : route.meta.title;
|
||||
menuItems.value.push({
|
||||
title,
|
||||
|
||||
Reference in New Issue
Block a user