refactor: 优化路由组件解析逻辑,更新字典数据注释及注册组件样式

This commit is contained in:
Ray.Hao
2026-01-09 23:08:53 +08:00
parent 6d88b5ee07
commit ca15fa0322
4 changed files with 19 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
<template>
<el-config-provider :locale="locale" :size="size">
<!-- å¼å<EFBFBD>¯æ°´å<EFBFBD>?-->
<!-- 开启水印-->
<el-watermark
:font="{ color: fontColor }"
:content="showWatermark ? watermarkContent : ''"
@@ -30,8 +30,8 @@ const size = computed(() => appStore.size as ComponentSize);
const showWatermark = computed(() => settingsStore.showWatermark);
const watermarkContent = appConfig.name;
// å<EFBFBD>ªæœ‰åœ¨å<EFBFBD>¯ç”?AI 助æ‰ä¸”用户已登录时æ‰<C3A6>显示
// 使用 userInfo 作为å“<EFBFBD>应å¼<EFBFBD>ä¾<EFBFBD>èµï¼Œå½“ç”¨æˆ·é€€å‡ºç™»å½•æ—¶ä¼šè‡ªåŠ¨æ´æ?
// 只有在启<EFBFBD>?AI 助手且用户已登录时才显示
// 使用 userInfo 作为响应式依赖当用户退出登录时会自动更<EFBFBD>?
const enableAiAssistant = computed(() => {
const isEnabled = settingsStore.enableAiAssistant;
const isLoggedIn = userStore.userInfo && Object.keys(userStore.userInfo).length > 0;

View File

@@ -8,6 +8,18 @@ import { RouteItem } from "@/types";
const modules = import.meta.glob("../../views/**/**.vue");
const Layout = () => import("../../layouts/index.vue");
function resolveViewComponent(componentPath: string) {
const normalized = componentPath
.trim()
.replace(/^\/+/, "")
.replace(/\.vue$/i, "");
return (
modules[`../../views/${normalized}.vue`] ||
modules[`../../views/${normalized}/index.vue`] ||
modules[`../../views/error/404.vue`]
);
}
export const usePermissionStore = defineStore("permission", () => {
// 所有路由(静态路由 + 动态路由)
const routes = ref<RouteRecordRaw[]>([]);
@@ -84,10 +96,7 @@ const transformRoutes = (routes: RouteItem[], isTopLevel: boolean = true): Route
} else {
// 动态导入组件Layout特殊处理找不到组件时返回404
normalizedRoute.component =
processedComponent === "Layout"
? Layout
: modules[`../../views/${processedComponent}.vue`] ||
modules[`../../views/error/404.vue`];
processedComponent === "Layout" ? Layout : resolveViewComponent(processedComponent);
}
// 递归处理子路由

View File

@@ -66,6 +66,7 @@
border-rd-4px
w-full
h-full
block
object-contain
shadow="[0_0_0_1px_var(--el-border-color)_inset]"
:src="captchaBase64"

View File

@@ -286,10 +286,10 @@ function handleDelete(id?: number) {
);
}
// 打开字典值"
// 打开字典数据
function handleOpenDictData(row: DictTypeItem) {
router.push({
path: "/system/dict-item",
name: "DictItem",
query: { dictCode: row.dictCode, title: `${row.name}】字典数据` },
});
}