From 82a79418ede1432574be25c6a39dcee5167cd7eb Mon Sep 17 00:00:00 2001 From: Teror Fox <i@trfox.top> Date: Sat, 22 Mar 2025 15:31:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(notification):=20=E9=87=8D=E6=9E=84=20?= =?UTF-8?q?PushPlusPlus=20=E9=80=9A=E7=9F=A5=E6=8F=90=E4=BE=9B=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 PushPlusPlus 类和相关组件 - 新增 PushPlus 类和组件 - 更新通知提供商列表和相关配置 - 修改国际化文案,将 PushPlusPlus 改为 PushPlus --- .../{pushplusplus.js => pushplus.js} | 22 +++++++++++++------ server/notification.js | 4 ++-- src/components/NotificationDialog.vue | 2 +- src/components/notifications/PushPlus.vue | 16 ++++++++++++++ src/components/notifications/PushPlusPlus.vue | 16 -------------- src/components/notifications/index.js | 4 ++-- src/lang/zh-CN.json | 2 +- src/lang/zh-HK.json | 2 +- src/lang/zh-TW.json | 2 +- 9 files changed, 39 insertions(+), 31 deletions(-) rename server/notification-providers/{pushplusplus.js => pushplus.js} (68%) create mode 100644 src/components/notifications/PushPlus.vue delete mode 100644 src/components/notifications/PushPlusPlus.vue diff --git a/server/notification-providers/pushplusplus.js b/server/notification-providers/pushplus.js similarity index 68% rename from server/notification-providers/pushplusplus.js rename to server/notification-providers/pushplus.js index 3d39d6dd3..cb062a9e0 100644 --- a/server/notification-providers/pushplusplus.js +++ b/server/notification-providers/pushplus.js @@ -2,22 +2,30 @@ const NotificationProvider = require("./notification-provider"); const axios = require("axios"); const { DOWN, UP } = require("../../src/util"); -class PushPlusPlus extends NotificationProvider { - name = "PushPlusPlus"; +class PushPlus extends NotificationProvider { + name = "PushPlus"; + + /** + * @inheritdoc + */ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { const okMsg = "Sent Successfully."; - const url = `https://pushplus.plus/send`; + const url = `https://www.pushplus.plus/send`; try { - await axios.post(notification.PushPlusPlusToken, { + await axios.post(url, { + "token": notification.pushPlusSendToken, "title": this.checkStatus(heartbeatJSON, monitorJSON), "content": msg, - }); - + "template": "html" + }, { headers: { "Content-Type": "application/json" } } + ); return okMsg; } catch (error) { this.throwGeneralAxiosError(error); + console.error("PushPlus Error:", error.response?.data || error.message); + throw new Error("Notification failed: " + error.message); } } @@ -39,4 +47,4 @@ class PushPlusPlus extends NotificationProvider { } } -module.exports = PushPlusPlus; \ No newline at end of file +module.exports = PushPlus; \ No newline at end of file diff --git a/server/notification.js b/server/notification.js index 6827df72f..0c222d932 100644 --- a/server/notification.js +++ b/server/notification.js @@ -39,7 +39,7 @@ const PromoSMS = require("./notification-providers/promosms"); const Pushbullet = require("./notification-providers/pushbullet"); const PushDeer = require("./notification-providers/pushdeer"); const Pushover = require("./notification-providers/pushover"); -const PushPlusPlus = require("./notification-providers/pushplusplus"); +const PushPlus = require("./notification-providers/pushplus"); const Pushy = require("./notification-providers/pushy"); const RocketChat = require("./notification-providers/rocket-chat"); const SerwerSMS = require("./notification-providers/serwersms"); @@ -129,7 +129,7 @@ class Notification { new Pushbullet(), new PushDeer(), new Pushover(), - new PushPlusPlus(), + new PushPlus(), new Pushy(), new RocketChat(), new ServerChan(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index ffcb7936f..f208d540c 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -182,7 +182,7 @@ export default { "SMSManager": "SmsManager (smsmanager.cz)", "WeCom": "WeCom (企业微信群机器人)", "ServerChan": "ServerChan (Server酱)", - "PushPlusPlus": "PushPlusPlus(推送加)", + "PushPlusPlus": "PushPlus(推送加)", "smsc": "SMSC", "WPush": "WPush(wpush.cn)", "YZJ": "YZJ (云之家自定义机器人)" diff --git a/src/components/notifications/PushPlus.vue b/src/components/notifications/PushPlus.vue new file mode 100644 index 000000000..67d61b90b --- /dev/null +++ b/src/components/notifications/PushPlus.vue @@ -0,0 +1,16 @@ +<template> + <div class="mb-3"> + <label for="pushPlus-sendkey" class="form-label">{{ $t("SendKey") }}</label> + <HiddenInput id="pushPlus-sendkey" v-model="$parent.notification.pushPlusSendKey" :required="true" autocomplete="new-password"></HiddenInput> + </div> +</template> + +<script> +import HiddenInput from "../HiddenInput.vue"; + +export default { + components: { + HiddenInput, + }, +}; +</script> \ No newline at end of file diff --git a/src/components/notifications/PushPlusPlus.vue b/src/components/notifications/PushPlusPlus.vue deleted file mode 100644 index 79bc7af61..000000000 --- a/src/components/notifications/PushPlusPlus.vue +++ /dev/null @@ -1,16 +0,0 @@ -<template> - <div class="mb-3"> - <label for="pushplusplus-sendkey" class="form-label">{{ $t("SendKey") }}</label> - <HiddenInput id="pushplusplus-sendkey" v-model="$parent.notification.PushPlusPlusSendKey" :required="true" autocomplete="new-password"></HiddenInput> - </div> -</template> - -<script> -import HiddenInput from "../HiddenInput.vue"; - -export default { - components: { - HiddenInput, - }, -}; -</script> \ No newline at end of file diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 2741296f3..76c00f052 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -39,7 +39,7 @@ import PromoSMS from "./PromoSMS.vue"; import Pushbullet from "./Pushbullet.vue"; import PushDeer from "./PushDeer.vue"; import Pushover from "./Pushover.vue"; -import PushPlusPlus from "./PushPlusPlus.vue"; +import PushPlus from "./PushPlus.vue"; import Pushy from "./Pushy.vue"; import RocketChat from "./RocketChat.vue"; import ServerChan from "./ServerChan.vue"; @@ -117,7 +117,7 @@ const NotificationFormList = { "PushByTechulus": TechulusPush, "PushDeer": PushDeer, "pushover": Pushover, - "PushPlusPlus": PushPlusPlus, + "PushPlusPlus": PushPlus, "pushy": Pushy, "rocket.chat": RocketChat, "serwersms": SerwerSMS, diff --git a/src/lang/zh-CN.json b/src/lang/zh-CN.json index 4a9a277b0..1b23aaf9c 100644 --- a/src/lang/zh-CN.json +++ b/src/lang/zh-CN.json @@ -1101,5 +1101,5 @@ "Separate multiple email addresses with commas": "用逗号分隔多个电子邮件地址", "rabbitmqHelpText": "要使用此监控项,您需要在 RabbitMQ 设置中启用管理插件。有关更多信息,请参阅 {rabitmq_documentation}。", "aboutSlackUsername": "更改消息发件人的显示名称。如果您想提及某人,请另行将其包含在友好名称中。", - "PushPlusPlus Token": "PushPlusPlus Token" + "PushPlus Token": "PushPlus Token" } diff --git a/src/lang/zh-HK.json b/src/lang/zh-HK.json index 84e04ab35..700d3c51e 100644 --- a/src/lang/zh-HK.json +++ b/src/lang/zh-HK.json @@ -1086,5 +1086,5 @@ "cellsyntDestination": "收件人的手機號碼需要使用以 00+國家代碼開頭的國際通用格式,例如若要發給英國的號碼 07920 110 000 需使用 00447920110000 作為收件人手機號碼(至多17位數)。需發送給多個收件人手機號碼時可使用英文逗號分隔,每次請求最 多250 00個收件人手機號碼。", "threemaRecipient": "收件人", "threemaRecipientTypeIdentityFormat": "8 位字符", - "PushPlusPlus Token": "PushPlusPlus Token" + "PushPlus Token": "PushPlus Token" } diff --git a/src/lang/zh-TW.json b/src/lang/zh-TW.json index 98392b648..c93913806 100644 --- a/src/lang/zh-TW.json +++ b/src/lang/zh-TW.json @@ -1086,5 +1086,5 @@ "Separate multiple email addresses with commas": "用逗號分隔多個電子郵件地址", "record": "記錄", "New Group": "新分組", - "PushPlusPlus Token": "PushPlusPlus Token" + "PushPlus Token": "PushPlus Token" }