diff --git a/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json index 083b5adf2..e9cbee2ff 100644 --- a/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json +++ b/apps/vben5/apps/app-antd/src/locales/langs/en-US/abp.json @@ -31,6 +31,10 @@ "title": "Settings", "definitions": "Definitions", "system": "System Settings" + }, + "notifications": { + "title": "Notifications", + "myNotifilers": "My Notifilers" } }, "openiddict": { diff --git a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json index 3de89786d..37b0d3bbc 100644 --- a/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json +++ b/apps/vben5/apps/app-antd/src/locales/langs/zh-CN/abp.json @@ -31,6 +31,10 @@ "title": "设置管理", "definitions": "设置定义", "system": "系统设置" + }, + "notifications": { + "title": "通知管理", + "myNotifilers": "我的通知" } }, "openiddict": { diff --git a/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts index d0fa18b44..1b7ec5c4f 100644 --- a/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts +++ b/apps/vben5/apps/app-antd/src/router/routes/modules/abp.ts @@ -157,6 +157,26 @@ const routes: RouteRecordRaw[] = [ path: '/manage/audit-logs', component: () => import('#/views/auditing/audit-logs/index.vue'), }, + { + meta: { + title: $t('abp.manage.notifications.title'), + icon: 'tabler:notification', + }, + name: 'Notifications', + path: '/manage/notifications', + children: [ + { + meta: { + title: $t('abp.manage.notifications.myNotifilers'), + icon: 'ant-design:notification-outlined', + }, + name: 'MyNotifications', + path: '/manage/notifications/my-notifilers', + component: () => + import('#/views/notifications/my-notifilers/index.vue'), + }, + ], + }, ], }, { diff --git a/apps/vben5/apps/app-antd/src/views/notifications/my-notifilers/index.vue b/apps/vben5/apps/app-antd/src/views/notifications/my-notifilers/index.vue new file mode 100644 index 000000000..ed3d7e67b --- /dev/null +++ b/apps/vben5/apps/app-antd/src/views/notifications/my-notifilers/index.vue @@ -0,0 +1,15 @@ + + + diff --git a/apps/vben5/packages/@abp/notifications/src/api/index.ts b/apps/vben5/packages/@abp/notifications/src/api/index.ts index e69de29bb..22f43c9e1 100644 --- a/apps/vben5/packages/@abp/notifications/src/api/index.ts +++ b/apps/vben5/packages/@abp/notifications/src/api/index.ts @@ -0,0 +1,2 @@ +export { useMyNotifilersApi } from './useMyNotifilersApi'; +export { useNotificationsApi } from './useNotificationsApi'; diff --git a/apps/vben5/packages/@abp/notifications/src/api/useMyNotifilersApi.ts b/apps/vben5/packages/@abp/notifications/src/api/useMyNotifilersApi.ts new file mode 100644 index 000000000..c6be6ee73 --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/api/useMyNotifilersApi.ts @@ -0,0 +1,57 @@ +import type { PagedResultDto } from '@abp/core'; + +import type { + GetMyNotifilerPagedListInput, + MarkReadStateInput, + UserNotificationDto, +} from '../types/my-notifilers'; + +import { useRequest } from '@abp/request'; + +export function useMyNotifilersApi() { + const { cancel, request } = useRequest(); + /** + * 获取我的通知列表 + * @param {GetMyNotifilerPagedListInput} input 参数 + * @returns {Promise>} 通知分页列表 + */ + function getMyNotifilersApi( + input?: GetMyNotifilerPagedListInput, + ): Promise> { + return request>( + '/api/notifications/my-notifilers', + { + method: 'GET', + params: input, + }, + ); + } + /** + * 删除我的通知 + * @param {string} id 通知id + * @returns {void} + */ + function deleteMyNotifilerApi(id: string): Promise { + return request(`/api/notifications/my-notifilers/${id}`, { + method: 'DELETE', + }); + } + /** + * 设置通知已读状态 + * @param {MarkReadStateInput} input 参数 + * @returns {void} + */ + function markReadStateApi(input: MarkReadStateInput): Promise { + return request(`/api/notifications/my-notifilers/mark-read-state`, { + data: input, + method: 'PUT', + }); + } + + return { + cancel, + deleteMyNotifilerApi, + getMyNotifilersApi, + markReadStateApi, + }; +} diff --git a/apps/vben5/packages/@abp/notifications/src/api/useNotificationsApi.ts b/apps/vben5/packages/@abp/notifications/src/api/useNotificationsApi.ts new file mode 100644 index 000000000..5934f3d11 --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/api/useNotificationsApi.ts @@ -0,0 +1,76 @@ +import type { ListResultDto } from '@abp/core'; + +import type { + NotificationGroupDto, + NotificationTemplateDto, +} from '../types/definitions'; +import type { + NotificationSendInput, + NotificationTemplateSendInput, +} from '../types/notifications'; + +import { useRequest } from '@abp/request'; + +export function useNotificationsApi() { + const { cancel, request } = useRequest(); + /** + * 获取可用通知列表 + * @returns {Promise>} 可用通知列表 + */ + function getAssignableNotifiersApi(): Promise< + ListResultDto + > { + return request>( + '/api/notifications/assignables', + { + method: 'GET', + }, + ); + } + /** + * 获取可用通知模板列表 + * @returns {Promise>} 可用通知模板列表 + */ + function getAssignableTemplatesApi(): Promise< + ListResultDto + > { + return request>( + '/api/notifications/assignable-templates', + { + method: 'GET', + }, + ); + } + /** + * 发送通知 + * @param input 参数 + * @returns {Promise} + */ + function sendNotiferApi(input: NotificationSendInput): Promise { + return request('/api/notifications/send', { + data: input, + method: 'POST', + }); + } + /** + * 发送模板通知 + * @param input 参数 + * @returns {Promise} + */ + function sendTemplateNotiferApi( + input: NotificationTemplateSendInput, + ): Promise { + return request('/api/notifications/send/template', { + data: input, + method: 'POST', + }); + } + + return { + cancel, + getAssignableNotifiersApi, + getAssignableTemplatesApi, + sendNotiferApi, + sendTemplateNotiferApi, + }; +} diff --git a/apps/vben5/packages/@abp/notifications/src/components/index.ts b/apps/vben5/packages/@abp/notifications/src/components/index.ts index e69de29bb..b7a46cbbc 100644 --- a/apps/vben5/packages/@abp/notifications/src/components/index.ts +++ b/apps/vben5/packages/@abp/notifications/src/components/index.ts @@ -0,0 +1 @@ +export { default as MyNotificationTable } from './my-notifilers/MyNotificationTable.vue'; diff --git a/apps/vben5/packages/@abp/notifications/src/components/my-notifilers/MyNotificationTable.vue b/apps/vben5/packages/@abp/notifications/src/components/my-notifilers/MyNotificationTable.vue new file mode 100644 index 000000000..9611cd7a3 --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/components/my-notifilers/MyNotificationTable.vue @@ -0,0 +1,337 @@ + + + + + diff --git a/apps/vben5/packages/@abp/notifications/src/types/definitions.ts b/apps/vben5/packages/@abp/notifications/src/types/definitions.ts new file mode 100644 index 000000000..4a8425070 --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/types/definitions.ts @@ -0,0 +1,25 @@ +import type { NotificationLifetime, NotificationType } from './notifications'; + +interface NotificationDto { + description: string; + displayName: string; + lifetime: NotificationLifetime; + name: string; + type: NotificationType; +} + +interface NotificationGroupDto { + displayName: string; + name: string; + notifications: NotificationDto[]; +} + +interface NotificationTemplateDto { + content?: string; + culture?: string; + description?: string; + name: string; + title: string; +} + +export type { NotificationDto, NotificationGroupDto, NotificationTemplateDto }; diff --git a/apps/vben5/packages/@abp/notifications/src/types/index.ts b/apps/vben5/packages/@abp/notifications/src/types/index.ts index 9ea5ce778..3f4e39d55 100644 --- a/apps/vben5/packages/@abp/notifications/src/types/index.ts +++ b/apps/vben5/packages/@abp/notifications/src/types/index.ts @@ -1 +1,2 @@ +export * from './my-notifilers'; export * from './notifications'; diff --git a/apps/vben5/packages/@abp/notifications/src/types/my-notifilers.ts b/apps/vben5/packages/@abp/notifications/src/types/my-notifilers.ts new file mode 100644 index 000000000..c7c6f47cc --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/types/my-notifilers.ts @@ -0,0 +1,48 @@ +import type { PagedAndSortedResultRequestDto } from '@abp/core'; + +import type { + NotificationContentType, + NotificationData, + NotificationLifetime, + NotificationReadState, + NotificationSeverity, + NotificationType, +} from './notifications'; + +interface GetMyNotifilerPagedListInput extends PagedAndSortedResultRequestDto { + filter?: string; + /** 已读状态 */ + readState?: NotificationReadState; +} + +interface MarkReadStateInput { + idList: string[]; + state: NotificationReadState; +} + +interface UserNotificationDto { + /** 内容类型 */ + contentType: NotificationContentType; + /** 创建时间 */ + creationTime: Date; + /** 数据 */ + data: NotificationData; + /** Id */ + id: string; + /** 生命周期 */ + lifetime: NotificationLifetime; + /** 名称 */ + name: string; + /** 紧急程度 */ + severity: NotificationSeverity; + /** 阅读状态 */ + state: NotificationReadState; + /** 类型 */ + type: NotificationType; +} + +export type { + GetMyNotifilerPagedListInput, + MarkReadStateInput, + UserNotificationDto, +}; diff --git a/apps/vben5/packages/@abp/notifications/src/types/notifications.ts b/apps/vben5/packages/@abp/notifications/src/types/notifications.ts index a1eeb8b10..710fb18ad 100644 --- a/apps/vben5/packages/@abp/notifications/src/types/notifications.ts +++ b/apps/vben5/packages/@abp/notifications/src/types/notifications.ts @@ -43,39 +43,41 @@ interface UserIdentifier { } interface NotificationSendInput { + /** 当前文化(模板渲染时需要) */ culture?: string; + /** 通知数据 */ data: Dictionary; + /** 通知(模板通知时为模板名称)名称 */ name: string; + /** 紧急程度 */ severity?: NotificationSeverity; + /** 接收人列表 */ toUsers?: UserIdentifier[]; } +type NotificationTemplateSendInput = NotificationSendInput; + interface NotificationInfo { + /** 内容类型 */ contentType: NotificationContentType; + /** 创建时间 */ creationTime: Date; + /** 数据 */ data: NotificationData; + /** Id */ id: string; + /** 生命周期 */ lifetime: NotificationLifetime; + /** 名称 */ name: string; + /** 紧急程度 */ severity: NotificationSeverity; + /** 类型 */ type: NotificationType; } -interface NotificationDto { - description: string; - displayName: string; - lifetime: NotificationLifetime; - name: string; - type: NotificationType; -} - -interface NotificationGroupDto { - displayName: string; - name: string; - notifications: NotificationDto[]; -} - interface Notification { + [key: string]: any; contentType: NotificationContentType; creationTime: Date; data: Record; @@ -91,8 +93,7 @@ interface Notification { export type { Notification, NotificationData, - NotificationDto, - NotificationGroupDto, NotificationInfo, NotificationSendInput, + NotificationTemplateSendInput, };