Fixed the issue that clicking the Settings button on the edit status page was invalid

This commit is contained in:
Marshu 2025-04-13 23:41:43 +08:00
parent 436ac1b2ca
commit 853e84178e
2 changed files with 182 additions and 170 deletions

View file

@ -72,11 +72,17 @@ export default {
* @returns {void} * @returns {void}
*/ */
show(group, monitor) { show(group, monitor) {
// Check if monitor exists and has required properties
if (!monitor || !monitor.id) {
console.error("Invalid monitor object", monitor);
return;
}
this.monitor = { this.monitor = {
id: monitor.element.id, id: monitor.id,
name: monitor.element.name, name: monitor.name,
monitor_index: monitor.index, monitor_index: monitor.index || 0,
group_index: group.index, group_index: group.index || 0,
isClickAble: this.showLink(monitor), isClickAble: this.showLink(monitor),
}; };
@ -103,12 +109,18 @@ export default {
* @returns {boolean} Should the link be shown? * @returns {boolean} Should the link be shown?
*/ */
showLink(monitor, ignoreSendUrl = false) { showLink(monitor, ignoreSendUrl = false) {
if (!monitor || !monitor.id) {
return false;
}
// We must check if there are any elements in monitorList to // We must check if there are any elements in monitorList to
// prevent undefined errors if it hasn't been loaded yet // prevent undefined errors if it hasn't been loaded yet
if (this.$parent.editMode && ignoreSendUrl && Object.keys(this.$root.monitorList).length) { if (this.$parent.editMode && ignoreSendUrl && Object.keys(this.$root.monitorList).length) {
return this.$root.monitorList[monitor.element.id].type === "http" || this.$root.monitorList[monitor.element.id].type === "keyword" || this.$root.monitorList[monitor.element.id].type === "json-query"; return this.$root.monitorList[monitor.id].type === "http" ||
this.$root.monitorList[monitor.id].type === "keyword" ||
this.$root.monitorList[monitor.id].type === "json-query";
} }
return monitor.element.sendUrl && monitor.element.url && monitor.element.url !== "https://" && !this.editMode; return monitor.sendUrl && monitor.url && monitor.url !== "https://" && !this.editMode;
}, },
}, },
}; };

View file

@ -235,7 +235,7 @@
v-if="editMode" v-if="editMode"
:class="{'link-active': true, 'btn-link': true}" :class="{'link-active': true, 'btn-link': true}"
icon="cog" class="action me-3" icon="cog" class="action me-3"
@click="$refs.monitorSettingDialog.show(group.element, monitor)" @click="$refs.monitorSettingDialog.show(group, monitor)"
/> />
</span> </span>
</div> </div>