发布 0.1.0:通知渠道、告警规则与多项体验修复
CI / test (push) Successful in 27s
Release / release (push) Successful in 26s

This commit is contained in:
Wang Defa
2026-07-10 17:31:19 +08:00
parent 9d0c116ce3
commit 5464d2dfea
68 changed files with 1604 additions and 359 deletions
+34
View File
@@ -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')