From acfb1afdba794459a6c71266096125ae68ae214b Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Tue, 30 Sep 2025 01:04:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(dashboard):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0=E9=A1=B5=E9=9D=A2=E5=B9=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=BF=AB=E9=80=9F=E5=BC=80=E5=A7=8B=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(lang): 添加清除按钮的翻译文本 fix(tags-view): 移除调试日志输出 refactor(quick-start): 简化快速链接数据结构并添加清空功能 --- frontend/src/lang/package/en.ts | 1 + frontend/src/lang/package/zh-cn.ts | 1 + frontend/src/store/modules/tags-view.store.ts | 1 - frontend/src/utils/quickStartManager.ts | 61 +--- .../components/AddQuickLinkDialog.vue | 232 -------------- .../views/dashboard/components/QuickStart.vue | 298 ------------------ .../src/views/dashboard/components/index.ts | 2 - frontend/src/views/dashboard/workplace.vue | 231 ++++++++++---- 8 files changed, 179 insertions(+), 648 deletions(-) delete mode 100644 frontend/src/views/dashboard/components/AddQuickLinkDialog.vue delete mode 100644 frontend/src/views/dashboard/components/QuickStart.vue delete mode 100644 frontend/src/views/dashboard/components/index.ts diff --git a/frontend/src/lang/package/en.ts b/frontend/src/lang/package/en.ts index e66e1354..a3e5585b 100644 --- a/frontend/src/lang/package/en.ts +++ b/frontend/src/lang/package/en.ts @@ -8,6 +8,7 @@ export default { edit: "Edit", delete: "Delete", add: "Add", + clear: "Clear", export: "Export", import: "Import", query: "Query", diff --git a/frontend/src/lang/package/zh-cn.ts b/frontend/src/lang/package/zh-cn.ts index e4acb307..27eacf10 100644 --- a/frontend/src/lang/package/zh-cn.ts +++ b/frontend/src/lang/package/zh-cn.ts @@ -8,6 +8,7 @@ export default { edit: "编辑", delete: "删除", add: "添加", + clear: "清除", export: "导出", import: "导入", query: "查询", diff --git a/frontend/src/store/modules/tags-view.store.ts b/frontend/src/store/modules/tags-view.store.ts index 7768f06d..1054f2c0 100644 --- a/frontend/src/store/modules/tags-view.store.ts +++ b/frontend/src/store/modules/tags-view.store.ts @@ -39,7 +39,6 @@ export const useTagsViewStore = defineStore("tagsView", () => { // 如果视图需要缓存(keepAlive),则将其路由名称添加到缓存视图列表中 if (view.keepAlive) { cachedViews.value.push(viewName); - console.log("cachedViews",cachedViews.value) } } diff --git a/frontend/src/utils/quickStartManager.ts b/frontend/src/utils/quickStartManager.ts index 85c1ce86..c586360b 100644 --- a/frontend/src/utils/quickStartManager.ts +++ b/frontend/src/utils/quickStartManager.ts @@ -3,10 +3,8 @@ import { ElMessage } from 'element-plus'; // 快速链接数据类型 export interface QuickLink { title: string; - description: string; icon: string; href: string; - action: 'navigate' | 'external'; id?: string; } @@ -28,40 +26,7 @@ class QuickStartManager { // 获取默认链接 private getDefaultLinks(): QuickLink[] { - return [ - { - id: 'user-management', - title: "用户管理", - description: "管理系统用户信息", - icon: "User", - href: "/system/user", - action: "navigate" - }, - { - id: 'monitor', - title: "系统监控", - description: "监控系统状态", - icon: "Monitor", - href: "/monitor", - action: "navigate" - }, - { - id: 'baidu', - title: "百度搜索", - description: "访问百度搜索引擎", - icon: "Search", - href: "https://www.baidu.com", - action: "external" - }, - { - id: 'github', - title: "GitHub", - description: "访问代码托管平台", - icon: "Monitor", - href: "https://github.com", - action: "external" - } - ]; + return []; } // 保存快速链接 @@ -78,9 +43,6 @@ class QuickStartManager { addQuickLink(link: QuickLink): void { const links = this.getQuickLinks(); - // 生成唯一ID - link.id = link.id || `link-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; - // 检查是否已存在相同路径的链接 const existingIndex = links.findIndex(l => l.href === link.href); if (existingIndex !== -1) { @@ -105,28 +67,19 @@ class QuickStartManager { } } + // 清空所有快速链接 + clearQuickLinks(): void { + this.saveQuickLinks([]); + } // 从路由或菜单信息创建快速链接 - createQuickLinkFromRoute(route: any, customTitle?: string, customDescription?: string): QuickLink { - // 优先使用路由对象上的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); - } - + createQuickLinkFromRoute(route: any, customTitle?: string): QuickLink { // 确定最终使用的标题 - 优先使用route.title const finalTitle = customTitle || route.title || route.name || '未命名页面'; return { title: finalTitle, - description: customDescription || `快速访问 ${route.title || route.name || '页面'}`, - icon: routeIcon, + icon: route.icon, href: route.fullPath || route.path, - action: 'navigate', id: `route-${route.path.replace(/\//g, '-')}-${Date.now()}` }; } diff --git a/frontend/src/views/dashboard/components/AddQuickLinkDialog.vue b/frontend/src/views/dashboard/components/AddQuickLinkDialog.vue deleted file mode 100644 index efc44784..00000000 --- a/frontend/src/views/dashboard/components/AddQuickLinkDialog.vue +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - - - - - - - - - - - 内部链接 - 外部链接 - - - - - - - - - - - - - - - 取消 - 确定 - - - - - - - - diff --git a/frontend/src/views/dashboard/components/QuickStart.vue b/frontend/src/views/dashboard/components/QuickStart.vue deleted file mode 100644 index 3f299f68..00000000 --- a/frontend/src/views/dashboard/components/QuickStart.vue +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - - - - - - 快速开始 / 便捷导航 - - - - - - {{ t('common.add') }} - - - - - - - - onContextMenuChange(visible, item)" - > - - - - - - - - - {{ item.title }} - 外链 - - - - - - - - - - - 编辑链接 - - - - - - 删除链接 - - - - - - - - - - - - - - - - diff --git a/frontend/src/views/dashboard/components/index.ts b/frontend/src/views/dashboard/components/index.ts deleted file mode 100644 index f7e9f364..00000000 --- a/frontend/src/views/dashboard/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as QuickStart } from './QuickStart.vue'; -export { default as AddQuickLinkDialog } from './AddQuickLinkDialog.vue'; diff --git a/frontend/src/views/dashboard/workplace.vue b/frontend/src/views/dashboard/workplace.vue index b4f98c8c..c38822ef 100644 --- a/frontend/src/views/dashboard/workplace.vue +++ b/frontend/src/views/dashboard/workplace.vue @@ -33,7 +33,8 @@ 进行中的项目 全部项目 - + + @@ -61,58 +62,108 @@ - - - - - 通知公告 - 更多 - - - - - - - - {{ item.notice_title }} - - {{ getNoticeTypeText(item.notice_type) }} - - - {{ formatTime(item.created_at) }} - - {{ item.notice_content }} - - {{ item.creator?.name }} 发布 - - 详情↗ - - - - - - + + + + + 通知公告 + 更多 + + + + + + + + + {{ item.notice_title }} + + {{ getNoticeTypeText(item.notice_type) }} + + + {{ formatTime(item.created_at) }} + + {{ item.notice_content }} + + {{ item.creator?.name }} 发布 + + 详情↗ + + + + + + - - - - 团队 - - - - - - {{ item.member }} - - - - + + + + 团队 + + + + + + + {{ item.member }} + + + + - + + + + + + + + + + 快速开始 / 便捷导航 + + + + + + {{ t('common.clear') }} + + + + + + + + + + + + + {{ item.title }} + + + + + + + + @@ -128,16 +179,25 @@ import { EChartsOption } from 'echarts' import { useUserStore } from "@/store/index"; import { greetings } from '@/utils/common'; -import QuickStart from './components/QuickStart.vue'; import NoticeAPI, { NoticeTable } from '@/api/system/notice'; -import { ref, onMounted } from 'vue'; +import { ref, onMounted, reactive } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRouter } from 'vue-router'; +import { QuestionFilled, Close, CircleCloseFilled } from "@element-plus/icons-vue"; +import { ElMessage, ElMessageBox } from 'element-plus'; +import { quickStartManager, type QuickLink } from '@/utils/quickStartManager'; const userStore = useUserStore(); const timefix = greetings(); +const { t } = useI18n(); +const router = useRouter(); // 通知公告数据 const noticeList = ref([]); +// 快速链接数据 +const quickLinks = ref(quickStartManager.getQuickLinks()); + // 格式化时间 const formatTime = (time: string | undefined) => { if (!time) return ''; @@ -195,9 +255,68 @@ const getNoticeList = async () => { } }; -// 组件挂载时获取数据 +// 处理快速链接点击 +const handleQuickLinkClick = (item: QuickLink) => { + if (item.href) { + // 内部路由跳转 + router.push(item.href).catch(() => { + ElMessage.warning(`路由 ${item.href} 不存在,请检查配置`); + }); + ElMessage.success(`进入:${item.title}`); + } else { + ElMessage.info(`${item.title} 功能待开发`); + } +}; + +// 处理删除链接 +const handleDeleteLink = (item: QuickLink) => { + ElMessageBox.confirm( + `确定要取消收藏"${item.title}"吗?`, + '取消收藏确认', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ).then(() => { + if (item.id) { + quickStartManager.removeQuickLink(item.id); + ElMessage.success(`已取消收藏:${item.title}`); + } + }).catch(() => { + // 用户取消删除 + }); +}; + +const clearBookmarks = () => { + ElMessageBox.confirm( + '确定要清空收藏吗?', + '清空收藏确认', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ).then(() => { + quickStartManager.clearQuickLinks(); + ElMessage.success('已清空收藏'); + }).catch(() => {}) +} + +// 监听快速链接变化 +const updateQuickLinks = (links: QuickLink[]) => { + quickLinks.value = links; +}; + +// 组件挂载时获取数据和添加监听器 onMounted(() => { getNoticeList(); + quickStartManager.addListener(updateQuickLinks); +}); + +// 组件卸载时移除监听器 +onUnmounted(() => { + quickStartManager.removeListener(updateQuickLinks); }); defineOptions({ @@ -279,7 +398,6 @@ const projectNotice = [ ]; - const chartOptions = reactive({ tooltip: { trigger: 'item' }, legend: { data: ['个人', '团队', '部门'] }, @@ -307,18 +425,9 @@ const chartOptions = reactive({ }] }); - -