Skip to content

Commit cab1609

Browse files
committed
feat(notifications): 实现消息通知功能
- 接入 channels 和 event-types API - 事件类型从接口动态获取,支持展示名称和描述 - 使用 Icon 组件展示钉钉/飞书/企业微信图标 - 添加 secret 字段、名称必填 - 移除 scope 参数 - 整行点击可勾选订阅事件 Made-with: Cursor
1 parent 99178ba commit cab1609

File tree

3 files changed

+491
-120
lines changed

3 files changed

+491
-120
lines changed

frontend/public/iconfont.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/api/Api.ts

Lines changed: 200 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,31 @@ export enum ConstsModelProvider {
6868
ModelProviderGoogle = "Gemini",
6969
}
7070

71+
export enum ConstsNotifyChannelKind {
72+
NotifyChannelDingTalk = "dingtalk",
73+
NotifyChannelFeishu = "feishu",
74+
NotifyChannelWeCom = "wecom",
75+
NotifyChannelWebhook = "webhook",
76+
}
77+
78+
export enum ConstsNotifyEventType {
79+
NotifyEventTaskCreated = "task.created",
80+
NotifyEventTaskEnded = "task.ended",
81+
NotifyEventVMRecycled = "vm.recycled",
82+
NotifyEventVMExpiringSoon = "vm.expiring_soon",
83+
}
84+
85+
export interface ConstsNotifyEventTypeInfo {
86+
description?: string;
87+
name?: string;
88+
type?: ConstsNotifyEventType;
89+
}
90+
91+
export enum ConstsNotifyOwnerType {
92+
NotifyOwnerUser = "user",
93+
NotifyOwnerTeam = "team",
94+
}
95+
7196
export enum ConstsOwnerType {
7297
OwnerTypePrivate = "private",
7398
OwnerTypePublic = "public",
@@ -390,6 +415,22 @@ export interface DomainCreateModelReq {
390415
temperature?: number;
391416
}
392417

418+
export interface DomainCreateNotifyChannelReq {
419+
/**
420+
* 订阅的事件类型
421+
* @minItems 1
422+
*/
423+
event_types: ConstsNotifyEventType[];
424+
headers?: Record<string, string>;
425+
kind: "dingtalk" | "feishu" | "wecom" | "webhook";
426+
/** @maxLength 64 */
427+
name: string;
428+
/** "self" | "team:<uuid>" */
429+
scope: string;
430+
secret?: string;
431+
webhook_url: string;
432+
}
433+
393434
export interface DomainCreateProjectReq {
394435
/** 项目描述 */
395436
description?: string;
@@ -717,6 +758,19 @@ export interface DomainModel {
717758
updated_at?: number;
718759
}
719760

761+
export interface DomainNotifyChannel {
762+
created_at?: number;
763+
enabled?: boolean;
764+
event_types?: ConstsNotifyEventType[];
765+
id?: string;
766+
kind?: ConstsNotifyChannelKind;
767+
name?: string;
768+
owner_id?: string;
769+
owner_type?: ConstsNotifyOwnerType;
770+
scope?: string;
771+
webhook_url?: string;
772+
}
773+
720774
export enum DomainOAuthSiteType {
721775
OAuthSiteTypeDomestic = "domestic",
722776
OAuthSiteTypeInternational = "international",
@@ -1358,6 +1412,16 @@ export interface DomainUpdateModelReq {
13581412
temperature?: number;
13591413
}
13601414

1415+
export interface DomainUpdateNotifyChannelReq {
1416+
enabled?: boolean;
1417+
event_types?: ConstsNotifyEventType[];
1418+
headers?: Record<string, string>;
1419+
name?: string;
1420+
scope?: string;
1421+
secret?: string;
1422+
webhook_url?: string;
1423+
}
1424+
13611425
export interface DomainUpdateProjectReq {
13621426
/** 创建协作者列表 */
13631427
collaborators?: DomainCreateCollaboratorItem[];
@@ -1526,7 +1590,6 @@ export interface GitInChaitinNetAiMonkeycodeMonkeycodeAiEntTypesCondition {
15261590
type?: GitInChaitinNetAiMonkeycodeMonkeycodeAiEntTypesConditionType;
15271591
}
15281592

1529-
/** @format int32 */
15301593
export enum GitInChaitinNetAiMonkeycodeMonkeycodeAiEntTypesConditionStatus {
15311594
ConditionStatusCONDITIONSTATUSUNKNOWN = 0,
15321595
ConditionStatusCONDITIONSTATUSINPROGRESS = 1,
@@ -4434,6 +4497,142 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
44344497
...params,
44354498
}),
44364499

4500+
/**
4501+
* @description 列出当前用户的所有推送渠道及其订阅配置
4502+
*
4503+
* @tags 通知推送
4504+
* @name V1UsersNotifyChannelsList
4505+
* @summary 列出推送渠道
4506+
* @request GET:/api/v1/users/notify/channels
4507+
* @secure
4508+
*/
4509+
v1UsersNotifyChannelsList: (params: RequestParams = {}) =>
4510+
this.request<
4511+
WebResp & {
4512+
data?: DomainNotifyChannel[];
4513+
},
4514+
WebResp
4515+
>({
4516+
path: `/api/v1/users/notify/channels`,
4517+
method: "GET",
4518+
secure: true,
4519+
type: ContentType.Json,
4520+
format: "json",
4521+
...params,
4522+
}),
4523+
4524+
/**
4525+
* @description 创建推送渠道(钉钉/飞书/企业微信/Webhook),同时配置订阅的事件类型
4526+
*
4527+
* @tags 通知推送
4528+
* @name V1UsersNotifyChannelsCreate
4529+
* @summary 创建推送渠道
4530+
* @request POST:/api/v1/users/notify/channels
4531+
* @secure
4532+
*/
4533+
v1UsersNotifyChannelsCreate: (param: DomainCreateNotifyChannelReq, params: RequestParams = {}) =>
4534+
this.request<
4535+
WebResp & {
4536+
data?: DomainNotifyChannel;
4537+
},
4538+
WebResp
4539+
>({
4540+
path: `/api/v1/users/notify/channels`,
4541+
method: "POST",
4542+
body: param,
4543+
secure: true,
4544+
type: ContentType.Json,
4545+
format: "json",
4546+
...params,
4547+
}),
4548+
4549+
/**
4550+
* @description 更新推送渠道配置及订阅的事件类型
4551+
*
4552+
* @tags 通知推送
4553+
* @name V1UsersNotifyChannelsUpdate
4554+
* @summary 更新推送渠道
4555+
* @request PUT:/api/v1/users/notify/channels/{id}
4556+
* @secure
4557+
*/
4558+
v1UsersNotifyChannelsUpdate: (id: string, param: DomainUpdateNotifyChannelReq, params: RequestParams = {}) =>
4559+
this.request<
4560+
WebResp & {
4561+
data?: DomainNotifyChannel;
4562+
},
4563+
WebResp
4564+
>({
4565+
path: `/api/v1/users/notify/channels/${id}`,
4566+
method: "PUT",
4567+
body: param,
4568+
secure: true,
4569+
type: ContentType.Json,
4570+
format: "json",
4571+
...params,
4572+
}),
4573+
4574+
/**
4575+
* @description 删除推送渠道及其关联的订阅
4576+
*
4577+
* @tags 通知推送
4578+
* @name V1UsersNotifyChannelsDelete
4579+
* @summary 删除推送渠道
4580+
* @request DELETE:/api/v1/users/notify/channels/{id}
4581+
* @secure
4582+
*/
4583+
v1UsersNotifyChannelsDelete: (id: string, params: RequestParams = {}) =>
4584+
this.request<WebResp, WebResp>({
4585+
path: `/api/v1/users/notify/channels/${id}`,
4586+
method: "DELETE",
4587+
secure: true,
4588+
type: ContentType.Json,
4589+
format: "json",
4590+
...params,
4591+
}),
4592+
4593+
/**
4594+
* @description 发送测试消息验证渠道配置是否正确
4595+
*
4596+
* @tags 通知推送
4597+
* @name V1UsersNotifyChannelsTestCreate
4598+
* @summary 测试推送渠道
4599+
* @request POST:/api/v1/users/notify/channels/{id}/test
4600+
* @secure
4601+
*/
4602+
v1UsersNotifyChannelsTestCreate: (id: string, params: RequestParams = {}) =>
4603+
this.request<WebResp, WebResp>({
4604+
path: `/api/v1/users/notify/channels/${id}/test`,
4605+
method: "POST",
4606+
secure: true,
4607+
type: ContentType.Json,
4608+
format: "json",
4609+
...params,
4610+
}),
4611+
4612+
/**
4613+
* @description 列出所有支持订阅的事件类型
4614+
*
4615+
* @tags 通知推送
4616+
* @name V1UsersNotifyEventTypesList
4617+
* @summary 列出事件类型
4618+
* @request GET:/api/v1/users/notify/event-types
4619+
* @secure
4620+
*/
4621+
v1UsersNotifyEventTypesList: (params: RequestParams = {}) =>
4622+
this.request<
4623+
WebResp & {
4624+
data?: ConstsNotifyEventTypeInfo[];
4625+
},
4626+
WebResp
4627+
>({
4628+
path: `/api/v1/users/notify/event-types`,
4629+
method: "GET",
4630+
secure: true,
4631+
type: ContentType.Json,
4632+
format: "json",
4633+
...params,
4634+
}),
4635+
44374636
/**
44384637
* @description 密码登录
44394638
*

0 commit comments

Comments
 (0)