diff --git a/web/src/components/PushSetting.js b/web/src/components/PushSetting.js index 4181466..e8f36ec 100644 --- a/web/src/components/PushSetting.js +++ b/web/src/components/PushSetting.js @@ -1,14 +1,6 @@ import React, { useEffect, useState } from 'react'; -import { - Button, - Divider, - Form, - Grid, - Header, - Message, -} from 'semantic-ui-react'; -import { API, removeTrailingSlash, showError, showSuccess } from '../helpers'; -import axios from 'axios'; +import { Button, Form, Grid, Header, Message } from 'semantic-ui-react'; +import { API, showError, showSuccess } from '../helpers'; const PushSetting = () => { let [inputs, setInputs] = useState({ @@ -16,26 +8,6 @@ const PushSetting = () => { username: '', channel: '', token: '', - wechat_test_account_id: '', - wechat_test_account_secret: '', - wechat_test_account_template_id: '', - wechat_test_account_open_id: '', - wechat_corp_account_id: '', - wechat_corp_account_agent_secret: '', - wechat_corp_account_agent_id: '', - wechat_corp_account_user_id: '', - wechat_corp_account_client_type: '', - corp_webhook_url: '', - lark_webhook_url: '', - lark_webhook_secret: '', - ding_webhook_url: '', - ding_webhook_secret: '', - bark_server: '', - bark_secret: '', - client_secret: '', - telegram_bot_token: '', - telegram_chat_id: '', - discord_webhook_url: '', }); let [loading, setLoading] = useState(false); @@ -50,15 +22,9 @@ const PushSetting = () => { if (data.channel === '') { data.channel = 'email'; } - if (data.wechat_corp_account_client_type === '') { - data.wechat_corp_account_client_type = 'plugin'; - } if (data.token === ' ') { data.token = ''; } - if (data.bark_server === '') { - data.bark_server = 'https://api.day.app'; - } setInputs(data); } else { showError(message); @@ -80,47 +46,6 @@ const PushSetting = () => { data.token = ' '; } break; - case 'test': - data.wechat_test_account_id = inputs.wechat_test_account_id; - data.wechat_test_account_secret = inputs.wechat_test_account_secret; - data.wechat_test_account_template_id = - inputs.wechat_test_account_template_id; - data.wechat_test_account_open_id = inputs.wechat_test_account_open_id; - break; - case 'corp_app': - data.wechat_corp_account_id = inputs.wechat_corp_account_id; - data.wechat_corp_account_agent_secret = - inputs.wechat_corp_account_agent_secret; - data.wechat_corp_account_agent_id = inputs.wechat_corp_account_agent_id; - data.wechat_corp_account_user_id = inputs.wechat_corp_account_user_id; - data.wechat_corp_account_client_type = - inputs.wechat_corp_account_client_type; - break; - case 'corp': - data.corp_webhook_url = inputs.corp_webhook_url; - break; - case 'lark': - data.lark_webhook_url = inputs.lark_webhook_url; - data.lark_webhook_secret = inputs.lark_webhook_secret; - break; - case 'ding': - data.ding_webhook_url = inputs.ding_webhook_url; - data.ding_webhook_secret = inputs.ding_webhook_secret; - break; - case 'bark': - data.bark_server = removeTrailingSlash(inputs.bark_server); - data.bark_secret = inputs.bark_secret; - break; - case 'client': - data.client_secret = inputs.client_secret; - break; - case 'telegram': - data.telegram_bot_token = inputs.telegram_bot_token; - data.telegram_chat_id = inputs.telegram_chat_id; - break; - case 'discord': - data.discord_webhook_url = inputs.discord_webhook_url; - break; default: showError(`无效的参数:${which}`); return; @@ -134,9 +59,9 @@ const PushSetting = () => { } }; - const test = async (type) => { + const test = async () => { let res = await API.get( - `/push/${inputs.username}?token=${inputs.token}&channel=${type}&title=消息推送服务&description=配置成功!` + `/push/${inputs.username}?token=${inputs.token}&channel=${inputs.channel}&title=消息推送服务&description=配置成功!` ); const { success, message } = res.data; if (success) { @@ -146,30 +71,6 @@ const PushSetting = () => { } }; - const getTelegramChatId = async () => { - if (inputs.telegram_bot_token === '') { - showError('请先输入 Telegram 机器人令牌!'); - return; - } - let res = await axios.get( - `https://api.telegram.org/bot${inputs.telegram_bot_token}/getUpdates` - ); - const { ok } = res.data; - if (ok) { - let result = res.data.result; - if (result.length === 0) { - showError(`请先向你的机器人发送一条任意消息!`); - } else { - let id = result[0]?.message?.chat?.id; - id = id.toString(); - setInputs((inputs) => ({ ...inputs, telegram_chat_id: id })); - showSuccess('会话 ID 获取成功,请点击保存按钮保存!'); - } - } else { - showError(`发生错误:${res.description}`); - } - }; - return ( @@ -209,375 +110,6 @@ const PushSetting = () => { 保存 - -
- 邮箱设置(email) - 通过邮件进行推送 -
- - 邮件推送方式(email)需要设置邮箱,请前往个人设置页面绑定邮箱地址。 - - - -
- 微信测试号设置(test) - - 通过微信测试号进行推送,点击前往配置: - - 微信公众平台接口测试帐号 - - -
- - 需要新增测试模板,模板标题推荐填写为「消息推送」,模板内容必须填写为 - {' {{'}text.DATA{'}}'}。 - - - - - - - - - - - - -
- 企业微信应用号设置(corp_app) - - 通过企业微信应用号进行推送,点击前往配置: - - 企业微信应用管理 - - -
- - 注意,企业微信要求配置可信 IP,步骤:应用管理 -> 自建 -> 创建应用 -> - 应用设置页面下拉中找到「企业可信 IP」,点击配置 -> 设置可信域名 -> - 在「可调用 - JS-SDK、跳转小程序的可信域名」下面填写一个域名,然后点击「申请校验域名」,根据提示完成校验 - -> 之后填写服务器 IP 地址(此 IP - 地址是消息推送服务所部署在的服务器的 IP - 地址,未必是上面校验域名中记录的 IP 地址)。 - - - - - - - - - - - - - -
- 企业微信群机器人设置(corp) - - 通过企业微信群机器人进行推送,配置流程:选择一个群聊 -> 设置 -> - 群机器人 -> 添加 -> 新建 -> 输入名字,点击添加 -> 点击复制 Webhook - 地址 - -
- - - - - - -
- 飞书群机器人设置(lark) - - 通过飞书群机器人进行推送,飞书桌面客户端的配置流程:选择一个群聊 - -> 设置 -> 群机器人 -> 添加机器人 -> 自定义机器人 -> 添加( - 注意选中「签名校验」)。具体参见: - - 飞书开放文档 - - -
- - - - - - - -
- 钉钉群机器人设置(ding) - - 通过钉钉群机器人进行推送,钉钉桌面客户端的配置流程:选择一个群聊 - -> 群设置 -> 智能群助手 -> 添加机器人(点击右侧齿轮图标) -> - 自定义 -> 添加( - 注意选中「加密」)。具体参见: - - 钉钉开放文档 - - -
- - - - - - - -
- Bark 设置(bark) - - 通过 Bark 进行推送,下载 Bark 后按提示注册设备,之后会看到一个 - URL,例如 https://api.day.app/wrsVSDRANDOM/Body Text - ,其中 wrsVSDRANDOM 就是你的推送 key。 - -
- - - - - - - -
- WebSocket 客户端设置(client) - - 通过 WebSocket - 客户端进行推送,可以使用官方客户端实现,或者根据协议自行实现。官方客户端 - - 详见此处 - - 。 - -
- - - - - - -
- Telegram 机器人设置(telegram) - - 通过 Telegram 机器人进行消息推送。首先向 - - {' '} - Bot Father{' '} - - 申请创建一个新的机器人,之后在下方输入获取到的令牌,然后点击你的机器人,随便发送一条消息,之后点击下方的「获取会话 - ID」按钮,系统将自动为你填写会话 - ID,最后点击保存按钮保存设置即可。 - -
- - - - - - - - -
- Discord 群机器人设置(discord) - - 通过 Discord 群机器人进行推送,配置流程:选择一个 channel -> 设置 - -> 整合 -> 创建 Webhook -> 点击复制 Webhook URL - -
- - - - -
diff --git a/web/src/components/SystemSetting.js b/web/src/components/SystemSetting.js index 442f466..e628dc4 100644 --- a/web/src/components/SystemSetting.js +++ b/web/src/components/SystemSetting.js @@ -112,8 +112,8 @@ const SystemSetting = () => { await updateOption('SMTPAccount', inputs.SMTPAccount); } if ( - originInputs['SMTPPort'] !== inputs.SMTPPort && - inputs.SMTPPort !== '' + originInputs['SMTPPort'] !== inputs.SMTPPort && + inputs.SMTPPort !== '' ) { await updateOption('SMTPPort', inputs.SMTPPort); } @@ -262,23 +262,23 @@ const SystemSetting = () => { label='SMTP 服务器地址' name='SMTPServer' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.SMTPServer} placeholder='例如:smtp.qq.com' /> @@ -287,7 +287,7 @@ const SystemSetting = () => { name='SMTPToken' onChange={handleInputChange} type='password' - autoComplete='off' + autoComplete='new-password' value={inputs.SMTPToken} placeholder='敏感信息不会发送到前端显示' /> @@ -314,7 +314,7 @@ const SystemSetting = () => { label='GitHub Client ID' name='GitHubClientId' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.GitHubClientId} placeholder='输入你注册的 GitHub OAuth APP 的 ID' /> @@ -323,7 +323,7 @@ const SystemSetting = () => { name='GitHubClientSecret' onChange={handleInputChange} type='password' - autoComplete='off' + autoComplete='new-password' value={inputs.GitHubClientSecret} placeholder='敏感信息不会发送到前端显示' /> @@ -351,7 +351,7 @@ const SystemSetting = () => { name='WeChatServerAddress' placeholder='例如:https://yourdomain.com' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.WeChatServerAddress} /> { name='WeChatServerToken' type='password' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.WeChatServerToken} placeholder='敏感信息不会发送到前端显示' /> @@ -367,7 +367,7 @@ const SystemSetting = () => { label='微信公众号二维码图片链接' name='WeChatAccountQRCodeImageURL' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.WeChatAccountQRCodeImageURL} placeholder='输入一个图片链接' /> @@ -391,7 +391,7 @@ const SystemSetting = () => { label='Turnstile Site Key' name='TurnstileSiteKey' onChange={handleInputChange} - autoComplete='off' + autoComplete='new-password' value={inputs.TurnstileSiteKey} placeholder='输入你注册的 Turnstile Site Key' /> @@ -400,7 +400,7 @@ const SystemSetting = () => { name='TurnstileSecretKey' onChange={handleInputChange} type='password' - autoComplete='off' + autoComplete='new-password' value={inputs.TurnstileSecretKey} placeholder='敏感信息不会发送到前端显示' /> diff --git a/web/src/pages/User/EditUser.js b/web/src/pages/User/EditUser.js index b336421..a8d4e7c 100644 --- a/web/src/pages/User/EditUser.js +++ b/web/src/pages/User/EditUser.js @@ -60,7 +60,7 @@ const EditUser = () => { <>
更新用户信息
-
+ { placeholder={'请输入新的用户名'} onChange={handleInputChange} value={username} - autoComplete='off' + autoComplete='new-password' /> @@ -79,7 +79,7 @@ const EditUser = () => { placeholder={'请输入新的密码'} onChange={handleInputChange} value={password} - autoComplete='off' + autoComplete='new-password' /> @@ -89,7 +89,7 @@ const EditUser = () => { placeholder={'请输入新的显示名称'} onChange={handleInputChange} value={display_name} - autoComplete='off' + autoComplete='new-password' /> @@ -97,7 +97,7 @@ const EditUser = () => { label='已绑定的 GitHub 账户' name='github_id' value={github_id} - autoComplete='off' + autoComplete='new-password' placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改' readOnly /> @@ -107,7 +107,7 @@ const EditUser = () => { label='已绑定的微信账户' name='wechat_id' value={wechat_id} - autoComplete='off' + autoComplete='new-password' placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改' readOnly /> @@ -117,7 +117,7 @@ const EditUser = () => { label='已绑定的邮箱账户' name='email' value={email} - autoComplete='off' + autoComplete='new-password' placeholder='此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改' readOnly />