mirror of
https://github.com/xiaoshi930/xiaoshi-pad-card.git
synced 2025-11-29 00:59:42 +00:00
Update xiaoshi-device-update-card.js
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
@@ -552,12 +563,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,弹出实体详情
|
||||||
@@ -577,9 +588,9 @@ export class XiaoshiUpdateCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_handleConfirmUpdate(update, event) {
|
_handleConfirmUpdate(update, event) {
|
||||||
|
this._handleClick();
|
||||||
event.stopPropagation(); // 阻止事件冒泡
|
event.stopPropagation(); // 阻止事件冒泡
|
||||||
event.preventDefault(); // 阻止默认行为
|
event.preventDefault(); // 阻止默认行为
|
||||||
navigator.vibrate(50);
|
|
||||||
|
|
||||||
// 弹出确认对话框
|
// 弹出确认对话框
|
||||||
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}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user