移动home接口

This commit is contained in:
TsMask
2023-09-14 14:51:50 +08:00
parent d0b0d34862
commit 3125b112f7
3 changed files with 48 additions and 85 deletions

47
src/api/index.ts Normal file
View File

@@ -0,0 +1,47 @@
import { request } from '@/plugins/http-fetch';
import { parseDateToStr } from '@/utils/date-utils';
/**
* 查询公告列表
* @param query 查询参数
* @returns object
*/
export async function listMain() {
const result = await request({
url: 'systemManagement/v1/elementType/all/objectType/systemState',
method: 'get',
});
// console.log(result);
let realData = result.data.data;
const mergedData = realData.map((obj: any) => {
// console.log(obj);
const [key, value] = Object.entries(obj)[0];
const ipAddress = (value as any).ipAddress;
const systemState = (value as any).systemState;
const errCode = systemState && systemState['errorCode'];
var time = new Date();
// console.log(key, value);
let mergedObj;
if (errCode === undefined && systemState) {
mergedObj = {
...systemState,
refresh: parseDateToStr(time),
ipAddress: ipAddress,
name: key,
status: '正常',
};
} else {
mergedObj = {
version: '-',
refresh: parseDateToStr(time),
ipAddress: ipAddress,
name: key,
status: '异常',
};
}
return mergedObj;
});
// console.log(mergedData);
// console.log(rowArr)
return mergedData;
}