refactor: 优化路由组件解析逻辑,更新字典数据注释及注册组件样式
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// 递归处理子路由
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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}】字典数据` },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user