You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2024-01-17 13:54:43
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2024-01-18 15:37:29
* @FilePath: \General-AI-Platform-Web-Client\mock\alarm.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { MockMethod } from "vite-plugin-mock";
function generateRandomDateTime(year) {
// 生成随机月份1-12
const month = Math.floor(Math.random() * 12) + 1;
// 生成随机日期1-31
const day = Math.floor(Math.random() * 31) + 1;
// 生成随机小时0-23
const hour = Math.floor(Math.random() * 24);
// 生成随机分钟0-59
const minute = Math.floor(Math.random() * 60);
// 生成随机秒钟0-59
const second = Math.floor(Math.random() * 60);
// 返回随机日期和时间的字符串
return `${year}-${month < 10 ? "0" : ""}${month}-${
day < 10 ? "0" : ""
}${day} ${hour < 10 ? "0" : ""}${hour}:${minute < 10 ? "0" : ""}${minute}:${
second < 10 ? "0" : ""
}${second}`;
}
function fetchList(): Record<string, any>[] {
const currList: Record<string, any>[] = [];
// const nameArr = ["玩手机监测", "控制器", "视频监控"];
// const deviceGroupArr = [""]
for (let i = 0; i < 10; i++) {
currList.push({
id: 1,
createTime: generateRandomDateTime(2023),
updateTime: "2023-10-17T02:35:41.14308Z",
name: "表面缺陷",
code: "DC00001",
level: "1",
deviceGroup: "设备组" + parseInt(Math.random() * 10) + 1,
remark: ""
});
}
return currList;
}
export default [
{
url: "/getAlarmList",
method: "post",
response: () => {
return {
success: true,
data: {
list: fetchList()
}
};
}
}
] as MockMethod[];