feat: add Telegram notification settings UI
Some checks failed
Deploy to Production / Build and Test (push) Has been cancelled
Deploy to Production / Deploy to Server (push) Has been cancelled

This commit is contained in:
你的用户名
2025-11-05 02:22:00 +08:00
parent 6108b9c5ed
commit a06a964bab
7 changed files with 21297 additions and 25 deletions

View File

@@ -0,0 +1,70 @@
import { requestClient } from '#/api/request';
export namespace TelegramApi {
export interface NotificationConfig {
id: number;
name: string;
botToken: string;
chatId: string;
notificationTypes: string[];
isEnabled: boolean;
createdAt: string;
updatedAt: string;
}
export interface CreateNotificationConfigParams {
name: string;
botToken: string;
chatId: string;
notificationTypes?: string[];
isEnabled?: boolean;
}
export interface UpdateNotificationConfigParams {
name?: string;
botToken?: string;
chatId?: string;
notificationTypes?: string[];
isEnabled?: boolean;
}
export interface TestNotificationConfigParams {
botToken: string;
chatId: string;
}
}
export function getTelegramNotificationConfigs() {
return requestClient.get<TelegramApi.NotificationConfig[]>(
'/telegram/notifications',
);
}
export function createTelegramNotificationConfig(
data: TelegramApi.CreateNotificationConfigParams,
) {
return requestClient.post<TelegramApi.NotificationConfig>(
'/telegram/notifications',
data,
);
}
export function updateTelegramNotificationConfig(
id: number,
data: TelegramApi.UpdateNotificationConfigParams,
) {
return requestClient.put<TelegramApi.NotificationConfig>(
`/telegram/notifications/${id}`,
data,
);
}
export function deleteTelegramNotificationConfig(id: number) {
return requestClient.delete<{ id: number }>(`/telegram/notifications/${id}`);
}
export function testTelegramNotificationConfig(
data: TelegramApi.TestNotificationConfigParams,
) {
return requestClient.post<{ message: string }>('/telegram/test', data);
}