Skip to content

Commit 77d2947

Browse files
committed
refactor: 优化代码
1 parent 834ccaa commit 77d2947

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

ui/src/utils/theme.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ export const defaultPlatformSetting = {
4747
projectUrl: 'https://github.com/1Panel-dev/MaxKB'
4848
}
4949

50-
export function hexToRgba(hex: string, alpha: number) {
50+
export function hexToRgba(hex?: string, alpha?: number) {
5151
// 将16进制颜色值的两个字符一起转换成十进制
52-
const r = parseInt(hex.slice(1, 3), 16)
53-
const g = parseInt(hex.slice(3, 5), 16)
54-
const b = parseInt(hex.slice(5, 7), 16)
52+
if (!hex) {
53+
return ''
54+
} else {
55+
const r = parseInt(hex.slice(1, 3), 16)
56+
const g = parseInt(hex.slice(3, 5), 16)
57+
const b = parseInt(hex.slice(5, 7), 16)
5558

56-
// 返回RGBA格式的字符串
57-
return `rgba(${r}, ${g}, ${b}, ${alpha})`
59+
// 返回RGBA格式的字符串
60+
return `rgba(${r}, ${g}, ${b}, ${alpha})`
61+
}
5862
}

ui/src/views/application-overview/component/XPackDisplaySettingDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
/>
141141
<img
142142
v-else
143-
src="/ui/public/MaxKB.gif"
143+
src="/MaxKB.gif"
144144
height="50px"
145145
style="width: 40px; height: 40px; display: block"
146146
/>

0 commit comments

Comments
 (0)