This commit is contained in:
mtvpls
2026-06-29 22:41:36 +08:00
parent 418d57ae8a
commit c1716615e2
6 changed files with 145 additions and 7 deletions
+9 -1
View File
@@ -13959,6 +13959,7 @@ const TelegramConfigComponent = ({
const [apiBaseUrl, setApiBaseUrl] = useState('');
const [loginEnabled, setLoginEnabled] = useState(true);
const [bindingEnabled, setBindingEnabled] = useState(true);
const [registrationEnabled, setRegistrationEnabled] = useState(false);
const [notificationsEnabled, setNotificationsEnabled] = useState(true);
const [defaultNotifications, setDefaultNotifications] = useState(true);
const [testChatId, setTestChatId] = useState('');
@@ -13974,6 +13975,7 @@ const TelegramConfigComponent = ({
setApiBaseUrl(telegram.apiBaseUrl || '');
setLoginEnabled(telegram.loginEnabled !== false);
setBindingEnabled(telegram.bindingEnabled !== false);
setRegistrationEnabled(telegram.registrationEnabled === true);
setNotificationsEnabled(telegram.notificationsEnabled !== false);
setDefaultNotifications(telegram.defaultNotifications !== false);
}
@@ -13988,6 +13990,7 @@ const TelegramConfigComponent = ({
apiBaseUrl,
loginEnabled,
bindingEnabled,
registrationEnabled,
notificationsEnabled,
defaultNotifications,
});
@@ -14014,7 +14017,10 @@ const TelegramConfigComponent = ({
const handleSetWebhook = async () => {
await withLoading('setTelegramWebhook', async () => {
try {
if (!enabled || !botToken.trim() || !botUsername.trim() || !webhookSecret.trim()) {
if (!enabled) {
throw new Error('请先开启 Telegram Bot');
}
if (!botToken.trim() || !botUsername.trim() || !webhookSecret.trim()) {
throw new Error('请先填写 Bot Token、Bot 用户名 和 Webhook Secret');
}
@@ -14081,6 +14087,7 @@ const TelegramConfigComponent = ({
</h3>
<div className='text-sm text-sky-800 dark:text-sky-200 space-y-1'>
<p> Telegram</p>
<p> Telegram Bot /register </p>
<p> Webhook Telegram Bot API </p>
<p> Bot Token Webhook Secret </p>
</div>
@@ -14136,6 +14143,7 @@ const TelegramConfigComponent = ({
<div className='grid grid-cols-1 sm:grid-cols-2 gap-3 rounded-lg border border-gray-200 p-4 dark:border-gray-700'>
{[
['允许绑定', bindingEnabled, setBindingEnabled],
['允许 Telegram 注册', registrationEnabled, setRegistrationEnabled],
['允许 Telegram 登录', loginEnabled, setLoginEnabled],
['启用 Telegram 通知', notificationsEnabled, setNotificationsEnabled],
['新绑定默认开启通知', defaultNotifications, setDefaultNotifications],