From e56391c98e07417a2541a750f1aaa8f6a64bbb41 Mon Sep 17 00:00:00 2001 From: zhaojisen <1301338853@qq.com> Date: Tue, 3 Mar 2026 15:51:55 +0800 Subject: [PATCH] Optimize the display of some colors --- src/styles/index.scss | 2 +- src/utils/theme/color.js | 38 ++++++++++++++++++ .../reports/pam/Dashboard/RiskSummary.vue | 39 ++++++++++++++++++- .../reports/pam/Dashboard/SummaryChart.vue | 13 ++++--- 4 files changed, 85 insertions(+), 7 deletions(-) diff --git a/src/styles/index.scss b/src/styles/index.scss index eda8513af..830d903e3 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -605,7 +605,7 @@ li.rmenu i.fa { } .fa-check-circle { - color: #1ab394 !important; + color: var(--color-primary) !important; } .el-alert.el-alert--info.is-light { diff --git a/src/utils/theme/color.js b/src/utils/theme/color.js index 4427f80d8..5449e8df1 100644 --- a/src/utils/theme/color.js +++ b/src/utils/theme/color.js @@ -70,6 +70,44 @@ export function mix(color_1, color_2, weight) { return color } +export function getCssVar(name, fallback = '') { + if (typeof window === 'undefined' || typeof document === 'undefined') { + return fallback + } + + const root = document.documentElement + const inlineValue = root.style.getPropertyValue(name) + const computedValue = window.getComputedStyle(root).getPropertyValue(name) + const defaultValue = fallback || defaultThemeConfig[name] || '' + return (inlineValue || computedValue || defaultValue).trim() +} + +export function colorToRgba(color, alpha) { + const fallback = alpha === 0 ? 'transparent' : color + if (!color) { + return alpha === 0 ? 'transparent' : color + } + + const normalizedColor = color.trim() + if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(normalizedColor)) { + const hex = normalizedColor.slice(1) + const fullHex = hex.length === 3 + ? hex.split('').map(char => char + char).join('') + : hex + const r = Number.parseInt(fullHex.slice(0, 2), 16) + const g = Number.parseInt(fullHex.slice(2, 4), 16) + const b = Number.parseInt(fullHex.slice(4, 6), 16) + return `rgba(${r}, ${g}, ${b}, ${alpha})` + } + + const rgbValues = normalizedColor.match(/\d+/g) + if (normalizedColor.startsWith('rgb') && rgbValues && rgbValues.length >= 3) { + return `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, ${alpha})` + } + + return fallback +} + export function setRootColors() { const themeColors = defaultThemeConfig || {} for (const [key, value] of Object.entries(themeColors)) { diff --git a/src/views/reports/pam/Dashboard/RiskSummary.vue b/src/views/reports/pam/Dashboard/RiskSummary.vue index 7cc2b4545..afbedfc46 100644 --- a/src/views/reports/pam/Dashboard/RiskSummary.vue +++ b/src/views/reports/pam/Dashboard/RiskSummary.vue @@ -12,6 +12,7 @@