From fe22c85d3b435b7064c2ae8340eccaf7adff76cd Mon Sep 17 00:00:00 2001
From: xiaoshi <115949669+xiaoshi930@users.noreply.github.com>
Date: Sat, 13 Dec 2025 22:48:20 +0800
Subject: [PATCH] Update xiaoshi-device-ha-info-button.js
---
xiaoshi-device-ha-info-button.js | 48 +++++++++++++++++++++++++-------
1 file changed, 38 insertions(+), 10 deletions(-)
diff --git a/xiaoshi-device-ha-info-button.js b/xiaoshi-device-ha-info-button.js
index f4dff5c..5e27e5a 100644
--- a/xiaoshi-device-ha-info-button.js
+++ b/xiaoshi-device-ha-info-button.js
@@ -93,7 +93,6 @@ class XiaoshiHaInfoButtonEditor extends LitElement {
-
+
+
+
+
+ (平板端特性)白色图标文字(勾选后锁定显示白色)
@@ -140,7 +153,7 @@ class XiaoshiHaInfoButtonEditor extends LitElement {
id="hide_icon"
/>
- 隐藏图标(勾选后隐藏图标)
+ ( 平板端特性)隐藏图标(勾选后隐藏图标)
@@ -154,7 +167,7 @@ class XiaoshiHaInfoButtonEditor extends LitElement {
id="hide_colon"
/>
- 隐藏冒号(勾选后不显示冒号,改为空格)
+ (平板端特性)隐藏冒号(勾选后不显示冒号,改为空格)
@@ -168,7 +181,7 @@ class XiaoshiHaInfoButtonEditor extends LitElement {
id="hide_zero"
/>
- 隐藏0值(勾选后数量为0时不显示数量)
+ (平板端特性)隐藏0值(勾选后数量为0时不显示数量)
@@ -342,7 +355,7 @@ template: 测试模板(最好引用模板,否则大概率会报错)'>
if (type === 'checkbox') {
finalValue = checked;
} else {
- if (!value && name !== 'theme' && name !== 'button_width' && name !== 'button_height' && name !== 'button_font_size' && name !== 'button_icon_size' && name !== 'width' && name !== 'tap_action') return;
+ if (!value && name !== 'theme' && name !== 'button_width' && name !== 'button_height' && name !== 'button_font_size' && name !== 'button_icon_size' && name !== 'width' && name !== 'tap_action' && name !== 'display_mode' && name !== 'decimal_precision') return;
finalValue = value
}
@@ -1781,6 +1794,7 @@ export class XiaoshiHaInfoButton extends LitElement {
const hideColon = this.config.hide_colon === true;
const hideZero = this.config.hide_zero === true;
const autoHide = this.config.auto_hide === true;
+ const lockWhiteFg = this.config.lock_white_fg === true;
const buttonText = this.config.button_text || 'HA';
const buttonIcon = this.config.button_icon || 'mdi:home-assistant';
@@ -1825,9 +1839,13 @@ export class XiaoshiHaInfoButton extends LitElement {
displayText += '\u2002'; // 两个en空格,大约等于数字"0"的宽度
}
+ // 应用锁定白色功能
+ const iconColor = lockWhiteFg ? 'rgb(255, 255, 255)' : fgColor;
+ const textColor = lockWhiteFg ? 'rgb(255, 255, 255)' : fgColor;
+
buttonHtml = html`
-
- ${!hideIcon ? html`
` : ''}
+
+ ${!hideIcon ? html`` : ''}
${displayText}
`;
@@ -1845,7 +1863,17 @@ export class XiaoshiHaInfoButton extends LitElement {
`;
} else {
// 普通模式:显示文本和数量
- const textColor = warningCount === 0 ? fgColor : 'rgb(255, 0, 0)';
+ // 应用锁定白色功能,但预警颜色(红色)不受影响
+ let textColor, iconColor;
+ if (warningCount === 0) {
+ // 非预警状态:根据锁定白色设置决定颜色
+ textColor = lockWhiteFg ? 'rgb(255, 255, 255)' : fgColor;
+ iconColor = lockWhiteFg ? 'rgb(255, 255, 255)' : fgColor;
+ } else {
+ // 预警状态:始终使用红色,不受锁定白色影响
+ textColor = 'rgb(255, 0, 0)';
+ iconColor = lockWhiteFg ? 'rgb(255, 255, 255)' : fgColor;
+ }
// 构建显示文本
let displayText = buttonText;
@@ -1867,7 +1895,7 @@ export class XiaoshiHaInfoButton extends LitElement {
buttonHtml = html`
- ${!hideIcon ? html`` : ''}
+ ${!hideIcon ? html`` : ''}
${displayText}
`;