refactor: 优化代码

This commit is contained in:
wxg0103 2024-10-29 11:55:19 +08:00
parent 834ccaa35b
commit 77d29471a1
2 changed files with 11 additions and 7 deletions

View File

@ -47,12 +47,16 @@ export const defaultPlatformSetting = {
projectUrl: 'https://github.com/1Panel-dev/MaxKB' projectUrl: 'https://github.com/1Panel-dev/MaxKB'
} }
export function hexToRgba(hex: string, alpha: number) { export function hexToRgba(hex?: string, alpha?: number) {
// 将16进制颜色值的两个字符一起转换成十进制 // 将16进制颜色值的两个字符一起转换成十进制
const r = parseInt(hex.slice(1, 3), 16) if (!hex) {
const g = parseInt(hex.slice(3, 5), 16) return ''
const b = parseInt(hex.slice(5, 7), 16) } 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格式的字符串 // 返回RGBA格式的字符串
return `rgba(${r}, ${g}, ${b}, ${alpha})` return `rgba(${r}, ${g}, ${b}, ${alpha})`
}
} }

View File

@ -140,7 +140,7 @@
/> />
<img <img
v-else v-else
src="/ui/public/MaxKB.gif" src="/MaxKB.gif"
height="50px" height="50px"
style="width: 40px; height: 40px; display: block" style="width: 40px; height: 40px; display: block"
/> />