From 77d29471a1bd61f579ff9dada4222e268aa3db55 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 29 Oct 2024 11:55:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/utils/theme.ts | 16 ++++++++++------ .../component/XPackDisplaySettingDialog.vue | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/src/utils/theme.ts b/ui/src/utils/theme.ts index 96a885938..35dbbbb35 100644 --- a/ui/src/utils/theme.ts +++ b/ui/src/utils/theme.ts @@ -47,12 +47,16 @@ export const defaultPlatformSetting = { projectUrl: 'https://github.com/1Panel-dev/MaxKB' } -export function hexToRgba(hex: string, alpha: number) { +export function hexToRgba(hex?: string, alpha?: number) { // 将16进制颜色值的两个字符一起转换成十进制 - const r = parseInt(hex.slice(1, 3), 16) - const g = parseInt(hex.slice(3, 5), 16) - const b = parseInt(hex.slice(5, 7), 16) + if (!hex) { + return '' + } else { + const r = parseInt(hex.slice(1, 3), 16) + const g = parseInt(hex.slice(3, 5), 16) + const b = parseInt(hex.slice(5, 7), 16) - // 返回RGBA格式的字符串 - return `rgba(${r}, ${g}, ${b}, ${alpha})` + // 返回RGBA格式的字符串 + return `rgba(${r}, ${g}, ${b}, ${alpha})` + } } diff --git a/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue b/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue index 67f7c2882..befd04ae7 100644 --- a/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue +++ b/ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue @@ -140,7 +140,7 @@ />