From 56c547f00a8259512d1140c42cc6667ff0061df9 Mon Sep 17 00:00:00 2001 From: innerpeacez Date: Tue, 11 Mar 2025 10:22:28 +0800 Subject: [PATCH] optimized --- server/notification-providers/yzj.js | 28 ++++++++++++---------------- src/components/notifications/YZJ.vue | 17 +++++++++++++---- src/lang/en.json | 3 ++- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/server/notification-providers/yzj.js b/server/notification-providers/yzj.js index 775d71525..973bbff12 100644 --- a/server/notification-providers/yzj.js +++ b/server/notification-providers/yzj.js @@ -12,20 +12,17 @@ class YZJ extends NotificationProvider { let okMsg = "Sent Successfully."; try { + if (heartbeatJSON != null) { - let params = { - content: `${this.statusToString(heartbeatJSON["status"])} ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}` - }; - if (await this.sendToYZJ(notification, params)) { - return okMsg; - } - } else { - let params = { - content: msg - }; - if (await this.sendToYZJ(notification, params)) { - return okMsg; - } + msg = `${this.statusToString(heartbeatJSON["status"])} ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}` + } + + let params = { + content: msg + }; + + if (await this.sendToYZJ(notification, params)) { + return okMsg; } } catch (error) { this.throwGeneralAxiosError(error); @@ -50,10 +47,9 @@ class YZJ extends NotificationProvider { }; let result = await axios(config); - if (result.data.success === true) { - return true; + if (!result.data?.success) { + throw new Error(result.data?.errmsg); } - throw new Error(result.data.errmsg); } /** diff --git a/src/components/notifications/YZJ.vue b/src/components/notifications/YZJ.vue index 9409b450d..94f4a378d 100644 --- a/src/components/notifications/YZJ.vue +++ b/src/components/notifications/YZJ.vue @@ -2,14 +2,23 @@
- - - - {{ $t("here") }}
+
+ + +
+
+ + + + {{ $t("here") }} + +