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; } > 测试通知 +