/* * @Author: donghao donghao@supervision.ltd * @Date: 2024-03-01 16:34:06 * @LastEditors: donghao donghao@supervision.ltd * @LastEditTime: 2024-03-07 11:44:52 * @FilePath: \General-AI-Platform-Web-Client\mock\screenData.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import { MockMethod } from "vite-plugin-mock"; import { serverListData, serverParamsListData } from "./pools/serverListData"; import { modelListData } from "./pools/modelListData"; import { fetchCurrPageByList, fetchMockSuccessFullByOther } from "./utils/apiMock"; export default [ { url: "/getServerBoxList", method: "post", response: req => { const { page, pageSize } = req.body; // console.log(req); return { ...fetchCurrPageByList({ ...serverListData, data: { ...serverListData.data, page, pageSize: pageSize || 10 } }) }; } }, { url: "/updateServerBoxList", method: "post", response: req => { const { currServerList } = req.body; console.log(currServerList, "currServerList"); const finalServerList = currServerList.map(item => { if (item.isEnabled) { item.progressData = item.progressData.map(itemChild => { switch (itemChild.label) { case "CPU": case "GPU": // eslint-disable-next-line no-case-declarations const randomNumber = Math.random(); // eslint-disable-next-line no-case-declarations const changeNumberValue = 10; // 通过逻辑判断,将随机数转换为正数或负数 // 如果随机数小于0.5,则为负数;否则为正数 // eslint-disable-next-line no-case-declarations const changeNumber = randomNumber < 0.5 ? -changeNumberValue : changeNumberValue; itemChild.percent += changeNumber / 100; if (itemChild.percent >= 1) { itemChild.percent = 1; } if (itemChild.percent <= 0.1) { itemChild.percent = 0.1; } break; default: break; } return itemChild; }); } return item; }); // console.log(req); return fetchMockSuccessFullByOther({ data: finalServerList }); } }, { url: "/getModelBoxList", method: "post", response: req => { const { page, pageSize } = req.body; // console.log(req); return { ...fetchCurrPageByList({ ...modelListData, data: { ...modelListData.data, page, pageSize: pageSize || 10 } }) }; } } ] as MockMethod[];