From 44f0e09f8ea39d14ffd164be67dce24fb23ea997 Mon Sep 17 00:00:00 2001 From: Kylin Date: Tue, 27 Aug 2024 18:11:34 +0800 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20websocket=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=89=8D=E7=AB=AF=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit websocket的通知部分前端代码. --- src/api/notice-status.ts | 73 +++ src/api/notice.ts | 141 ++++++ src/enums/MessageTypeEnum.ts | 4 +- .../NavBar/components/NavbarAction.vue | 59 ++- src/views/system/notice-status/index.vue | 249 +++++++++ src/views/system/notice/index.vue | 478 ++++++++++++++++++ 6 files changed, 1000 insertions(+), 4 deletions(-) create mode 100644 src/api/notice-status.ts create mode 100644 src/api/notice.ts create mode 100644 src/views/system/notice-status/index.vue create mode 100644 src/views/system/notice/index.vue diff --git a/src/api/notice-status.ts b/src/api/notice-status.ts new file mode 100644 index 00000000..03433c37 --- /dev/null +++ b/src/api/notice-status.ts @@ -0,0 +1,73 @@ +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 {} + +/** 用户公告状态表单对象 */ +export interface NoticeStatusForm {} + +/** 用户公告状态分页对象 */ +export interface NoticeStatusPageVO {} diff --git a/src/api/notice.ts b/src/api/notice.ts new file mode 100644 index 00000000..cb73bff0 --- /dev/null +++ b/src/api/notice.ts @@ -0,0 +1,141 @@ +import request from "@/utils/request"; + +const NOTICE_BASE_URL = "/api/v1/notices"; + +class NoticeAPI { + /** 获取通知公告分页数据 */ + static getPage(queryParams?: NoticePageQuery) { + return request>({ + url: `${NOTICE_BASE_URL}/page`, + method: "get", + params: queryParams, + }); + } + + /** + * 获取通知公告表单数据 + * + * @param id NoticeID + * @returns Notice表单数据 + */ + static getFormData(id: number) { + return request({ + url: `${NOTICE_BASE_URL}/${id}/form`, + method: "get", + }); + } + + /** 添加通知公告*/ + static add(data: NoticeForm) { + return request({ + url: `${NOTICE_BASE_URL}`, + method: "post", + data: data, + }); + } + + /** + * 更新通知公告 + * + * @param id NoticeID + * @param data Notice表单数据 + */ + static update(id: number, data: NoticeForm) { + return request({ + url: `${NOTICE_BASE_URL}/${id}`, + method: "put", + data: data, + }); + } + + /** + * 批量删除通知公告,多个以英文逗号(,)分割 + * + * @param ids 通知公告ID字符串,多个以英文逗号(,)分割 + */ + static deleteByIds(ids: string) { + return request({ + url: `${NOTICE_BASE_URL}/${ids}`, + method: "delete", + }); + } +} + +export default NoticeAPI; + +/** 通知公告分页查询参数 */ +export interface NoticePageQuery extends PageQuery { + id?: bigint; + /** 通知标题 */ + title?: string; + /** 通知内容 */ + content?: string; + /** 通知类型 */ + noticeType?: number; + /** 发布人 */ + releaseBy?: bigint; + /** 优先级(0-低 1-中 2-高) */ + priority?: number; + /** 目标类型(0-全体 1-指定) */ + tarType?: number; + /** 发布状态(0-未发布 1已发布 2已撤回) */ + sendStatus?: number; + /** 发布时间 */ + sendTime?: [string, string]; + /** 撤回时间 */ + recallTime?: [string, string]; + /** 创建时间 */ + createTime?: Date; + /** 更新时间 */ + updateTime?: Date; +} + +/** 通知公告表单对象 */ +export interface NoticeForm { + id?: bigint; + /** 通知标题 */ + title?: string; + /** 通知内容 */ + content?: string; + /** 通知类型 */ + noticeType?: number; + /** 发布人 */ + releaseBy?: bigint; + /** 优先级(0-低 1-中 2-高) */ + priority?: number; + /** 目标类型(0-全体 1-指定) */ + tarType?: number; + /** 发布状态(0-未发布 1已发布 2已撤回) */ + sendStatus?: number; + /** 发布时间 */ + sendTime?: Date; + /** 撤回时间 */ + recallTime?: Date; +} + +/** 通知公告分页对象 */ +export interface NoticePageVO { + id?: bigint; + /** 通知标题 */ + title?: string; + /** 通知内容 */ + content?: string; + /** 通知类型 */ + noticeType?: number; + /** 发布人 */ + releaseBy?: bigint; + /** 优先级(0-低 1-中 2-高) */ + priority?: number; + /** 目标类型(0-全体 1-指定) */ + tarType?: number; + /** 发布状态(0-未发布 1已发布 2已撤回) */ + sendStatus?: number; + /** 发布时间 */ + sendTime?: Date; + /** 撤回时间 */ + recallTime?: Date; + /** 创建时间 */ + createTime?: Date; + /** 更新时间 */ + updateTime?: Date; +} diff --git a/src/enums/MessageTypeEnum.ts b/src/enums/MessageTypeEnum.ts index 42a6fb94..5dbefb41 100644 --- a/src/enums/MessageTypeEnum.ts +++ b/src/enums/MessageTypeEnum.ts @@ -10,6 +10,6 @@ export const enum MessageTypeEnum { export const MessageTypeLabels = { [MessageTypeEnum.MESSAGE]: "消息", - [MessageTypeEnum.NOTICE]: "通知", - [MessageTypeEnum.TODO]: "待办", + // [MessageTypeEnum.NOTICE]: "通知", + // [MessageTypeEnum.TODO]: "待办", }; diff --git a/src/layout/components/NavBar/components/NavbarAction.vue b/src/layout/components/NavBar/components/NavbarAction.vue index f1b79e2d..3f6a4273 100644 --- a/src/layout/components/NavBar/components/NavbarAction.vue +++ b/src/layout/components/NavBar/components/NavbarAction.vue @@ -55,7 +55,9 @@
查看更多 - + + + 全部已读 @@ -114,6 +116,8 @@ import { import defaultSettings from "@/settings"; import { DeviceEnum } from "@/enums/DeviceEnum"; import { MessageTypeEnum, MessageTypeLabels } from "@/enums/MessageTypeEnum"; +import { Client } from "@stomp/stompjs"; +import { TOKEN_KEY } from "@/enums/CacheEnum"; const appStore = useAppStore(); const tagsViewStore = useTagsViewStore(); @@ -122,7 +126,8 @@ const settingStore = useSettingsStore(); const route = useRoute(); const router = useRouter(); - +const isConnected = ref(false); +const socketEndpoint = ref(import.meta.env.VITE_APP_WS_ENDPOINT); const isMobile = computed(() => appStore.device === DeviceEnum.MOBILE); const { isFullscreen, toggle } = useFullscreen(); @@ -192,6 +197,56 @@ function logout() { }); }); } + +let stompClient: Client; + +function connectWebSocket() { + stompClient = new Client({ + brokerURL: socketEndpoint.value, + connectHeaders: { + Authorization: localStorage.getItem(TOKEN_KEY) || "", + }, + debug: (str) => { + console.log(str); + }, + onConnect: () => { + console.log("连接成功"); + isConnected.value = true; + messages.value.push({ + sender: "Server", + content: "Websocket 已连接", + type: "tip", + }); + // 订阅 /topic/chat 主题 + stompClient.subscribe("/topic/chat", (res) => { + debugger; + console.log("收到消息:" + res.body); + // messages.value.push({ + // sender: "Server", + // content: res.body, + // }); + }); + }, + onStompError: (frame) => { + console.error("Broker reported error: " + frame.headers["message"]); + console.error("Additional details: " + frame.body); + }, + onDisconnect: () => { + isConnected.value = false; + messages.value.push({ + sender: "Server", + content: "Websocket 已断开", + type: "tip", + }); + }, + }); + + stompClient.activate(); +} + +onMounted(() => { + connectWebSocket(); +}); From d0f31715c415f5e92c46409581ca2570764b6159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com> Date: Mon, 2 Sep 2024 16:25:00 +0800 Subject: [PATCH 05/11] =?UTF-8?q?wip:=20:construction:=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=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 通知公告临时提交 --- .../NavBar/components/NavbarAction.vue | 33 +++---------------- src/views/system/notice/index.vue | 4 +-- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/layout/components/NavBar/components/NavbarAction.vue b/src/layout/components/NavBar/components/NavbarAction.vue index def658a2..3ac541a7 100644 --- a/src/layout/components/NavBar/components/NavbarAction.vue +++ b/src/layout/components/NavBar/components/NavbarAction.vue @@ -201,6 +201,7 @@ function logout() { let stompClient: Client; function connectWebSocket() { + console.log("连接消息ws的url:" + socketEndpoint.value); stompClient = new Client({ brokerURL: socketEndpoint.value, connectHeaders: { @@ -210,32 +211,11 @@ function connectWebSocket() { console.log(str); }, onConnect: () => { - console.log("连接成功"); + console.log("消息ws连接成功"); isConnected.value = true; - // messages.value.push({ - // sender: "Server", - // content: "Websocket 已连接", - // type: "tip", - // }); - // 订阅 /topic/chat 主题 - while (messages.value.length > 3) { - messages.value.shift(); - } - stompClient.subscribe("/topic/chat", (res) => { + + stompClient.subscribe("/user/queue/message", (res) => { console.log("收到消息:" + res.body); - const message = JSON.parse(res.body); - console.log("当前有:" + message.id); - console.log("数组已更新,强制重新渲染"); - messages.value.push({ - id: message.id, - title: message.title, - type: MessageTypeEnum.MESSAGE, - }); - while (messages.value.length > 3) { - messages.value.shift(); - } - console.log("当前还有:" + messages.value); - nextTick(async () => {}); }); }, onStompError: (frame) => { @@ -244,11 +224,6 @@ function connectWebSocket() { }, onDisconnect: () => { isConnected.value = false; - // messages.value.push({ - // sender: "Server", - // content: "Websocket 已断开", - // type: "tip", - // }); }, }); diff --git a/src/views/system/notice/index.vue b/src/views/system/notice/index.vue index 385d7b5f..1bc4dc3b 100644 --- a/src/views/system/notice/index.vue +++ b/src/views/system/notice/index.vue @@ -69,6 +69,7 @@ @selection-change="handleSelectionChange" > + From 35a419ff8b6b2430c41f7f5284cf8ed37ba97048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com> Date: Thu, 5 Sep 2024 17:10:29 +0800 Subject: [PATCH 06/11] =?UTF-8?q?wip:=20:construction:=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=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 通知公告临时提交 --- src/api/notice.ts | 11 ++ src/components/Notice/index.vue | 138 ++++++++++++++++++ .../NavBar/components/NavbarAction.vue | 127 +--------------- src/types/components.d.ts | 1 + 4 files changed, 151 insertions(+), 126 deletions(-) create mode 100644 src/components/Notice/index.vue diff --git a/src/api/notice.ts b/src/api/notice.ts index fd33b6e8..a395fff0 100644 --- a/src/api/notice.ts +++ b/src/api/notice.ts @@ -89,6 +89,17 @@ class NoticeAPI { method: "patch", }); } + + /** + * 获取我的通知公告n条 + * @returns 消息 + */ + static listNotice() { + return request({ + url: `${NOTICE_BASE_URL}/notice/5`, + method: "get", + }); + } } export default NoticeAPI; diff --git a/src/components/Notice/index.vue b/src/components/Notice/index.vue new file mode 100644 index 00000000..500fb6a6 --- /dev/null +++ b/src/components/Notice/index.vue @@ -0,0 +1,138 @@ + + diff --git a/src/layout/components/NavBar/components/NavbarAction.vue b/src/layout/components/NavBar/components/NavbarAction.vue index 3ac541a7..339fbb2d 100644 --- a/src/layout/components/NavBar/components/NavbarAction.vue +++ b/src/layout/components/NavBar/components/NavbarAction.vue @@ -23,49 +23,7 @@ - - -
- -
-
- -
+ @@ -115,9 +73,6 @@ import { } from "@/store"; import defaultSettings from "@/settings"; import { DeviceEnum } from "@/enums/DeviceEnum"; -import { MessageTypeEnum, MessageTypeLabels } from "@/enums/MessageTypeEnum"; -import { Client } from "@stomp/stompjs"; -import { TOKEN_KEY } from "@/enums/CacheEnum"; const appStore = useAppStore(); const tagsViewStore = useTagsViewStore(); @@ -126,54 +81,10 @@ const settingStore = useSettingsStore(); const route = useRoute(); const router = useRouter(); -const isConnected = ref(false); -const socketEndpoint = ref(import.meta.env.VITE_APP_WS_ENDPOINT); const isMobile = computed(() => appStore.device === DeviceEnum.MOBILE); const { isFullscreen, toggle } = useFullscreen(); -const activeTab = ref(MessageTypeEnum.MESSAGE); - -const messages = ref([ - { - id: 1, - title: "系统升级通知:服务器将于今晚12点进行升级维护,请提前保存工作内容。", - type: MessageTypeEnum.MESSAGE, - }, - { - id: 2, - title: "新功能发布:我们的应用程序现在支持多语言功能。", - type: MessageTypeEnum.MESSAGE, - }, - { - id: 3, - title: "重要提醒:请定期更改您的密码以保证账户安全。", - type: MessageTypeEnum.MESSAGE, - }, - // { - // id: 4, - // title: "通知:您有一条未读的系统消息,请及时查看。", - // type: MessageTypeEnum.NOTICE, - // }, - // { - // id: 5, - // title: "新订单通知:您有一笔新的订单需要处理。", - // type: MessageTypeEnum.NOTICE, - // }, - // { - // id: 6, - // title: "审核提醒:您的审核请求已被批准。", - // type: MessageTypeEnum.NOTICE, - // }, - // { id: 7, title: "待办事项:完成用户权限设置。", type: MessageTypeEnum.TODO }, - // { id: 8, title: "待办事项:更新产品列表。", type: MessageTypeEnum.TODO }, - // { id: 9, title: "待办事项:备份数据库。", type: MessageTypeEnum.TODO }, -]); - -const getFilteredMessages = (type: MessageTypeEnum) => { - return messages.value.filter((message) => message.type === type); -}; - /** 打开个人中心 */ function handleOpenUserProfile() { router.push({ name: "Profile" }); @@ -197,42 +108,6 @@ function logout() { }); }); } - -let stompClient: Client; - -function connectWebSocket() { - console.log("连接消息ws的url:" + socketEndpoint.value); - stompClient = new Client({ - brokerURL: socketEndpoint.value, - connectHeaders: { - Authorization: localStorage.getItem(TOKEN_KEY) || "", - }, - debug: (str) => { - console.log(str); - }, - onConnect: () => { - console.log("消息ws连接成功"); - isConnected.value = true; - - stompClient.subscribe("/user/queue/message", (res) => { - console.log("收到消息:" + res.body); - }); - }, - onStompError: (frame) => { - console.error("Broker reported error: " + frame.headers["message"]); - console.error("Additional details: " + frame.body); - }, - onDisconnect: () => { - isConnected.value = false; - }, - }); - - stompClient.activate(); -} - -onMounted(() => { - connectWebSocket(); -}); 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 @@ From f34df2bb400d9fb85f73680ccfc3d1aa824e79a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com> Date: Thu, 12 Sep 2024 18:10:38 +0800 Subject: [PATCH 09/11] =?UTF-8?q?wip:=20:construction:=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=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 通知公告临时提交 --- src/api/notice.ts | 8 ++ src/components/Notice/index.vue | 12 ++- src/views/notice/index.vue | 170 +------------------------------- 3 files changed, 19 insertions(+), 171 deletions(-) diff --git a/src/api/notice.ts b/src/api/notice.ts index 6ccd44b0..f9ffb366 100644 --- a/src/api/notice.ts +++ b/src/api/notice.ts @@ -132,6 +132,14 @@ class NoticeAPI { method: "PATCH", }); } + + static getMyNoticePage(queryParams?: NoticePageQuery) { + return request>({ + url: `${NOTICE_BASE_URL}/my/page`, + method: "get", + params: queryParams, + }); + } } export default NoticeAPI; diff --git a/src/components/Notice/index.vue b/src/components/Notice/index.vue index aa3d68be..7247e5d4 100644 --- a/src/components/Notice/index.vue +++ b/src/components/Notice/index.vue @@ -70,10 +70,12 @@ import NoticeModal from "@/components/NoticeModal/index.vue"; const activeTab = ref(MessageTypeEnum.MESSAGE); const messages = ref([]); const noticeModalRef = ref(null); -const offset = ref<["number", "number"]>([-15, 15] as ["number", "number"]); +const offset = ref([-15, 15]); const getFilteredMessages = (type: MessageTypeEnum) => { - return messages.value.filter((message) => message.type === type); + return messages.value.filter( + (message: { type: MessageTypeEnum }) => message.type === type + ); }; /**' @@ -91,7 +93,7 @@ function connectWebSocket() { //获取到id let id = content.id; //确认messages里面是否有这个id - let index = messages.value.findIndex((item) => item.id === id); + let index = messages.value.findIndex((item: any) => item.id === id); if (index < 0) { let messageContent = { id: id, @@ -120,7 +122,9 @@ function listNotice() { * @param id */ function readNotice(id: number) { - let index = messages.value.findIndex((item) => item.id === id); + let index = messages.value.findIndex( + (item: { id: number }) => item.id === id + ); if (index >= 0) { messages.value.splice(index, 1); } diff --git a/src/views/notice/index.vue b/src/views/notice/index.vue index a0f7b12a..5957d303 100644 --- a/src/views/notice/index.vue +++ b/src/views/notice/index.vue @@ -10,28 +10,6 @@ @keyup.enter="handleQuery()" /> - - - - - - - - - - @@ -89,7 +67,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 全体 - 指定 - - - - - - - - - - - 未发布 - 已发布 - 已撤回 - - - - - - - - - - -
@@ -250,7 +111,7 @@ import NoticeAPI, { } from "@/api/notice"; const queryFormRef = ref(ElForm); -const dataFormRef = ref(ElForm); +const pageData = ref([]); const loading = ref(false); const ids = ref([]); @@ -261,35 +122,10 @@ const queryParams = reactive({ pageSize: 10, }); -// 通知公告表格数据 -const pageData = ref([]); - -// 弹窗 -const dialog = reactive({ - title: "", - visible: false, -}); - -// 通知公告表单数据 -const formData = reactive({ - sendStatus: 0, // 默认状态为未发布 - priority: 0, // 默认优先级为低 - tarType: 0, // 默认目标类型为全体 -}); - -// 通知公告表单校验规则 -const rules = reactive({ - title: [{ required: true, message: "请输入通知标题", trigger: "blur" }], - content: [{ required: true, message: "请输入通知内容", trigger: "blur" }], - // releaseBy: [{ required: true, message: "请输入发布人", trigger: "blur" }], - sendTime: [{ required: true, message: "请输入发布时间", trigger: "blur" }], - recallTime: [{ required: true, message: "请输入撤回时间", trigger: "blur" }], -}); - /** 查询通知公告 */ function handleQuery() { loading.value = true; - NoticeAPI.getPage(queryParams) + NoticeAPI.getMyNoticePage(queryParams) .then((data) => { pageData.value = data.list; total.value = data.total; From da2aba757aee7e412387d0567f5fb8dad47a0b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=91=E7=BF=94?= <971366405@qq.com> Date: Sat, 14 Sep 2024 11:06:40 +0800 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E5=8F=91=E9=80=81ws?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增通知公告发送ws消息 --- src/components/Notice/index.vue | 13 ++- .../Sidebar/components/SidebarMenuItem.vue | 2 +- src/views/dashboard/index.vue | 1 - src/views/notice/index.vue | 95 ++----------------- src/views/system/notice/index.vue | 24 +++-- 5 files changed, 39 insertions(+), 96 deletions(-) diff --git a/src/components/Notice/index.vue b/src/components/Notice/index.vue index 7247e5d4..a4ba322c 100644 --- a/src/components/Notice/index.vue +++ b/src/components/Notice/index.vue @@ -40,7 +40,7 @@
- + 查看更多 @@ -66,10 +66,11 @@ import { MessageTypeEnum, MessageTypeLabels } from "@/enums/MessageTypeEnum"; import NoticeAPI from "@/api/notice"; import socket from "@/api/socket"; import NoticeModal from "@/components/NoticeModal/index.vue"; +import router from "@/router"; const activeTab = ref(MessageTypeEnum.MESSAGE); const messages = ref([]); -const noticeModalRef = ref(null); +const noticeModalRef = ref(NoticeModal); const offset = ref([-15, 15]); const getFilteredMessages = (type: MessageTypeEnum) => { @@ -131,6 +132,14 @@ function readNotice(id: number) { noticeModalRef.value?.open(id); // 调用 open 方法,传入 ID } +/** + * 查看更多 + */ +function more() { + //跳转到我的消息页面 + router.push({ path: "notice/notice" }); +} + /** * 全部已读 */ diff --git a/src/layout/components/Sidebar/components/SidebarMenuItem.vue b/src/layout/components/Sidebar/components/SidebarMenuItem.vue index e45ec8d1..b742eadf 100644 --- a/src/layout/components/Sidebar/components/SidebarMenuItem.vue +++ b/src/layout/components/Sidebar/components/SidebarMenuItem.vue @@ -55,7 +55,7 @@ defineOptions({ }); import path from "path-browserify"; -import { isExternal } from "@/utils/index"; +import { isExternal } from "@/utils"; import { RouteRecordRaw } from "vue-router"; const props = defineProps({ diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index bfa301c1..f7d1ce1f 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -391,7 +391,6 @@ const getNoticeLevelTag = (type: number) => { function connectWebSocket() { WebSocketManager.getWebSocketClient("/topic/onlineUserCount", (message) => { - console.log("收到消息:", message); onlineUserCount.value = JSON.parse(message); }); } diff --git a/src/views/notice/index.vue b/src/views/notice/index.vue index 5957d303..f6c68d5e 100644 --- a/src/views/notice/index.vue +++ b/src/views/notice/index.vue @@ -29,8 +29,8 @@ v-loading="loading" :data="pageData" highlight-current-row - @selection-change="handleSelectionChange" > + @@ -95,20 +95,19 @@ @pagination="handleQuery()" /> +