diff --git a/orion-ops-ui/src/api/system/message.ts b/orion-ops-ui/src/api/system/message.ts index e2d60eee..80aa48d6 100644 --- a/orion-ops-ui/src/api/system/message.ts +++ b/orion-ops-ui/src/api/system/message.ts @@ -1,38 +1,74 @@ import axios from 'axios'; -export interface MessageRecord { +/** + * 系统消息查询请求 + */ +export interface MessageQueryRequest { + limit?: number; + maxId?: number; + classify?: string; + queryUnread?: boolean; +} + +/** + * 系统消息查询响应 + */ +export interface MessageRecordResponse { id: number; + classify: string; type: string; + status: number; + relKey: string; title: string; - subTitle: string; - avatar?: string; content: string; - time: string; - status: 0 | 1; - messageType?: number; -} -export type MessageListType = MessageRecord[]; - -export function queryMessageList() { - return axios.post('/api/message/list'); + createTime: number; } -interface MessageStatus { - ids: number[]; +/** + * 查询系统消息列表 + */ +export function getMessageList(request: MessageQueryRequest) { + return axios.post>('/infra/system-message/list', request); } -export function setMessageStatus(data: MessageStatus) { - return axios.post('/api/message/read', data); +/** + * 查询系统消息数量 + */ +export function getMessageCount(queryUnread: boolean) { + return axios.get>('/infra/system-message/count', { params: { queryUnread } }); } -export interface ChatRecord { - id: number; - username: string; - content: string; - time: string; - isCollect: boolean; +/** + * 查询是否有未读消息 + */ +export function checkHasUnreadMessage() { + return axios.get('/infra/system-message/has-unread'); } -export function queryChatList() { - return axios.post('/api/chat/list'); +/** + * 更新系统消息为已读 + */ +export function updateMessageRead(id: number) { + return axios.put('/infra/system-message/read', undefined, { params: { id } }); +} + +/** + * 更新全部系统消息为已读 + */ +export function updateMessageReadAll(classify: string) { + return axios.put('/infra/system-message/read-all', undefined, { params: { classify } }); +} + +/** + * 删除系统消息 + */ +export function deleteMessage(id: number) { + return axios.delete('/infra/system-message/delete', { params: { id } }); +} + +/** + * 清理已读的系统消息 + */ +export function clearMessage(classify: string) { + return axios.delete('/infra/system-message/clear', { params: { classify } }); } diff --git a/orion-ops-ui/src/components/exec/log/panel/index.vue b/orion-ops-ui/src/components/exec/log/panel/index.vue index e869873f..0953a709 100644 --- a/orion-ops-ui/src/components/exec/log/panel/index.vue +++ b/orion-ops-ui/src/components/exec/log/panel/index.vue @@ -44,7 +44,7 @@ const logViewRef = ref(); const currentHostExecId = ref(); - const statusIntervalId = ref(); + const pullIntervalId = ref(); const execLog = ref(); const appender = ref(); @@ -57,9 +57,9 @@ if (record.status === execStatus.WAITING || record.status === execStatus.RUNNING) { // 等待一秒后先查询一下状态 - setTimeout(fetchTaskStatus, 1000); + setTimeout(pullExecStatus, 1000); // 注册状态轮询 - statusIntervalId.value = setInterval(fetchTaskStatus, 5000); + pullIntervalId.value = setInterval(pullExecStatus, 5000); } // 打开日志 nextTick(() => { @@ -68,7 +68,7 @@ }; // 加载状态 - const fetchTaskStatus = async () => { + const pullExecStatus = async () => { if (!execLog.value) { return; } @@ -150,7 +150,7 @@ // 清理轮询 const clearAllInterval = () => { // 关闭状态轮询 - clearInterval(statusIntervalId.value); + clearInterval(pullIntervalId.value); }; // 加载字典值 diff --git a/orion-ops-ui/src/utils/setup-mock.ts b/orion-ops-ui/src/utils/setup-mock.ts index 816ec285..feaafea9 100644 --- a/orion-ops-ui/src/utils/setup-mock.ts +++ b/orion-ops-ui/src/utils/setup-mock.ts @@ -7,12 +7,12 @@ export default ({ mock, setup }: { mock?: boolean; setup: () => void }) => { export const successResponseWrap = (data: unknown) => { return { data, - msg: '请求成功', + msg: 'success', code: 200, }; }; -export const failResponseWrap = (data: unknown, msg: string, code = 5000) => { +export const failResponseWrap = (data: unknown, msg: string, code = 500) => { return { data, msg, diff --git a/orion-ops-ui/src/views/dashboard/workplace/mock.ts b/orion-ops-ui/src/views/dashboard/workplace/mock.ts index ef436f41..e037190f 100644 --- a/orion-ops-ui/src/views/dashboard/workplace/mock.ts +++ b/orion-ops-ui/src/views/dashboard/workplace/mock.ts @@ -7,99 +7,18 @@ import setupMock, { successResponseWrap } from '@/utils/setup-mock'; const textList = [ { key: 1, - clickNumber: '346.3w+', - title: '经济日报:财政政策要精准提升…', + clickNumber: '1w+', + title: 'text...', increases: 35, }, { key: 2, - clickNumber: '324.2w+', - title: '双12遇冷,消费者厌倦了电商平…', + clickNumber: '2w+', + title: 'text...', increases: 22, }, - { - key: 3, - clickNumber: '318.9w+', - title: '致敬坚守战“疫”一线的社区工作…', - increases: 9, - }, - { - key: 4, - clickNumber: '257.9w+', - title: '普高还是职高?家长们陷入选择…', - increases: 17, - }, - { - key: 5, - clickNumber: '124.2w+', - title: '人民快评:没想到“浓眉大眼”的…', - increases: 37, - }, -]; -const imageList = [ - { - key: 1, - clickNumber: '15.3w+', - title: '杨涛接替陆慷出任外交部美大司…', - increases: 15, - }, - { - key: 2, - clickNumber: '12.2w+', - title: '图集:龙卷风袭击美国多州房屋…', - increases: 26, - }, - { - key: 3, - clickNumber: '18.9w+', - title: '52岁大姐贴钱照顾自闭症儿童八…', - increases: 9, - }, - { - key: 4, - clickNumber: '7.9w+', - title: '杭州一家三口公园宿营取暖中毒', - increases: 0, - }, - { - key: 5, - clickNumber: '5.2w+', - title: '派出所副所长威胁市民?警方调…', - increases: 4, - }, -]; -const videoList = [ - { - key: 1, - clickNumber: '367.6w+', - title: '这是今日10点的南京', - increases: 5, - }, - { - key: 2, - clickNumber: '352.2w+', - title: '立陶宛不断挑衅致经济受损民众…', - increases: 17, - }, - { - key: 3, - clickNumber: '348.9w+', - title: '韩国艺人刘在石确诊新冠', - increases: 30, - }, - { - key: 4, - clickNumber: '346.3w+', - title: '关于北京冬奥会,文在寅表态', - increases: 12, - }, - { - key: 5, - clickNumber: '271.2w+', - title: '95后现役军人荣立一等功', - increases: 2, - }, ]; + setupMock({ setup() { Mock.mock(new RegExp('/api/content-data'), () => { @@ -117,13 +36,11 @@ setupMock({ }); Mock.mock(new RegExp('/api/popular/list'), (params: GetParams) => { const { type = 'text' } = qs.parseUrl(params.url).query; - if (type === 'image') { - return successResponseWrap([...videoList]); + if (type === 'text') { + return successResponseWrap([...textList]); + } else { + return successResponseWrap([]); } - if (type === 'video') { - return successResponseWrap([...imageList]); - } - return successResponseWrap([...textList]); }); }, }); diff --git a/orion-ops-ui/src/views/exec/batch-upload/components/upload-panel.vue b/orion-ops-ui/src/views/exec/batch-upload/components/upload-panel.vue index 733a1ec0..e4c81fa9 100644 --- a/orion-ops-ui/src/views/exec/batch-upload/components/upload-panel.vue +++ b/orion-ops-ui/src/views/exec/batch-upload/components/upload-panel.vue @@ -76,7 +76,7 @@ const { loading, setLoading } = useLoading(); - const pullStatusId = ref(); + const pullIntervalId = ref(); const taskId = ref(); const task = ref({} as UploadTaskQueryResponse); const selectedHost = ref(); @@ -266,12 +266,12 @@ // 设置轮询状态 onMounted(() => { - pullStatusId.value = setInterval(pullTaskStatus, 5000); + pullIntervalId.value = setInterval(pullTaskStatus, 5000); }); // 卸载状态查询 onUnmounted(() => { - clearInterval(pullStatusId.value); + clearInterval(pullIntervalId.value); }); diff --git a/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue b/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue index 85cafa0f..3036d1a1 100644 --- a/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue +++ b/orion-ops-ui/src/views/exec/exec-command-log/components/exec-command-log-table.vue @@ -236,7 +236,7 @@ const { loading, setLoading } = useLoading(); const { toOptions, getDictValue } = useDictStore(); - const intervalId = ref(); + const pullIntervalId = ref(); const tableRef = ref(); const selectedKeys = ref([]); const tableRenderData = ref([]); @@ -343,7 +343,7 @@ }; // 加载状态 - const fetchTaskStatus = async () => { + const pullExecStatus = async () => { const unCompleteIdList = tableRenderData.value .filter(s => s.status === execStatus.WAITING || s.status === execStatus.RUNNING) .map(s => s.id); @@ -409,12 +409,12 @@ // 加载数据 fetchTableData(); // 注册状态轮询 - intervalId.value = setInterval(fetchTaskStatus, 10000); + pullIntervalId.value = setInterval(pullExecStatus, 10000); }); onUnmounted(() => { // 卸载状态轮询 - clearInterval(intervalId.value); + clearInterval(pullIntervalId.value); }); diff --git a/orion-ops-ui/src/views/exec/upload-task/components/upload-task-table.vue b/orion-ops-ui/src/views/exec/upload-task/components/upload-task-table.vue index 8bda1598..13b6abb6 100644 --- a/orion-ops-ui/src/views/exec/upload-task/components/upload-task-table.vue +++ b/orion-ops-ui/src/views/exec/upload-task/components/upload-task-table.vue @@ -199,7 +199,7 @@ const { loading, setLoading } = useLoading(); const { toOptions, getDictValue } = useDictStore(); - const intervalId = ref(); + const pullIntervalId = ref(); const selectedKeys = ref([]); const tableRenderData = ref([]); const formModel = reactive({ @@ -264,7 +264,7 @@ }; // 加载状态 - const fetchTaskStatus = async () => { + const pullTaskStatus = async () => { const unCompleteIdList = tableRenderData.value .filter(s => s.status === UploadTaskStatus.WAITING || s.status === UploadTaskStatus.UPLOADING) .map(s => s.id); @@ -311,12 +311,12 @@ // 加载数据 fetchTableData(); // 注册状态轮询 - intervalId.value = setInterval(fetchTaskStatus, 10000); + pullIntervalId.value = setInterval(pullTaskStatus, 10000); }); onUnmounted(() => { // 卸载状态轮询 - clearInterval(intervalId.value); + clearInterval(pullIntervalId.value); }); diff --git a/orion-ops-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts b/orion-ops-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts index 611746e4..ee2f9349 100644 --- a/orion-ops-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts +++ b/orion-ops-ui/src/views/host/terminal/handler/sftp-transfer-manager.ts @@ -14,7 +14,7 @@ export default class SftpTransferManager implements ISftpTransferManager { private run: boolean; - private progressId?: number; + private progressIntervalId?: number; private currentItem?: SftpTransferItem; @@ -136,7 +136,7 @@ export default class SftpTransferManager implements ISftpTransferManager { // 处理消息 this.client.onmessage = this.resolveMessage.bind(this); // 计算传输进度 - this.progressId = setInterval(this.calcProgress.bind(this), 500); + this.progressIntervalId = setInterval(this.calcProgress.bind(this), 500); // 打开后自动传输下一个任务 this.transferNextItem(); } @@ -275,7 +275,7 @@ export default class SftpTransferManager implements ISftpTransferManager { // 重置 run this.run = false; // 关闭传输进度 - clearInterval(this.progressId); + clearInterval(this.progressIntervalId); } } diff --git a/orion-ops-ui/src/views/host/terminal/handler/terminal-session-manager.ts b/orion-ops-ui/src/views/host/terminal/handler/terminal-session-manager.ts index 5463b139..52309f4d 100644 --- a/orion-ops-ui/src/views/host/terminal/handler/terminal-session-manager.ts +++ b/orion-ops-ui/src/views/host/terminal/handler/terminal-session-manager.ts @@ -23,7 +23,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager { private sessions: Record; - private keepAliveTask?: any; + private keepAliveTaskId?: any; private readonly dispatchResizeFn: () => {}; @@ -136,7 +136,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager { // 注册 resize 事件 addEventListen(window, 'resize', this.dispatchResizeFn); // 注册 ping 事件 - this.keepAliveTask = setInterval(() => { + this.keepAliveTaskId = setInterval(() => { this.channel.send(InputProtocol.PING, {}); }, 15000); } @@ -158,10 +158,7 @@ export default class TerminalSessionManager implements ITerminalSessionManager { // 关闭 channel this.channel.close(); // 清除 ping 事件 - if (this.keepAliveTask) { - clearInterval(this.keepAliveTask); - this.keepAliveTask = undefined; - } + clearInterval(this.keepAliveTaskId); // 移除 resize 事件 removeEventListen(window, 'resize', this.dispatchResizeFn); } catch (e) { diff --git a/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue b/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue index 4ea5746c..84dcfcfb 100644 --- a/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue +++ b/orion-ops-ui/src/views/job/exec-job-log/components/exec-job-log-table.vue @@ -217,7 +217,7 @@ const { loading, setLoading } = useLoading(); const { toOptions, getDictValue } = useDictStore(); - const intervalId = ref(); + const pullIntervalId = ref(); const tableRef = ref(); const selectedKeys = ref([]); const tableRenderData = ref([]); @@ -308,7 +308,7 @@ }; // 加载状态 - const fetchTaskStatus = async () => { + const pullJobStatus = async () => { const unCompleteIdList = tableRenderData.value .filter(s => s.status === execStatus.WAITING || s.status === execStatus.RUNNING) .map(s => s.id); @@ -374,12 +374,12 @@ // 加载数据 fetchTableData(); // 注册状态轮询 - intervalId.value = setInterval(fetchTaskStatus, 10000); + pullIntervalId.value = setInterval(pullJobStatus, 10000); }); onUnmounted(() => { // 卸载状态轮询 - clearInterval(intervalId.value); + clearInterval(pullIntervalId.value); });