mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 05:10:57 +00:00
feat: 优化工作台页面样式和快速开始功能
This commit is contained in:
@@ -236,6 +236,7 @@ const extractAffixTags = (routes: RouteRecordRaw[], basePath = "/"): TagView[] =
|
||||
fullPath,
|
||||
name: String(route.name || ""),
|
||||
title: route.meta.title || "no-name",
|
||||
icon: (route as any).icon || route.meta?.icon,
|
||||
affix: true,
|
||||
keepAlive: route.meta.keepAlive || false,
|
||||
});
|
||||
@@ -271,6 +272,7 @@ const initAffixTags = () => {
|
||||
const addCurrentTag = () => {
|
||||
if (!route.meta?.title) return;
|
||||
|
||||
|
||||
// 检查标签是否已存在
|
||||
const existingTag = visitedViews.value.find(tag => tag.path === route.path);
|
||||
|
||||
@@ -292,12 +294,14 @@ const addCurrentTag = () => {
|
||||
title: route.meta.title,
|
||||
path: route.path,
|
||||
fullPath: route.fullPath,
|
||||
icon: (route as any).icon || route.meta?.icon,
|
||||
affix: route.meta.affix || false,
|
||||
keepAlive: route.meta.keepAlive || false,
|
||||
query: route.query,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 检查是否需要自动滚动到最新标签
|
||||
nextTick(() => {
|
||||
autoScrollToLatestTag();
|
||||
@@ -317,6 +321,7 @@ const updateCurrentTag = () => {
|
||||
title: route.meta?.title || "",
|
||||
path: route.path,
|
||||
fullPath: route.fullPath,
|
||||
icon: (route as any).icon || route.meta?.icon,
|
||||
affix: route.meta?.affix || false,
|
||||
keepAlive: route.meta?.keepAlive || false,
|
||||
query: route.query,
|
||||
|
||||
@@ -30,6 +30,7 @@ export const useTagsViewStore = defineStore("tagsView", () => {
|
||||
* 添加缓存视图到缓存视图列表中
|
||||
*/
|
||||
function addCachedView(view: TagView) {
|
||||
console.log("view",view)
|
||||
const viewName = view.name;
|
||||
// 如果缓存视图名称已经存在于缓存视图列表中,则不再添加
|
||||
if (cachedViews.value.includes(viewName)) {
|
||||
@@ -39,6 +40,7 @@ export const useTagsViewStore = defineStore("tagsView", () => {
|
||||
// 如果视图需要缓存(keepAlive),则将其路由名称添加到缓存视图列表中
|
||||
if (view.keepAlive) {
|
||||
cachedViews.value.push(viewName);
|
||||
console.log("cachedViews",cachedViews.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,72 +105,27 @@ class QuickStartManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 从路由信息创建快速链接
|
||||
// 从路由或菜单信息创建快速链接
|
||||
createQuickLinkFromRoute(route: any, customTitle?: string, customDescription?: string): QuickLink {
|
||||
// 优先使用路由配置的图标
|
||||
let routeIcon = route.meta?.icon;
|
||||
let routeColor = '#409EFF'; // 默认颜色
|
||||
|
||||
// 如果路由没有配置图标,根据路径推断
|
||||
if (!routeIcon) {
|
||||
const iconMap: Record<string, { icon: string; color: string }> = {
|
||||
'/dashboard/workplace': { icon: 'House', color: '#409EFF' },
|
||||
'/dashboard/analysis': { icon: 'TrendCharts', color: '#67C23A' },
|
||||
'/dashboard': { icon: 'House', color: '#409EFF' },
|
||||
'/system/user': { icon: 'User', color: '#409EFF' },
|
||||
'/system/role': { icon: 'UserFilled', color: '#E6A23C' },
|
||||
'/system/menu': { icon: 'Menu', color: '#F56C6C' },
|
||||
'/system/dept': { icon: 'OfficeBuilding', color: '#909399' },
|
||||
'/system/position': { icon: 'Briefcase', color: '#606266' },
|
||||
'/system/dict': { icon: 'Collection', color: '#FF6B6B' },
|
||||
'/system/config': { icon: 'Setting', color: '#67C23A' },
|
||||
'/system/notice': { icon: 'Bell', color: '#E6A23C' },
|
||||
'/system/log': { icon: 'Document', color: '#FF6B6B' },
|
||||
'/system': { icon: 'Setting', color: '#67C23A' },
|
||||
'/monitor/server': { icon: 'Monitor', color: '#606266' },
|
||||
'/monitor/cache': { icon: 'Coin', color: '#F56C6C' },
|
||||
'/monitor/job': { icon: 'Timer', color: '#909399' },
|
||||
'/monitor/online': { icon: 'Connection', color: '#67C23A' },
|
||||
'/monitor': { icon: 'Monitor', color: '#606266' },
|
||||
'/codegen': { icon: 'Code', color: '#4ECDC4' },
|
||||
'/demo': { icon: 'DataAnalysis', color: '#3385FF' },
|
||||
'/profile': { icon: 'User', color: '#409EFF' },
|
||||
};
|
||||
|
||||
// 查找最匹配的路径配置
|
||||
let bestMatch = { icon: 'Link', color: '#909399' }; // 默认配置
|
||||
let maxMatchLength = 0;
|
||||
|
||||
for (const [path, config] of Object.entries(iconMap)) {
|
||||
if (route.path.startsWith(path) && path.length > maxMatchLength) {
|
||||
bestMatch = config;
|
||||
maxMatchLength = path.length;
|
||||
}
|
||||
}
|
||||
|
||||
routeIcon = bestMatch.icon;
|
||||
routeColor = bestMatch.color;
|
||||
} else {
|
||||
// 如果有路由图标,尝试获取对应的颜色
|
||||
const colorMap: Record<string, string> = {
|
||||
'house': '#409EFF',
|
||||
'user': '#409EFF',
|
||||
'setting': '#67C23A',
|
||||
'monitor': '#606266',
|
||||
'document': '#FF6B6B',
|
||||
'bell': '#E6A23C',
|
||||
'menu': '#F56C6C',
|
||||
'office-building': '#909399',
|
||||
'data-analysis': '#3385FF',
|
||||
'trend-charts': '#67C23A',
|
||||
};
|
||||
|
||||
routeColor = colorMap[routeIcon.toLowerCase()] || '#409EFF';
|
||||
// 优先使用路由对象上的icon字段,如果没有则使用默认图标
|
||||
let routeIcon = route.icon || 'Link';
|
||||
|
||||
// 处理Element Plus图标名称,转换为组件名称
|
||||
if (routeIcon.startsWith('el-icon-')) {
|
||||
// 将 el-icon-Odometer 转换为 Odometer
|
||||
routeIcon = routeIcon.replace('el-icon-', '');
|
||||
// 首字母大写
|
||||
routeIcon = routeIcon.charAt(0).toUpperCase() + routeIcon.slice(1);
|
||||
}
|
||||
|
||||
console.log("routeIcon",routeIcon)
|
||||
|
||||
// 确定最终使用的标题 - 优先使用route.title
|
||||
const finalTitle = customTitle || route.title || route.name || '未命名页面';
|
||||
|
||||
return {
|
||||
title: customTitle || route.meta?.title || route.name || '未命名页面',
|
||||
description: customDescription || `快速访问 ${route.meta?.title || route.name || '页面'}`,
|
||||
title: finalTitle,
|
||||
description: customDescription || `快速访问 ${route.title || route.name || '页面'}`,
|
||||
icon: routeIcon,
|
||||
href: route.fullPath || route.path,
|
||||
action: 'navigate',
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
<div class="text-20px font-bold">
|
||||
{{ timefix }}{{ currentUser.name }},{{ welcome }}
|
||||
</div>
|
||||
<el-text class="text-[var(--el-text-color-regular)]">
|
||||
<el-text>
|
||||
{{ currentUser.username }} | {{ currentUser.dept_name }} | {{ currentUser.description }}
|
||||
</el-text>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 最近登录时间 -->
|
||||
<div class="statItem text-14px text-[var(--el-text-color-regular)] text-right">
|
||||
<div class="statItem text-14px text-gray-600 text-right">
|
||||
<el-text>最近登录时间</el-text>
|
||||
<div class="mt-5px text-20px">{{ currentUser.last_login }}</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user