发布 0.1.0:通知渠道、告警规则与多项体验修复
This commit is contained in:
@@ -8,12 +8,15 @@ import {
|
||||
import { mockOn, mocked, request } from './request'
|
||||
import type {
|
||||
AboutInfo,
|
||||
NotifyChannelItem,
|
||||
NotifyChannelType,
|
||||
NotifyEventsSetting,
|
||||
NotifyTemplateItem,
|
||||
SecuritySetting,
|
||||
SystemLogPage,
|
||||
TaskSetting,
|
||||
TelegramSetting,
|
||||
UpdateNotifyChannelBody,
|
||||
} from '@/types/api'
|
||||
|
||||
export function getTelegramSetting(): Promise<TelegramSetting> {
|
||||
@@ -46,6 +49,37 @@ export function testTelegram(): Promise<void> {
|
||||
return request('/settings/telegram/test', { method: 'POST' })
|
||||
}
|
||||
|
||||
/** 通知渠道(webhook/ntfy/bark/smtp)脱敏视图列表 */
|
||||
export function listNotifyChannels(): Promise<NotifyChannelItem[]> {
|
||||
if (mockOn)
|
||||
return mocked(
|
||||
(['webhook', 'ntfy', 'bark', 'smtp'] as NotifyChannelType[]).map((type) => ({
|
||||
type,
|
||||
enabled: false,
|
||||
secretSet: false,
|
||||
})),
|
||||
)
|
||||
return request<{ items: NotifyChannelItem[] }>('/settings/notify-channels').then((r) => r.items)
|
||||
}
|
||||
|
||||
/** 保存单渠道配置,返回全渠道最新视图 */
|
||||
export function updateNotifyChannel(
|
||||
type: NotifyChannelType,
|
||||
body: UpdateNotifyChannelBody,
|
||||
): Promise<NotifyChannelItem[]> {
|
||||
if (mockOn) return mocked([], 400)
|
||||
return request<{ items: NotifyChannelItem[] }>(`/settings/notify-channels/${type}`, {
|
||||
method: 'PUT',
|
||||
body,
|
||||
}).then((r) => r.items)
|
||||
}
|
||||
|
||||
/** 向指定渠道发送测试消息(用已保存配置,不看启用开关) */
|
||||
export function testNotifyChannel(type: NotifyChannelType): Promise<void> {
|
||||
if (mockOn) return mocked(undefined, 800)
|
||||
return request(`/settings/notify-channels/${type}/test`, { method: 'POST' })
|
||||
}
|
||||
|
||||
export function getNotifyEvents(): Promise<NotifyEventsSetting> {
|
||||
if (mockOn) return mocked({ ...mockNotifyEvents })
|
||||
return request('/settings/notify-events')
|
||||
|
||||
Reference in New Issue
Block a user