From 467928f2e238af7ed38cc814acdc6521aae4f51f Mon Sep 17 00:00:00 2001 From: EchoZenith <60392923+EchoZenith@users.noreply.github.com> Date: Sun, 24 May 2026 00:29:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9ETelegram=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=94=AF=E6=8C=81=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E5=8F=91=E9=80=81=E6=97=A5=E6=8A=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增Telegram机器人通知配置项和实现逻辑 2. 重构通知发送逻辑为统一的sendAllNotifications方法 3. 调整日报定时任务时间为23:30,优化日报内容 4. 后台页面新增手动发送日报按钮和相关接口 5. 优化通知提示文案,兼容多通知渠道 --- .env.example | 7 ++- client/src/pages/Dashboard.jsx | 28 ++++++++++- server.js | 85 +++++++++++++++++++++++++++------- 3 files changed, 100 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 97cb225..67c869b 100644 --- a/.env.example +++ b/.env.example @@ -8,7 +8,12 @@ LOGIN_PASSWORD=你的密码 # 选填 - 企业微信群机器人 Webhook URL WECOM_WEBHOOK_URL=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=你的key -# 选填 - 电费余额预警阈值(低于此值时发送企业微信通知,设为0或留空关闭) +# 选填 - Telegram 机器人 Token(从 @BotFather 获取) +TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklmNOPqrstUVwxyz +# 选填 - 接收通知的 Telegram 用户 ID(从 @userinfobot 获取) +TELEGRAM_CHAT_ID=123456789 + +# 选填 - 电费余额预警阈值(低于此值时发送通知,设为0或留空关闭) ALERT_THRESHOLD=20 # 选填 - Cookie 签名密钥 diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsx index f2bfce1..c5f8ffb 100644 --- a/client/src/pages/Dashboard.jsx +++ b/client/src/pages/Dashboard.jsx @@ -86,7 +86,21 @@ export default function Dashboard({ onLogout }) { const res = await fetch('/api/test-notify'); const data = await res.json(); if (data.success) { - message.success('测试消息已发送,请查看企业微信'); + message.success('测试消息已发送,请检查通知渠道'); + } else { + message.error('发送失败'); + } + } catch { + message.error('发送失败'); + } + }; + + const handleSendReport = async () => { + try { + const res = await fetch('/api/send-report'); + const data = await res.json(); + if (data.success) { + message.success('日报已发送'); } else { message.error('发送失败'); } @@ -333,6 +347,18 @@ body { margin: 0; } > 测试通知 +