fix: 修复 BgTextConfigSheet 中 Color.parseColor 崩溃问题

当 bgStr/bgStrNight 为空字符串或非法颜色值时,toColorInt() 会抛出
IllegalArgumentException: Unknown color。使用 runCatching 包裹并提供
合理的默认值(日间 #EEEEEE,夜间 #000000)。
This commit is contained in:
HapeLee
2026-06-08 00:28:23 +08:00
parent 4cc04b20d5
commit 40cb04dfab
@@ -62,8 +62,12 @@ fun BgTextConfigSheet(
val styleName = styleConfig.styleName
val darkStatusIcon = styleConfig.darkStatusIcon
val bgAlpha = styleConfig.bgAlpha
val dayBgColor = if (styleConfig.bgType == 0) styleConfig.bgStr.toColorInt() else 0
val nightBgColor = if (styleConfig.bgTypeNight == 0) styleConfig.bgStrNight.toColorInt() else 0
val dayBgColor = if (styleConfig.bgType == 0) {
runCatching { styleConfig.bgStr.toColorInt() }.getOrDefault(0xFFEEEEEE.toInt())
} else 0
val nightBgColor = if (styleConfig.bgTypeNight == 0) {
runCatching { styleConfig.bgStrNight.toColorInt() }.getOrDefault(0xFF000000.toInt())
} else 0
val dayBgImage = if (styleConfig.bgType != 0) styleConfig.bgStr else null
val nightBgImage = if (styleConfig.bgTypeNight != 0) styleConfig.bgStrNight else null