refactor: 优化路由组件解析逻辑,更新字典数据注释及注册组件样式
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-config-provider :locale="locale" :size="size">
|
<el-config-provider :locale="locale" :size="size">
|
||||||
<!-- å¼€å<EFBFBD>¯æ°´å<EFBFBD>?-->
|
<!-- 开启水印-->
|
||||||
<el-watermark
|
<el-watermark
|
||||||
:font="{ color: fontColor }"
|
:font="{ color: fontColor }"
|
||||||
:content="showWatermark ? watermarkContent : ''"
|
:content="showWatermark ? watermarkContent : ''"
|
||||||
@@ -30,8 +30,8 @@ const size = computed(() => appStore.size as ComponentSize);
|
|||||||
const showWatermark = computed(() => settingsStore.showWatermark);
|
const showWatermark = computed(() => settingsStore.showWatermark);
|
||||||
const watermarkContent = appConfig.name;
|
const watermarkContent = appConfig.name;
|
||||||
|
|
||||||
// å<EFBFBD>ªæœ‰åœ¨å<EFBFBD>¯ç”?AI 助手且用户已登录时æ‰<C3A6>显示
|
// 只有在启<EFBFBD>?AI 助手且用户已登录时才显示
|
||||||
// 使用 userInfo 作为å“<EFBFBD>应å¼<EFBFBD>ä¾<EFBFBD>赖,当用户退出登录时会自动更æ–?
|
// 使用 userInfo 作为响应式依赖,当用户退出登录时会自动更<EFBFBD>?
|
||||||
const enableAiAssistant = computed(() => {
|
const enableAiAssistant = computed(() => {
|
||||||
const isEnabled = settingsStore.enableAiAssistant;
|
const isEnabled = settingsStore.enableAiAssistant;
|
||||||
const isLoggedIn = userStore.userInfo && Object.keys(userStore.userInfo).length > 0;
|
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 modules = import.meta.glob("../../views/**/**.vue");
|
||||||
const Layout = () => import("../../layouts/index.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", () => {
|
export const usePermissionStore = defineStore("permission", () => {
|
||||||
// 所有路由(静态路由 + 动态路由)
|
// 所有路由(静态路由 + 动态路由)
|
||||||
const routes = ref<RouteRecordRaw[]>([]);
|
const routes = ref<RouteRecordRaw[]>([]);
|
||||||
@@ -84,10 +96,7 @@ const transformRoutes = (routes: RouteItem[], isTopLevel: boolean = true): Route
|
|||||||
} else {
|
} else {
|
||||||
// 动态导入组件,Layout特殊处理,找不到组件时返回404
|
// 动态导入组件,Layout特殊处理,找不到组件时返回404
|
||||||
normalizedRoute.component =
|
normalizedRoute.component =
|
||||||
processedComponent === "Layout"
|
processedComponent === "Layout" ? Layout : resolveViewComponent(processedComponent);
|
||||||
? Layout
|
|
||||||
: modules[`../../views/${processedComponent}.vue`] ||
|
|
||||||
modules[`../../views/error/404.vue`];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 递归处理子路由
|
// 递归处理子路由
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
border-rd-4px
|
border-rd-4px
|
||||||
w-full
|
w-full
|
||||||
h-full
|
h-full
|
||||||
|
block
|
||||||
object-contain
|
object-contain
|
||||||
shadow="[0_0_0_1px_var(--el-border-color)_inset]"
|
shadow="[0_0_0_1px_var(--el-border-color)_inset]"
|
||||||
:src="captchaBase64"
|
:src="captchaBase64"
|
||||||
|
|||||||
@@ -286,10 +286,10 @@ function handleDelete(id?: number) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开字典值"
|
// 打开字典数据
|
||||||
function handleOpenDictData(row: DictTypeItem) {
|
function handleOpenDictData(row: DictTypeItem) {
|
||||||
router.push({
|
router.push({
|
||||||
path: "/system/dict-item",
|
name: "DictItem",
|
||||||
query: { dictCode: row.dictCode, title: `【${row.name}】字典数据` },
|
query: { dictCode: row.dictCode, title: `【${row.name}】字典数据` },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user