From aee411607fa5054e375c5dcf79d6b21c2287db92 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 24 Nov 2023 00:33:05 +0800 Subject: [PATCH] =?UTF-8?q?websocket=20=E9=87=8D=E6=96=B0=E5=B0=81?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 1744c6ec6fea5897ee202d42c5e6198285ba09e4) --- .env.base | 4 +- src/api/system/notice/index.ts | 5 + src/locales/zh-CN.ts | 2 +- src/views/infra/webSocket/index.vue | 142 ++++++++++++++++++++-------- src/views/system/notice/index.vue | 17 ++++ 5 files changed, 127 insertions(+), 43 deletions(-) diff --git a/.env.base b/.env.base index fdb26d85..cf433822 100644 --- a/.env.base +++ b/.env.base @@ -4,10 +4,10 @@ NODE_ENV=development VITE_DEV=true # 请求路径 -VITE_BASE_URL='http://localhost:48080' +VITE_BASE_URL='http://127.0.0.1:48080' # 上传路径 -VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' +VITE_UPLOAD_URL='http://127.0.0.1:48080/admin-api/infra/file/upload' # 接口前缀 VITE_API_BASEPATH=/dev-api diff --git a/src/api/system/notice/index.ts b/src/api/system/notice/index.ts index cd420a29..56f624dc 100644 --- a/src/api/system/notice/index.ts +++ b/src/api/system/notice/index.ts @@ -40,3 +40,8 @@ export const updateNoticeApi = (data: NoticeVO) => { export const deleteNoticeApi = (id: number) => { return request.delete({ url: '/system/notice/delete?id=' + id }) } + +// 推送公告 +export const pushNotice = (id: number) => { + return request.post({ url: '/system/notice/push?id=' + id }) +} diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index c76a9755..6346a3d3 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -438,5 +438,5 @@ export default { btn_zoom_out: '缩小', preview: '预览' }, - 'OAuth 2.0': 'OAuth 2.0' + 'OAuth 2.0': 'OAuth 2.0' // 避免菜单名是 OAuth 2.0 时,一直 warn 报错 } diff --git a/src/views/infra/webSocket/index.vue b/src/views/infra/webSocket/index.vue index b5a466c0..bb84af2f 100644 --- a/src/views/infra/webSocket/index.vue +++ b/src/views/infra/webSocket/index.vue @@ -1,5 +1,6 @@ @@ -122,6 +128,17 @@ const handleDetail = async (rowId: number) => { detailData.value = res } +/** 推送按钮操作 */ +const handlePush = async (id: number) => { + try { + // 推送的二次确认 + await message.confirm('是否推送所选中通知?') + // 发起推送 + await NoticeApi.pushNoticeApi(id) + message.success(t('推送成功')) + } catch {} +} + // 提交新增/修改的表单 const submitForm = async () => { const elForm = unref(formRef)?.getElFormRef()