From 9bb190f224ffc3bd14c346acaf1aae7f2ec7edee Mon Sep 17 00:00:00 2001 From: Theo <971366405@qq.com> Date: Sun, 8 Sep 2024 02:21:58 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20:construction:=20=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通知公告临时提交,快结束了,css实在得学一波 --- src/api/notice-status.ts | 95 ------- src/api/notice.ts | 56 +++- src/api/{WebSocketManager.ts => socket.ts} | 4 +- src/components/Notice/index.vue | 202 +++++++------ src/components/NoticeModal/index.vue | 99 +++++++ src/enums/MessageTypeEnum.ts | 2 +- src/types/components.d.ts | 1 + src/views/dashboard/index.vue | 2 +- src/views/system/notice-status/index.vue | 316 --------------------- 9 files changed, 275 insertions(+), 502 deletions(-) delete mode 100644 src/api/notice-status.ts rename src/api/{WebSocketManager.ts => socket.ts} (97%) create mode 100644 src/components/NoticeModal/index.vue delete mode 100644 src/views/system/notice-status/index.vue diff --git a/src/api/notice-status.ts b/src/api/notice-status.ts deleted file mode 100644 index 93873cab..00000000 --- a/src/api/notice-status.ts +++ /dev/null @@ -1,95 +0,0 @@ -import request from "@/utils/request"; - -const NOTICESTATUS_BASE_URL = "/api/v1/noticeStatuss"; - -class NoticeStatusAPI { - /** 获取用户公告状态分页数据 */ - static getPage(queryParams?: NoticeStatusPageQuery) { - return request>({ - url: `${NOTICESTATUS_BASE_URL}/page`, - method: "get", - params: queryParams, - }); - } - - /** - * 获取用户公告状态表单数据 - * - * @param id NoticeStatusID - * @returns NoticeStatus表单数据 - */ - static getFormData(id: number) { - return request({ - url: `${NOTICESTATUS_BASE_URL}/${id}/form`, - method: "get", - }); - } - - /** 添加用户公告状态*/ - static add(data: NoticeStatusForm) { - return request({ - url: `${NOTICESTATUS_BASE_URL}`, - method: "post", - data: data, - }); - } - - /** - * 更新用户公告状态 - * - * @param id NoticeStatusID - * @param data NoticeStatus表单数据 - */ - static update(id: number, data: NoticeStatusForm) { - return request({ - url: `${NOTICESTATUS_BASE_URL}/${id}`, - method: "put", - data: data, - }); - } - - /** - * 批量删除用户公告状态,多个以英文逗号(,)分割 - * - * @param ids 用户公告状态ID字符串,多个以英文逗号(,)分割 - */ - static deleteByIds(ids: string) { - return request({ - url: `${NOTICESTATUS_BASE_URL}/${ids}`, - method: "delete", - }); - } -} - -export default NoticeStatusAPI; - -/** 用户公告状态分页查询参数 */ -export interface NoticeStatusPageQuery extends PageQuery { - /** id */ - id?: bigint; - /** 公共通知id */ - noticeId?: bigint; - /** 用户id */ - userId?: number; - /** 读取状态,0未读,1已读取 */ - readStatus?: bigint; - /** 用户阅读时间 */ - readTiem?: [string, string]; -} - -/** 用户公告状态表单对象 */ -export interface NoticeStatusForm {} - -/** 用户公告状态分页对象 */ -export interface NoticeStatusPageVO { - /** id */ - id?: bigint; - /** 公共通知id */ - noticeId?: bigint; - /** 用户id */ - userId?: number; - /** 读取状态,0未读,1已读取 */ - readStatus?: bigint; - /** 用户阅读时间 */ - readTiem?: Date; -} diff --git a/src/api/notice.ts b/src/api/notice.ts index a395fff0..6ccd44b0 100644 --- a/src/api/notice.ts +++ b/src/api/notice.ts @@ -83,7 +83,7 @@ class NoticeAPI { * @param id 撤回的通知id * @returns */ - static recallNotice(id: number) { + static recallNotice(id: number): Promise<[]> { return request({ url: `${NOTICE_BASE_URL}/recall/${id}`, method: "patch", @@ -91,15 +91,47 @@ class NoticeAPI { } /** - * 获取我的通知公告n条 + * 获取未读消息 * @returns 消息 */ - static listNotice() { + static listUnreadNotice() { return request({ - url: `${NOTICE_BASE_URL}/notice/5`, + url: `${NOTICE_BASE_URL}/unread`, method: "get", }); } + + /** + * 查看通知 + * @param id + */ + static readNotice(id: number): Promise { + return request({ + url: `${NOTICE_BASE_URL}/read/${id}`, + method: "PATCH", + }); + } + + /** + * 查看通知详情 + * @param id + */ + static getDetail(id: number): Promise { + return request({ + url: `${NOTICE_BASE_URL}/detail/${id}`, + method: "get", + }); + } + + /** + * 全部已读 + */ + static readAllNotice() { + return request({ + url: `${NOTICE_BASE_URL}/readAll`, + method: "PATCH", + }); + } } export default NoticeAPI; @@ -151,3 +183,19 @@ export interface NoticePageVO { /** 撤回时间 */ recallTime?: Date; } + +export interface NoticeDetailVO { + id?: string; + /** 通知标题 */ + title?: string; + /** 通知内容 */ + content?: string; + /** 通知类型 */ + noticeTypeLabel?: number; + /** 发布人 */ + releaseBy?: string; + /** 优先级(0-低 1-中 2-高) */ + priority?: number; + /** 发布时间 */ + releaseTime?: Date; +} diff --git a/src/api/WebSocketManager.ts b/src/api/socket.ts similarity index 97% rename from src/api/WebSocketManager.ts rename to src/api/socket.ts index bc943e37..37038076 100644 --- a/src/api/WebSocketManager.ts +++ b/src/api/socket.ts @@ -5,7 +5,7 @@ const MAX_RETRIES = 3; // 最大重试次数 const RETRY_DELAY_MS = 5000; // 重试延迟时间,单位:毫秒 const HEARTBEAT_INTERVAL = 30000; // 心跳间隔时间,单位:毫秒 -class WebSocketManager { +class Socket { private clients: Map = new Map(); private retryCountMap: Map = new Map(); private subscriptions: Map void)[]> = new Map(); @@ -110,4 +110,4 @@ class WebSocketManager { } } -export default new WebSocketManager(); +export default new Socket(); diff --git a/src/components/Notice/index.vue b/src/components/Notice/index.vue index 5c6603e9..aa3d68be 100644 --- a/src/components/Notice/index.vue +++ b/src/components/Notice/index.vue @@ -1,107 +1,143 @@ diff --git a/src/components/NoticeModal/index.vue b/src/components/NoticeModal/index.vue new file mode 100644 index 00000000..62575329 --- /dev/null +++ b/src/components/NoticeModal/index.vue @@ -0,0 +1,99 @@ + + + diff --git a/src/enums/MessageTypeEnum.ts b/src/enums/MessageTypeEnum.ts index 5dbefb41..071f1b26 100644 --- a/src/enums/MessageTypeEnum.ts +++ b/src/enums/MessageTypeEnum.ts @@ -1,7 +1,7 @@ /* 消息类型枚举 */ export const enum MessageTypeEnum { /* 消息 */ - MESSAGE = "MESSAGE", + MESSAGE = "SYSTEM_MESSAGE", /* 通知 */ NOTICE = "NOTICE", /* 待办 */ diff --git a/src/types/components.d.ts b/src/types/components.d.ts index cd71a592..f947408e 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -75,6 +75,7 @@ declare module "vue" { LangSelect: (typeof import("./../components/LangSelect/index.vue"))["default"]; MenuSearch: (typeof import("./../components/MenuSearch/index.vue"))["default"]; Notice: (typeof import("./../components/Notice/index.vue"))["default"]; + NoticeModal: (typeof import("./../components/NoticeModal/index.vue"))["default"]; LayoutSelect: (typeof import("./../layout/components/Settings/components/LayoutSelect.vue"))["default"]; MultiUpload: (typeof import("./../components/Upload/MultiUpload.vue"))["default"]; NavBar: (typeof import("./../layout/components/NavBar/index.vue"))["default"]; diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 54c72c0a..bfa301c1 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -188,7 +188,7 @@