From e732f79fb39ca207464705308c9ee2deb3a79307 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期二, 03 十二月 2024 11:21:41 +0800 Subject: [PATCH] 后台任务状态实时刷新同步后台更改 1. startTime和endTime对象结构修改 2. runTime根据后端逻辑生成runTime --- src/enum/socketMessage.js | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/enum/socketMessage.js b/src/enum/socketMessage.js index 9a7783b..14ea741 100644 --- a/src/enum/socketMessage.js +++ b/src/enum/socketMessage.js @@ -1,17 +1,29 @@ -const messageTypes = [ - { id: 0, value: '0', label: '蹇冭烦鏈哄埗', name: 'heartbeat' }, - { id: 1, value: '1', label: '鍚庡彴浠诲姟', name: 'background_task' }, - { id: 2, value: '2', label: '涓氬姟鏃ュ織', name: 'business_log' } -]; +import { Enum } from './enum'; +const SOCKET_MESSAGE_TYPE = Enum({ + BACKGROUND_TASK: { + id: 1, + value: '1', + label: '鍚庡彴浠诲姟', + name: 'background_task' + }, + BUSINESS_LOG: { id: 2, value: '2', label: '涓氬姟鏃ュ織', name: 'business_log' } +}); /** * 鏍规嵁socket娑堟伅绫诲瀷瀛楁寰楀埌杩欎釜绫诲瀷瀵硅薄 * @param {*} value socket娑堟伅绫诲瀷 * @returns 瀵瑰簲鐨勬秷鎭被鍨嬪璞� */ +/** + * 閫氳繃鍚嶇О鏌ユ壘鏋氫妇绫� + * @param {String} value + * @returns + */ function getByValue(value) { - return messageTypes.find((v) => v.value == value); + for (const type in SOCKET_MESSAGE_TYPE) { + const typeObj = SOCKET_MESSAGE_TYPE[type] + if (typeObj.value == value) { + return typeObj + } + } } -function isHeartbeatMessageByType(type) { - return type == '0'; -} -export { messageTypes, getByValue, isHeartbeatMessageByType }; +export { SOCKET_MESSAGE_TYPE, getByValue }; -- Gitblit v1.9.3