mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-06 03:30:25 -05:00
✨ feat(api): Telegram
This commit is contained in:
parent
bca0935063
commit
17ce96a423
@ -1,5 +1,5 @@
|
||||
// @ts-ignore
|
||||
|
||||
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as announcement from './announcement';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import useGlobalStore from '@/config/use-global';
|
||||
import { updateUserNotifySetting } from '@/services/user/user';
|
||||
import { bindTelegram, unbindTelegram, updateUserNotifySetting } from '@/services/user/user';
|
||||
import { Button } from '@shadcn/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@shadcn/ui/card';
|
||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@shadcn/ui/form';
|
||||
@ -20,7 +20,7 @@ const FormSchema = z.object({
|
||||
|
||||
export default function NotifySettings() {
|
||||
const t = useTranslations('profile.notify');
|
||||
const { user } = useGlobalStore();
|
||||
const { user, getUserInfo } = useGlobalStore();
|
||||
const form = useForm<z.infer<typeof FormSchema>>({
|
||||
resolver: zodResolver(FormSchema),
|
||||
defaultValues: {
|
||||
@ -59,15 +59,22 @@ export default function NotifySettings() {
|
||||
onChange={(e) => {
|
||||
field.onChange(e.target.value ? Number(e.target.value) : '');
|
||||
}}
|
||||
disabled
|
||||
/>
|
||||
<Button
|
||||
size='sm'
|
||||
type='button'
|
||||
onClick={async () => {
|
||||
form.handleSubmit(onSubmit)();
|
||||
if (user?.telegram) {
|
||||
await unbindTelegram();
|
||||
await getUserInfo();
|
||||
} else {
|
||||
const { data } = await bindTelegram();
|
||||
data.data?.url && window.open(data.data.url, '_blank');
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('bind')}
|
||||
{t(user?.telegram ? 'unbind' : 'bind')}
|
||||
</Button>
|
||||
</div>
|
||||
</FormControl>
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Aktualizace úspěšná"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Připojit",
|
||||
"bind": "Přejít na vazbu",
|
||||
"emailNotification": "E-mailové oznámení",
|
||||
"notificationSettings": "Nastavení oznámení",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Zadejte Telegram ID",
|
||||
"telegramNotification": "Telegram oznámení",
|
||||
"unbind": "Zrušit vazbu",
|
||||
"updateSuccess": "Aktualizace byla úspěšná"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Erfolgreich aktualisiert"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Binden",
|
||||
"bind": "Zur Bindung gehen",
|
||||
"emailNotification": "E-Mail-Benachrichtigung",
|
||||
"notificationSettings": "Benachrichtigungseinstellungen",
|
||||
"telegramId": "Telegram-ID",
|
||||
"telegramIdPlaceholder": "Telegram-ID eingeben",
|
||||
"telegramNotification": "Telegram-Benachrichtigung",
|
||||
"unbind": "Lösen",
|
||||
"updateSuccess": "Erfolgreich aktualisiert"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Update Successful"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Bind",
|
||||
"bind": "Go to Binding",
|
||||
"emailNotification": "Email Notification",
|
||||
"notificationSettings": "Notification Settings",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Enter Telegram ID",
|
||||
"telegramNotification": "Telegram Notification",
|
||||
"unbind": "Unbind",
|
||||
"updateSuccess": "Update Successful"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Actualización exitosa"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Vincular",
|
||||
"bind": "Ir a Vinculación",
|
||||
"emailNotification": "Notificación por correo electrónico",
|
||||
"notificationSettings": "Configuración de notificaciones",
|
||||
"telegramId": "ID de Telegram",
|
||||
"telegramIdPlaceholder": "Ingrese ID de Telegram",
|
||||
"telegramNotification": "Notificación de Telegram",
|
||||
"unbind": "Desvincular",
|
||||
"updateSuccess": "Actualización exitosa"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Actualización exitosa"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Vincular",
|
||||
"bind": "Ir a Vinculación",
|
||||
"emailNotification": "Notificación por correo electrónico",
|
||||
"notificationSettings": "Configuración de notificaciones",
|
||||
"telegramId": "ID de Telegram",
|
||||
"telegramIdPlaceholder": "Ingrese ID de Telegram",
|
||||
"telegramNotification": "Notificación de Telegram",
|
||||
"unbind": "Desvincular",
|
||||
"updateSuccess": "Actualización exitosa"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "بهروزرسانی موفقیتآمیز"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "اتصال",
|
||||
"bind": "رفتن به اتصال",
|
||||
"emailNotification": "اعلان ایمیل",
|
||||
"notificationSettings": "تنظیمات اعلان",
|
||||
"telegramId": "شناسه تلگرام",
|
||||
"telegramIdPlaceholder": "شناسه تلگرام را وارد کنید",
|
||||
"telegramNotification": "اعلان تلگرام",
|
||||
"unbind": "لغو اتصال",
|
||||
"updateSuccess": "بهروزرسانی موفقیتآمیز"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Päivitys onnistui"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Yhdistä",
|
||||
"bind": "Siirry sitomiseen",
|
||||
"emailNotification": "Sähköposti-ilmoitus",
|
||||
"notificationSettings": "Ilmoitusasetukset",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Syötä Telegram ID",
|
||||
"telegramNotification": "Telegram-ilmoitus",
|
||||
"unbind": "Poista sitominen",
|
||||
"updateSuccess": "Päivitys onnistui"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Mise à jour réussie"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Lier",
|
||||
"bind": "Aller à la liaison",
|
||||
"emailNotification": "Notification par e-mail",
|
||||
"notificationSettings": "Paramètres de notification",
|
||||
"telegramId": "ID Telegram",
|
||||
"telegramIdPlaceholder": "Entrez l'ID Telegram",
|
||||
"telegramNotification": "Notification Telegram",
|
||||
"unbind": "Délier",
|
||||
"updateSuccess": "Mise à jour réussie"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "सफलतापूर्वक अपडेट किया गया"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "बाइंड",
|
||||
"bind": "बाइंडिंग पर जाएं",
|
||||
"emailNotification": "ईमेल सूचना",
|
||||
"notificationSettings": "सूचना सेटिंग्स",
|
||||
"telegramId": "टेलीग्राम आईडी",
|
||||
"telegramIdPlaceholder": "टेलीग्राम आईडी दर्ज करें",
|
||||
"telegramNotification": "टेलीग्राम सूचना",
|
||||
"unbind": "अनबाइंड करें",
|
||||
"updateSuccess": "सफलतापूर्वक अपडेट किया गया"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Sikeres frissítés"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Összekapcsolás",
|
||||
"bind": "Menj a kötéshez",
|
||||
"emailNotification": "E-mail értesítés",
|
||||
"notificationSettings": "Értesítési beállítások",
|
||||
"telegramId": "Telegram azonosító",
|
||||
"telegramIdPlaceholder": "Adja meg a Telegram azonosítót",
|
||||
"telegramNotification": "Telegram értesítés",
|
||||
"unbind": "Kötés feloldása",
|
||||
"updateSuccess": "Sikeres frissítés"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "バインド",
|
||||
"bind": "バインディングに移動",
|
||||
"emailNotification": "メール通知",
|
||||
"notificationSettings": "通知設定",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Telegram IDを入力",
|
||||
"telegramNotification": "Telegram通知",
|
||||
"unbind": "バインド解除",
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "업데이트 성공"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "연결",
|
||||
"bind": "바인딩으로 이동",
|
||||
"emailNotification": "이메일 알림",
|
||||
"notificationSettings": "알림 설정",
|
||||
"telegramId": "텔레그램 ID",
|
||||
"telegramIdPlaceholder": "텔레그램 ID 입력",
|
||||
"telegramNotification": "텔레그램 알림",
|
||||
"unbind": "바인딩 해제",
|
||||
"updateSuccess": "업데이트 성공"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Oppdatering vellykket"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Knytt til",
|
||||
"bind": "Gå til binding",
|
||||
"emailNotification": "E-postvarsling",
|
||||
"notificationSettings": "Varslingsinnstillinger",
|
||||
"telegramId": "Telegram-ID",
|
||||
"telegramIdPlaceholder": "Skriv inn Telegram-ID",
|
||||
"telegramNotification": "Telegram-varsling",
|
||||
"unbind": "Løsne",
|
||||
"updateSuccess": "Oppdatering vellykket"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Aktualizacja zakończona sukcesem"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Połącz",
|
||||
"bind": "Przejdź do wiązania",
|
||||
"emailNotification": "Powiadomienie e-mail",
|
||||
"notificationSettings": "Ustawienia powiadomień",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Wprowadź Telegram ID",
|
||||
"telegramNotification": "Powiadomienie Telegram",
|
||||
"unbind": "Odwiąż",
|
||||
"updateSuccess": "Aktualizacja zakończona sukcesem"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Atualização bem-sucedida"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Vincular",
|
||||
"bind": "Ir para Vinculação",
|
||||
"emailNotification": "Notificação por e-mail",
|
||||
"notificationSettings": "Configurações de notificação",
|
||||
"telegramId": "ID do Telegram",
|
||||
"telegramIdPlaceholder": "Insira o ID do Telegram",
|
||||
"telegramNotification": "Notificação do Telegram",
|
||||
"unbind": "Desvincular",
|
||||
"updateSuccess": "Atualização bem-sucedida"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Actualizare reușită"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Conectare",
|
||||
"bind": "Mergi la Legare",
|
||||
"emailNotification": "Notificare prin email",
|
||||
"notificationSettings": "Setări notificări",
|
||||
"telegramId": "ID Telegram",
|
||||
"telegramIdPlaceholder": "Introduceți ID-ul Telegram",
|
||||
"telegramNotification": "Notificare Telegram",
|
||||
"unbind": "Dezleagă",
|
||||
"updateSuccess": "Actualizare reușită"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Успешно обновлено"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Привязать",
|
||||
"bind": "Перейти к привязке",
|
||||
"emailNotification": "Уведомление по электронной почте",
|
||||
"notificationSettings": "Настройки уведомлений",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Введите Telegram ID",
|
||||
"telegramNotification": "Уведомление в Telegram",
|
||||
"unbind": "Отвязать",
|
||||
"updateSuccess": "Успешно обновлено"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "อัปเดตสำเร็จ"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "ผูก",
|
||||
"bind": "ไปที่การผูก",
|
||||
"emailNotification": "การแจ้งเตือนทางอีเมล",
|
||||
"notificationSettings": "การตั้งค่าการแจ้งเตือน",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "กรอก Telegram ID",
|
||||
"telegramNotification": "การแจ้งเตือนทาง Telegram",
|
||||
"unbind": "ยกเลิกการผูก",
|
||||
"updateSuccess": "อัปเดตสำเร็จ"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Güncelleme Başarılı"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Bağla",
|
||||
"bind": "Bağlamaya Git",
|
||||
"emailNotification": "E-posta Bildirimi",
|
||||
"notificationSettings": "Bildirim Ayarları",
|
||||
"telegramId": "Telegram Kimliği",
|
||||
"telegramIdPlaceholder": "Telegram Kimliği girin",
|
||||
"telegramNotification": "Telegram Bildirimi",
|
||||
"unbind": "Bağlamayı Kaldır",
|
||||
"updateSuccess": "Güncelleme Başarılı"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Оновлення успішне"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Прив'язати",
|
||||
"bind": "Перейти до прив'язки",
|
||||
"emailNotification": "Сповіщення електронною поштою",
|
||||
"notificationSettings": "Налаштування сповіщень",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Введіть Telegram ID",
|
||||
"telegramNotification": "Сповіщення Telegram",
|
||||
"unbind": "Відв'язати",
|
||||
"updateSuccess": "Оновлення успішне"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "Cập nhật thành công"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "Liên kết",
|
||||
"bind": "Đi đến Liên kết",
|
||||
"emailNotification": "Thông báo Email",
|
||||
"notificationSettings": "Cài đặt Thông báo",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "Nhập Telegram ID",
|
||||
"telegramNotification": "Thông báo Telegram",
|
||||
"unbind": "Hủy liên kết",
|
||||
"updateSuccess": "Cập nhật thành công"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "绑定",
|
||||
"bind": "前往绑定",
|
||||
"emailNotification": "邮件通知",
|
||||
"notificationSettings": "通知设置",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "输入 Telegram ID",
|
||||
"telegramNotification": "Telegram 通知",
|
||||
"unbind": "解除绑定",
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
@ -9,12 +9,13 @@
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notify": {
|
||||
"bind": "綁定",
|
||||
"bind": "前往綁定",
|
||||
"emailNotification": "郵件通知",
|
||||
"notificationSettings": "通知設定",
|
||||
"telegramId": "Telegram ID",
|
||||
"telegramIdPlaceholder": "輸入 Telegram ID",
|
||||
"telegramNotification": "Telegram 通知",
|
||||
"unbind": "解除綁定",
|
||||
"updateSuccess": "更新成功"
|
||||
},
|
||||
"notifyEvent": {
|
||||
|
||||
5
apps/user/services/user/typings.d.ts
vendored
5
apps/user/services/user/typings.d.ts
vendored
@ -27,6 +27,11 @@ declare namespace API {
|
||||
ios: Application[];
|
||||
};
|
||||
|
||||
type BindTelegramResponse = {
|
||||
url: string;
|
||||
expired_at: number;
|
||||
};
|
||||
|
||||
type CheckoutOrderRequest = {
|
||||
orderNo: string;
|
||||
};
|
||||
|
||||
@ -24,6 +24,17 @@ export async function queryUserBalanceLog(options?: { [key: string]: any }) {
|
||||
);
|
||||
}
|
||||
|
||||
/** Bind Telegram GET /v1/public/user/bind_telegram */
|
||||
export async function bindTelegram(options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.BindTelegramResponse }>(
|
||||
'/v1/public/user/bind_telegram',
|
||||
{
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** Query User Info GET /v1/public/user/info */
|
||||
export async function queryUserInfo(options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: API.User }>('/v1/public/user/info', {
|
||||
@ -87,3 +98,11 @@ export async function queryUserSubscribe(options?: { [key: string]: any }) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** Unbind Telegram POST /v1/public/user/unbind_telegram */
|
||||
export async function unbindTelegram(options?: { [key: string]: any }) {
|
||||
return request<API.Response & { data?: any }>('/v1/public/user/unbind_telegram', {
|
||||
method: 'POST',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user