From 79822a990ca9730be26cfcf6e57b9eb6b82ac93b Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 11 Mar 2025 13:28:25 +0800 Subject: [PATCH] feat(vben5): Personal page added notification subscription --- apps/vben5/packages/@abp/account/package.json | 1 + .../components/components/NoticeSettings.vue | 112 +++++++++++++++++- .../@abp/notifications/src/api/index.ts | 1 + .../src/api/useMySubscribesApi.ts | 54 +++++++++ .../@abp/notifications/src/types/index.ts | 2 + .../notifications/src/types/subscribes.ts | 17 +++ 6 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 apps/vben5/packages/@abp/notifications/src/api/useMySubscribesApi.ts create mode 100644 apps/vben5/packages/@abp/notifications/src/types/subscribes.ts diff --git a/apps/vben5/packages/@abp/account/package.json b/apps/vben5/packages/@abp/account/package.json index 4d0588716..16ac1feba 100644 --- a/apps/vben5/packages/@abp/account/package.json +++ b/apps/vben5/packages/@abp/account/package.json @@ -23,6 +23,7 @@ "@abp/core": "workspace:*", "@abp/gdpr": "workspace:*", "@abp/identity": "workspace:*", + "@abp/notifications": "workspace:*", "@abp/request": "workspace:*", "@abp/ui": "workspace:*", "@ant-design/icons-vue": "catalog:", diff --git a/apps/vben5/packages/@abp/account/src/components/components/NoticeSettings.vue b/apps/vben5/packages/@abp/account/src/components/components/NoticeSettings.vue index 80b2914e0..6299b0778 100644 --- a/apps/vben5/packages/@abp/account/src/components/components/NoticeSettings.vue +++ b/apps/vben5/packages/@abp/account/src/components/components/NoticeSettings.vue @@ -1,10 +1,118 @@ diff --git a/apps/vben5/packages/@abp/notifications/src/api/index.ts b/apps/vben5/packages/@abp/notifications/src/api/index.ts index 22f43c9e1..b3dc5aa58 100644 --- a/apps/vben5/packages/@abp/notifications/src/api/index.ts +++ b/apps/vben5/packages/@abp/notifications/src/api/index.ts @@ -1,2 +1,3 @@ export { useMyNotifilersApi } from './useMyNotifilersApi'; +export { useMySubscribesApi } from './useMySubscribesApi'; export { useNotificationsApi } from './useNotificationsApi'; diff --git a/apps/vben5/packages/@abp/notifications/src/api/useMySubscribesApi.ts b/apps/vben5/packages/@abp/notifications/src/api/useMySubscribesApi.ts new file mode 100644 index 000000000..a4e31ce99 --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/api/useMySubscribesApi.ts @@ -0,0 +1,54 @@ +import type { ListResultDto } from '@abp/core'; + +import type { UserSubscreNotification } from '../types/subscribes'; + +import { useRequest } from '@abp/request'; + +export function useMySubscribesApi() { + const { cancel, request } = useRequest(); + + /** + * 获取我的所有订阅通知 + * @returns 订阅通知列表 + */ + function getMySubscribesApi(): Promise< + ListResultDto + > { + return request>( + '/api/notifications/my-subscribes/all', + { + method: 'GET', + }, + ); + } + + /** + * 订阅通知 + * @param name 通知名称 + */ + function subscribeApi(name: string): Promise { + return request('/api/notifications/my-subscribes', { + data: { + name, + }, + method: 'POST', + }); + } + + /** + * 取消订阅通知 + * @param name 通知名称 + */ + function unSubscribeApi(name: string): Promise { + return request(`/api/notifications/my-subscribes?name=${name}`, { + method: 'DELETE', + }); + } + + return { + cancel, + getMySubscribesApi, + subscribeApi, + unSubscribeApi, + }; +} diff --git a/apps/vben5/packages/@abp/notifications/src/types/index.ts b/apps/vben5/packages/@abp/notifications/src/types/index.ts index 3f4e39d55..c07eef088 100644 --- a/apps/vben5/packages/@abp/notifications/src/types/index.ts +++ b/apps/vben5/packages/@abp/notifications/src/types/index.ts @@ -1,2 +1,4 @@ +export * from './definitions'; export * from './my-notifilers'; export * from './notifications'; +export * from './subscribes'; diff --git a/apps/vben5/packages/@abp/notifications/src/types/subscribes.ts b/apps/vben5/packages/@abp/notifications/src/types/subscribes.ts new file mode 100644 index 000000000..3836bf2df --- /dev/null +++ b/apps/vben5/packages/@abp/notifications/src/types/subscribes.ts @@ -0,0 +1,17 @@ +import type { PagedAndSortedResultRequestDto } from '@abp/core'; + +interface UserSubscreNotification { + name: string; +} + +interface UserSubscriptionsResult { + isSubscribed: boolean; +} + +type GetSubscriptionsPagedListInput = PagedAndSortedResultRequestDto; + +export type { + GetSubscriptionsPagedListInput, + UserSubscreNotification, + UserSubscriptionsResult, +};