From c617d2943fda57c1e9967459744ff85d7698d183 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Tue, 24 Feb 2026 09:28:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E7=95=8C=E9=9D=A2=E6=A0=B7=E5=BC=8F=E5=92=8C=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/role.ts | 2 +- src/assets/icons/browser.svg | 1 - src/assets/icons/visitor.svg | 1 - src/components/CopyButton/index.vue | 18 +- src/store/modules/tags-view.ts | 4 +- src/styles/variables.scss | 4 +- src/types/api/role.ts | 2 +- src/views/dashboard/index.vue | 245 ++++++++++++++++------------ 8 files changed, 152 insertions(+), 125 deletions(-) delete mode 100644 src/assets/icons/browser.svg delete mode 100644 src/assets/icons/visitor.svg diff --git a/src/api/system/role.ts b/src/api/system/role.ts index f0387d45..55dc0562 100644 --- a/src/api/system/role.ts +++ b/src/api/system/role.ts @@ -30,7 +30,7 @@ const RoleAPI = { }, /** 获取角色的部门ID集合(自定义数据权限) */ getRoleDeptIds(roleId: string) { - return request({ url: `${ROLE_BASE_URL}/${roleId}/dept-ids`, method: "get" }); + return request({ url: `${ROLE_BASE_URL}/${roleId}/dept-ids`, method: "get" }); }, /** 新增角色 */ create(data: RoleForm) { diff --git a/src/assets/icons/browser.svg b/src/assets/icons/browser.svg deleted file mode 100644 index 15c3927c..00000000 --- a/src/assets/icons/browser.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/icons/visitor.svg b/src/assets/icons/visitor.svg deleted file mode 100644 index 1fd8dbe6..00000000 --- a/src/assets/icons/visitor.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/components/CopyButton/index.vue b/src/components/CopyButton/index.vue index 1bd1bb8c..1b0035b4 100644 --- a/src/components/CopyButton/index.vue +++ b/src/components/CopyButton/index.vue @@ -31,9 +31,8 @@ function handleClipboard() { () => { ElMessage.success("Copy successfully"); }, - (error) => { + () => { ElMessage.warning("Copy failed"); - console.log("[CopyButton] Copy failed", error); } ); } else { @@ -44,18 +43,17 @@ function handleClipboard() { input.setAttribute("value", props.text); document.body.appendChild(input); input.select(); - let successful = false; try { - successful = document.execCommand("copy"); + const successful = document.execCommand("copy"); + + if (successful) { + ElMessage.success("Copy successfully!"); + } else { + ElMessage.warning("Copy failed!"); + } } finally { document.body.removeChild(input); } - - if (successful) { - ElMessage.success("Copy successfully!"); - } else { - ElMessage.warning("Copy failed!"); - } } } diff --git a/src/store/modules/tags-view.ts b/src/store/modules/tags-view.ts index 310f2cce..71f5a8eb 100644 --- a/src/store/modules/tags-view.ts +++ b/src/store/modules/tags-view.ts @@ -89,9 +89,9 @@ export const useTagsViewStore = defineStore("tagsView", () => { } function updateVisitedView(view: TagView) { - for (let v of visitedViews.value) { + for (const v of visitedViews.value) { if (v.path === view.path) { - v = Object.assign(v, view); + Object.assign(v, view); break; } } diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 2dcea989..0048e684 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -24,13 +24,13 @@ $tags-view-height: 34px; :root { // 菜单 --menu-background: #fff; - --menu-text: #212121; + --menu-text: #606266; --menu-active-text: var(--el-menu-active-color); --menu-hover: #e6f4ff; // 侧边栏 Logo --sidebar-logo-background: #f5f5f5; - --sidebar-logo-text-color: #333; + --sidebar-logo-text-color: #303133; } // SCSS 变量映射(供组件使用) diff --git a/src/types/api/role.ts b/src/types/api/role.ts index 2128ff24..521d86d7 100644 --- a/src/types/api/role.ts +++ b/src/types/api/role.ts @@ -43,7 +43,7 @@ export interface RoleForm { /** 数据权限(1-所有数据 2-部门及子部门数据 3-本部门数据 4-本人数据 5-自定义部门数据) */ dataScope?: number; /** 自定义数据权限部门ID列表(当dataScope=5时有效) */ - deptIds?: number[]; + deptIds?: string[]; /** 角色状态 */ status?: number; /** 备注 */ diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 08f172e0..7c234001 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,7 +1,7 @@  @@ -236,37 +257,45 @@ @@ -295,7 +324,7 @@ @@ -319,15 +348,23 @@ :hollow="index !== 0" size="large" > -
-
+
+
{{ item.title }} {{ item.tag }}
- {{ item.content }} + + {{ item.content }} +
详情 - +
@@ -363,21 +400,11 @@ import type { VisitStatsDetail, VisitTrendDetail } from "@/types/api"; import { useUserStore } from "@/store/modules/user"; import { formatGrowthRate } from "@/utils"; import { useTransition, useDateFormat } from "@vueuse/core"; -import { Connection, Failed } from "@element-plus/icons-vue"; +import { CircleCheck, CircleClose, Loading } from "@element-plus/icons-vue"; import { useOnlineCount } from "@/composables"; // 在线用户数量组件相关 -const { onlineUserCount, lastUpdateTime, isConnected } = useOnlineCount(); - -// 记录上一次的用户数量用于计算趋势 -const previousCount = ref(0); - -// 监听用户数量变化,计算趋势 -watch(onlineUserCount, (newCount, oldCount) => { - if (oldCount > 0) { - previousCount.value = oldCount; - } -}); +const { onlineUserCount, lastUpdateTime, isConnected, connectionState } = useOnlineCount(); // 格式化时间戳 const formattedTime = computed(() => { @@ -385,6 +412,23 @@ const formattedTime = computed(() => { return useDateFormat(lastUpdateTime, "HH:mm:ss").value; }); +const wsStatusText = computed(() => { + if (!isConnected.value) { + return connectionState.value === "CONNECTING" || connectionState.value === "RECONNECTING" + ? "连接中" + : "未连接"; + } + return "已连接"; +}); + +const wsStatusClass = computed(() => { + if (isConnected.value) + return "text-[--el-color-success] bg-[--el-color-success-light-9] border-[--el-color-success-light-7]"; + return connectionState.value === "CONNECTING" || connectionState.value === "RECONNECTING" + ? "text-[--el-color-warning] bg-[--el-color-warning-light-9] border-[--el-color-warning-light-7]" + : "text-[--el-color-danger] bg-[--el-color-danger-light-9] border-[--el-color-danger-light-7]"; +}); + interface VersionItem { id: string; title: string; // 版本标题(如:v2.4.0) @@ -456,6 +500,26 @@ const visitStatsData = ref({ totalPvCount: 0, }); +const uvGrowthText = computed(() => { + if ( + visitStatsData.value.uvGrowthRate === undefined || + visitStatsData.value.uvGrowthRate === null + ) { + return "--"; + } + return formatGrowthRate(visitStatsData.value.uvGrowthRate); +}); + +const pvGrowthText = computed(() => { + if ( + visitStatsData.value.pvGrowthRate === undefined || + visitStatsData.value.pvGrowthRate === null + ) { + return "--"; + } + return formatGrowthRate(visitStatsData.value.pvGrowthRate); +}); + // 数字过渡动画 const transitionUvCount = useTransition( computed(() => visitStatsData.value.todayUvCount), @@ -640,38 +704,5 @@ onMounted(() => {