mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-28 16:49:42 +00:00
Compare commits
16 Commits
da16f27cf2
...
6f58598f54
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f58598f54 | ||
|
|
f71e51029c | ||
|
|
48f0c23456 | ||
|
|
910365f8b8 | ||
|
|
81b40138f5 | ||
|
|
4783085a99 | ||
|
|
737b174953 | ||
|
|
d49426da73 | ||
|
|
3bf33ef0cb | ||
|
|
2c3c3fd42d | ||
|
|
4fe21a2c74 | ||
|
|
3900897f15 | ||
|
|
2170f5423c | ||
|
|
82e71cf38d | ||
|
|
c79052b1e1 | ||
|
|
5ef261877c |
@@ -975,12 +975,12 @@ class XiaoshiBalanceCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOilPriceData();
|
this._loadOilPriceData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
const evt = new Event('hass-more-info', { composed: true });
|
const evt = new Event('hass-more-info', { composed: true });
|
||||||
@@ -989,6 +989,17 @@ class XiaoshiBalanceCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_evaluateWarningCondition(value, condition) {
|
_evaluateWarningCondition(value, condition) {
|
||||||
if (!condition) return false;
|
if (!condition) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -1044,7 +1044,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 10px;
|
font-size: 11px;
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1054,7 +1054,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
|
|
||||||
.device-name {
|
.device-name {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -1064,13 +1064,12 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
|
|
||||||
.device-value {
|
.device-value {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
max-width: 45%;
|
max-width: 45%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1079,7 +1078,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.device-unit {
|
.device-unit {
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
margin-left: 0.5px;
|
margin-left: 0.5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -1261,12 +1260,12 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOilPriceData();
|
this._loadOilPriceData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
const evt = new Event('hass-more-info', { composed: true });
|
const evt = new Event('hass-more-info', { composed: true });
|
||||||
@@ -1274,6 +1273,18 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
this.dispatchEvent(evt);
|
this.dispatchEvent(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*button新元素 开始*/
|
/*button新元素 开始*/
|
||||||
_handleButtonClick() {
|
_handleButtonClick() {
|
||||||
const tapAction = this.config.tap_action;
|
const tapAction = this.config.tap_action;
|
||||||
@@ -1307,7 +1318,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
console.warn('browser_mod not available, cannot show popup');
|
console.warn('browser_mod not available, cannot show popup');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
}
|
}
|
||||||
/*button新元素 结束*/
|
/*button新元素 结束*/
|
||||||
|
|
||||||
|
|||||||
@@ -1524,7 +1524,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
|
|
||||||
.device-name {
|
.device-name {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -1534,13 +1534,12 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
|
|
||||||
.device-value {
|
.device-value {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
max-width: 45%;
|
max-width: 45%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1549,7 +1548,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.device-unit {
|
.device-unit {
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
margin-left: 0.5px;
|
margin-left: 0.5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -1731,12 +1730,12 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOilPriceData();
|
this._loadOilPriceData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
const evt = new Event('hass-more-info', { composed: true });
|
const evt = new Event('hass-more-info', { composed: true });
|
||||||
@@ -1746,6 +1745,17 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
}
|
}
|
||||||
/*button新元素 开始*/
|
/*button新元素 开始*/
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取默认弹出样式
|
// 获取默认弹出样式
|
||||||
_getDefaultPopupStyle() {
|
_getDefaultPopupStyle() {
|
||||||
return '--mdc-theme-surface: rgba(0,0,0,0)\n--dialog-backdrop-filter: blur(10px) brightness(1);';
|
return '--mdc-theme-surface: rgba(0,0,0,0)\n--dialog-backdrop-filter: blur(10px) brightness(1);';
|
||||||
@@ -1893,7 +1903,7 @@ class XiaoshiConsumablesButton extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 备选的弹出方案
|
// 备选的弹出方案
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
|
|
||||||
.device-name {
|
.device-name {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -916,13 +916,12 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
|
|
||||||
.device-value {
|
.device-value {
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
max-width: 45%;
|
max-width: 45%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,7 +930,7 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.device-unit {
|
.device-unit {
|
||||||
font-size: 9px;
|
font-size: 11px;
|
||||||
color: var(--fg-color, #000);
|
color: var(--fg-color, #000);
|
||||||
margin-left: 0.5px;
|
margin-left: 0.5px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -1113,12 +1112,12 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOilPriceData();
|
this._loadOilPriceData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
const evt = new Event('hass-more-info', { composed: true });
|
const evt = new Event('hass-more-info', { composed: true });
|
||||||
@@ -1127,6 +1126,17 @@ class XiaoshiConsumablesCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_renderDeviceItem(consumablesData) {
|
_renderDeviceItem(consumablesData) {
|
||||||
let isWarning = false;
|
let isWarning = false;
|
||||||
|
|
||||||
|
|||||||
@@ -766,6 +766,14 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
if (entityId.startsWith('climate.')) return 'mdi:thermostat';
|
if (entityId.startsWith('climate.')) return 'mdi:thermostat';
|
||||||
if (entityId.startsWith('cover.')) return 'mdi:window-shutter';
|
if (entityId.startsWith('cover.')) return 'mdi:window-shutter';
|
||||||
if (entityId.startsWith('weather.')) return 'mdi:weather-cloudy';
|
if (entityId.startsWith('weather.')) return 'mdi:weather-cloudy';
|
||||||
|
if (entityId.startsWith('input_select.')) return 'mdi:form-select';
|
||||||
|
if (entityId.startsWith('select.')) return 'mdi:form-select';
|
||||||
|
if (entityId.startsWith('input_text.')) return 'mdi:form-textbox';
|
||||||
|
if (entityId.startsWith('text.')) return 'mdi:form-textbox';
|
||||||
|
if (entityId.startsWith('button.')) return 'mdi:button-pointer';
|
||||||
|
if (entityId.startsWith('event.')) return 'mdi:gesture-tap-button';
|
||||||
|
if (entityId.startsWith('device_tracker.')) return 'mdi:lan-connect';
|
||||||
|
if (entityId.startsWith('notify.')) return 'mdi:message';
|
||||||
return 'mdi:help-circle';
|
return 'mdi:help-circle';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,13 +796,13 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOfflineDevices();
|
this._loadOfflineDevices();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleDeviceClick(device) {
|
_handleDeviceClick(device) {
|
||||||
navigator.vibrate(50);
|
|
||||||
// 点击设备时跳转到设备详情页
|
// 点击设备时跳转到设备详情页
|
||||||
|
this._handleClick();
|
||||||
if (device.device_id) {
|
if (device.device_id) {
|
||||||
// 先关闭当前弹窗/界面
|
// 先关闭当前弹窗/界面
|
||||||
this._closeCurrentDialog();
|
this._closeCurrentDialog();
|
||||||
@@ -817,7 +825,7 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
// 使用您建议的第一种方式
|
// 使用您建议的第一种方式
|
||||||
@@ -827,6 +835,17 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_closeCurrentDialog() {
|
_closeCurrentDialog() {
|
||||||
// 查找并关闭当前可能的弹窗或对话框
|
// 查找并关闭当前可能的弹窗或对话框
|
||||||
const dialogs = document.querySelectorAll('ha-dialog, .mdc-dialog, paper-dialog, vaadin-dialog');
|
const dialogs = document.querySelectorAll('ha-dialog, .mdc-dialog, paper-dialog, vaadin-dialog');
|
||||||
@@ -907,6 +926,12 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增规则:如果skipped_version为null情况下,当latest_version !== installed_version时,
|
||||||
|
// 且实体状态为off时,有可能是安装的版本比latest_version还高,这种不算更新的实体
|
||||||
|
if (attributes.skipped_version === null && entity.state === 'off') {
|
||||||
|
return; // 跳过此更新
|
||||||
|
}
|
||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
name: attributes.friendly_name || entity.entity_id.replace('update.', ''),
|
name: attributes.friendly_name || entity.entity_id.replace('update.', ''),
|
||||||
current_version: attributes.installed_version,
|
current_version: attributes.installed_version,
|
||||||
@@ -946,14 +971,14 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadUpdateData();
|
this._loadUpdateData();
|
||||||
this._loadOfflineDevices();
|
this._loadOfflineDevices();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleUpdateClick(update) {
|
_handleUpdateClick(update) {
|
||||||
navigator.vibrate(50);
|
|
||||||
// 点击更新项时弹出实体详情
|
// 点击更新项时弹出实体详情
|
||||||
|
this._handleClick();
|
||||||
|
|
||||||
// 如果有entity_id,弹出实体详情
|
// 如果有entity_id,弹出实体详情
|
||||||
if (update.entity_id) {
|
if (update.entity_id) {
|
||||||
@@ -974,7 +999,7 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
_handleConfirmUpdate(update, event) {
|
_handleConfirmUpdate(update, event) {
|
||||||
event.stopPropagation(); // 阻止事件冒泡
|
event.stopPropagation(); // 阻止事件冒泡
|
||||||
event.preventDefault(); // 阻止默认行为
|
event.preventDefault(); // 阻止默认行为
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
|
|
||||||
// 弹出确认对话框
|
// 弹出确认对话框
|
||||||
const confirmed = confirm(`确认要更新 ${update.name} 吗?\n当前版本: ${update.current_version}\n最新版本: ${update.latest_version}`);
|
const confirmed = confirm(`确认要更新 ${update.name} 吗?\n当前版本: ${update.current_version}\n最新版本: ${update.latest_version}`);
|
||||||
@@ -986,6 +1011,7 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
this._loadUpdateData();
|
this._loadUpdateData();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_executeUpdate(update) {
|
_executeUpdate(update) {
|
||||||
@@ -1249,7 +1275,7 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
<div class="device-name">${update.name}</div>
|
<div class="device-name">${update.name}</div>
|
||||||
<div class="device-details">
|
<div class="device-details">
|
||||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
${update.skipped_version ? html`<br><span style="color: #ff9800;">已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="device-last-seen-update" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
<div class="device-last-seen-update" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||||
@@ -1274,7 +1300,7 @@ export class XiaoshiHaInfoCard extends LitElement {
|
|||||||
<div class="device-name">${update.name}</div>
|
<div class="device-name">${update.name}</div>
|
||||||
<div class="device-details">
|
<div class="device-details">
|
||||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
${update.skipped_version ? html`<br><span style="color: #ff9800;">已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="device-last-seen-update" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
<div class="device-last-seen-update" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||||
|
|||||||
@@ -667,12 +667,12 @@ export class XiaoshiOfflineCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadOfflineDevices();
|
this._loadOfflineDevices();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleDeviceClick(device) {
|
_handleDeviceClick(device) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击设备时跳转到设备详情页
|
// 点击设备时跳转到设备详情页
|
||||||
if (device.device_id) {
|
if (device.device_id) {
|
||||||
// 先关闭当前弹窗/界面
|
// 先关闭当前弹窗/界面
|
||||||
@@ -696,7 +696,7 @@ export class XiaoshiOfflineCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
// 使用您建议的第一种方式
|
// 使用您建议的第一种方式
|
||||||
@@ -706,6 +706,17 @@ export class XiaoshiOfflineCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_closeCurrentDialog() {
|
_closeCurrentDialog() {
|
||||||
// 查找并关闭当前可能的弹窗或对话框
|
// 查找并关闭当前可能的弹窗或对话框
|
||||||
const dialogs = document.querySelectorAll('ha-dialog, .mdc-dialog, paper-dialog, vaadin-dialog');
|
const dialogs = document.querySelectorAll('ha-dialog, .mdc-dialog, paper-dialog, vaadin-dialog');
|
||||||
|
|||||||
@@ -941,12 +941,12 @@ class XiaoshiTodoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadTodoData();
|
this._loadTodoData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
const evt = new Event('hass-more-info', { composed: true });
|
const evt = new Event('hass-more-info', { composed: true });
|
||||||
@@ -955,6 +955,17 @@ class XiaoshiTodoCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _addTodoItem(entityId, item, description = '', due = '') {
|
async _addTodoItem(entityId, item, description = '', due = '') {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleEntityClick(entity) {
|
_handleEntityClick(entity) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击实体时打开实体详情页
|
// 点击实体时打开实体详情页
|
||||||
if (entity.entity_id) {
|
if (entity.entity_id) {
|
||||||
// 使用您建议的第一种方式
|
// 使用您建议的第一种方式
|
||||||
@@ -478,6 +478,17 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleClick(){
|
||||||
|
if (navigator.vibrate) {
|
||||||
|
navigator.vibrate(50);
|
||||||
|
}
|
||||||
|
else if (navigator.webkitVibrate) {
|
||||||
|
navigator.webkitVibrate(50);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _loadUpdateData() {
|
async _loadUpdateData() {
|
||||||
if (!this.hass) return;
|
if (!this.hass) return;
|
||||||
|
|
||||||
@@ -512,6 +523,11 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
return; // 跳过此更新
|
return; // 跳过此更新
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 新增规则:如果skipped_version为null情况下,当latest_version !== installed_version时,
|
||||||
|
// 且实体状态为off时,有可能是安装的版本比latest_version还高,这种不算更新的实体
|
||||||
|
if (attributes.skipped_version === null && entity.state === 'off') {
|
||||||
|
return; // 跳过此更新
|
||||||
|
}
|
||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
name: attributes.friendly_name || entity.entity_id.replace('update.', ''),
|
name: attributes.friendly_name || entity.entity_id.replace('update.', ''),
|
||||||
@@ -552,12 +568,12 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleRefresh() {
|
_handleRefresh() {
|
||||||
|
this._handleClick();
|
||||||
this._loadUpdateData();
|
this._loadUpdateData();
|
||||||
navigator.vibrate(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleUpdateClick(update) {
|
_handleUpdateClick(update) {
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
// 点击更新项时弹出实体详情
|
// 点击更新项时弹出实体详情
|
||||||
|
|
||||||
// 如果有entity_id,弹出实体详情
|
// 如果有entity_id,弹出实体详情
|
||||||
@@ -579,7 +595,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
_handleConfirmUpdate(update, event) {
|
_handleConfirmUpdate(update, event) {
|
||||||
event.stopPropagation(); // 阻止事件冒泡
|
event.stopPropagation(); // 阻止事件冒泡
|
||||||
event.preventDefault(); // 阻止默认行为
|
event.preventDefault(); // 阻止默认行为
|
||||||
navigator.vibrate(50);
|
this._handleClick();
|
||||||
|
|
||||||
// 弹出确认对话框
|
// 弹出确认对话框
|
||||||
const confirmed = confirm(`确认要更新 ${update.name} 吗?\n当前版本: ${update.current_version}\n最新版本: ${update.latest_version}`);
|
const confirmed = confirm(`确认要更新 ${update.name} 吗?\n当前版本: ${update.current_version}\n最新版本: ${update.latest_version}`);
|
||||||
@@ -854,7 +870,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
<div class="device-name">${update.name}</div>
|
<div class="device-name">${update.name}</div>
|
||||||
<div class="device-details">
|
<div class="device-details">
|
||||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
${update.skipped_version ? html`<br><span style="color: #ff9800;">已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||||
@@ -879,7 +895,7 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
<div class="device-name">${update.name}</div>
|
<div class="device-name">${update.name}</div>
|
||||||
<div class="device-details">
|
<div class="device-details">
|
||||||
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
当前版本: ${update.current_version} → 最新版本: ${update.latest_version}
|
||||||
${update.skipped_version ? html`<span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
${update.skipped_version ? html`<br><span style="color: #ff9800;"> 已跳过版本: ${update.skipped_version}</span>` : ''}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
<div class="device-last-seen" @click=${(e) => this._handleConfirmUpdate(update, e)}>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
console.info("%c 消逝卡-平板端 \n%c v 0.1.4 ", "color: red; font-weight: bold; background: black", "color: white; font-weight: bold; background: black");
|
console.info("%c 消逝卡-平板端 \n%c v 0.1.5 ", "color: red; font-weight: bold; background: black", "color: white; font-weight: bold; background: black");
|
||||||
|
|
||||||
const loadCards = async () => {
|
const loadCards = async () => {
|
||||||
await import('./xiaoshi-pad-grid-card.js');
|
await import('./xiaoshi-pad-grid-card.js');
|
||||||
|
|||||||
Reference in New Issue
Block a user