mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-01-15 17:27:36 -05:00
fix: trim str, clear choise when change option
This commit is contained in:
parent
da62c3d50a
commit
25adf97b2b
@ -14,14 +14,15 @@ class DingDing extends NotificationProvider {
|
|||||||
const mentionAll = notification.mentioning === "everyone";
|
const mentionAll = notification.mentioning === "everyone";
|
||||||
const mobileList = notification.mentioning === "specify-mobiles" ? notification.mobileList : [];
|
const mobileList = notification.mentioning === "specify-mobiles" ? notification.mobileList : [];
|
||||||
const userList = notification.mentioning === "specify-users" ? notification.userList : [];
|
const userList = notification.mentioning === "specify-users" ? notification.userList : [];
|
||||||
const mentionStr = [ ...mobileList || [], ...userList || [] ].map(item => `@${item}`).join(" ");
|
const finalList = [ ...mobileList || [], ...userList || [] ];
|
||||||
|
const mentionStr = finalList.length > 0 ? "\n" : "" + finalList.map(item => `@${item}`).join(" ");
|
||||||
try {
|
try {
|
||||||
if (heartbeatJSON != null) {
|
if (heartbeatJSON != null) {
|
||||||
let params = {
|
let params = {
|
||||||
msgtype: "markdown",
|
msgtype: "markdown",
|
||||||
markdown: {
|
markdown: {
|
||||||
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
|
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
|
||||||
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}${"\n\n" + mentionStr}`,
|
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}${mentionStr}`,
|
||||||
},
|
},
|
||||||
at: {
|
at: {
|
||||||
isAtAll: mentionAll,
|
isAtAll: mentionAll,
|
||||||
@ -36,7 +37,7 @@ class DingDing extends NotificationProvider {
|
|||||||
let params = {
|
let params = {
|
||||||
msgtype: "text",
|
msgtype: "text",
|
||||||
text: {
|
text: {
|
||||||
content: `${msg}${"\n" + mentionStr}`
|
content: `${msg}${mentionStr}`
|
||||||
},
|
},
|
||||||
at: {
|
at: {
|
||||||
isAtAll: mentionAll,
|
isAtAll: mentionAll,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="mentioning" class="form-label">{{ $t("Mentioning") }}<span style="color: red;"><sup>*</sup></span></label>
|
<label for="mentioning" class="form-label">{{ $t("Mentioning") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
<select id="mentioning" v-model="$parent.notification.mentioning" class="form-select" required>
|
<select id="mentioning" v-model="$parent.notification.mentioning" class="form-select" required @change="onMentioningChange">
|
||||||
<option value="nobody">{{ $t("Don't mention people") }}</option>
|
<option value="nobody">{{ $t("Don't mention people") }}</option>
|
||||||
<option value="everyone">{{ $t("Mention group", { group: "@everyone" }) }}</option>
|
<option value="everyone">{{ $t("Mention group", { group: "@everyone" }) }}</option>
|
||||||
<option value="specify-mobiles">{{ $t("Mention Mobile List") }}</option>
|
<option value="specify-mobiles">{{ $t("Mention Mobile List") }}</option>
|
||||||
@ -94,10 +94,20 @@ export default {
|
|||||||
if (typeof this.$parent.notification.userList === "undefined") {
|
if (typeof this.$parent.notification.userList === "undefined") {
|
||||||
this.$parent.notification.userList = [];
|
this.$parent.notification.userList = [];
|
||||||
} else {
|
} else {
|
||||||
this.mobileOpts = this.$parent.notification.mobileList;
|
this.userIdOpts = this.$parent.notification.userList;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onMentioningChange(e) {
|
||||||
|
if (e.target.value === "specify-mobiles") {
|
||||||
|
this.$parent.notification.userList = [];
|
||||||
|
} else if (e.target.value === "specify-users") {
|
||||||
|
this.$parent.notification.mobileList = [];
|
||||||
|
} else {
|
||||||
|
this.$parent.notification.userList = [];
|
||||||
|
this.$parent.notification.mobileList = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
addMobile(mobile) {
|
addMobile(mobile) {
|
||||||
const trimmedMobile = mobile.trim();
|
const trimmedMobile = mobile.trim();
|
||||||
const chinaMobileRegex = /^1[3-9]\d{9}$/;
|
const chinaMobileRegex = /^1[3-9]\d{9}$/;
|
||||||
|
Loading…
Reference in New Issue
Block a user