|
@@ -5,6 +5,7 @@ import { isEqual } from 'lodash-es';
|
|
|
|
|
|
|
|
import { TimeRangeItem, TimePeriodItem } from './types';
|
|
import { TimeRangeItem, TimePeriodItem } from './types';
|
|
|
import { CameraAlgoItem } from '@/api/camera/camera-preview';
|
|
import { CameraAlgoItem } from '@/api/camera/camera-preview';
|
|
|
|
|
+import safeParse from '@/utils/safeParse';
|
|
|
|
|
|
|
|
// export const createDefaultTime = (): TimeRangeItem => {
|
|
// export const createDefaultTime = (): TimeRangeItem => {
|
|
|
// return { id: uid(), value: [dayjs(), dayjs().add(1, 'hour')] as [Dayjs, Dayjs] };
|
|
// return { id: uid(), value: [dayjs(), dayjs().add(1, 'hour')] as [Dayjs, Dayjs] };
|
|
@@ -65,7 +66,7 @@ export const getDetectionTimeJSON = (time?: string): TimeRangeItem[] | null => {
|
|
|
|
|
|
|
|
export const getInferParam = (extra: string | undefined | null) => {
|
|
export const getInferParam = (extra: string | undefined | null) => {
|
|
|
if (!extra) return {};
|
|
if (!extra) return {};
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
const params = extraObj?.inferParams;
|
|
const params = extraObj?.inferParams;
|
|
|
if (!params || (params && params.length == 0)) return {};
|
|
if (!params || (params && params.length == 0)) return {};
|
|
|
return params[0];
|
|
return params[0];
|
|
@@ -73,7 +74,7 @@ export const getInferParam = (extra: string | undefined | null) => {
|
|
|
|
|
|
|
|
export const getMetaValues = (extra: string | undefined | null) => {
|
|
export const getMetaValues = (extra: string | undefined | null) => {
|
|
|
if (!extra) return [];
|
|
if (!extra) return [];
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
const params = extraObj?.inferParams;
|
|
const params = extraObj?.inferParams;
|
|
|
if (!params || (params && params.length == 0)) return [];
|
|
if (!params || (params && params.length == 0)) return [];
|
|
|
const metaObjs = params[0]?.metaObjs;
|
|
const metaObjs = params[0]?.metaObjs;
|
|
@@ -99,7 +100,7 @@ export const getMetaValues = (extra: string | undefined | null) => {
|
|
|
|
|
|
|
|
export const getDetectionTime = (time: string | undefined | null) => {
|
|
export const getDetectionTime = (time: string | undefined | null) => {
|
|
|
if (!time) return [];
|
|
if (!time) return [];
|
|
|
- const timeList = JSON.parse(time);
|
|
|
|
|
|
|
+ const timeList = safeParse(time);
|
|
|
if (!timeList || (timeList && timeList.length === 0)) {
|
|
if (!timeList || (timeList && timeList.length === 0)) {
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
@@ -108,13 +109,13 @@ export const getDetectionTime = (time: string | undefined | null) => {
|
|
|
|
|
|
|
|
export const getInferCode = (extra: string | undefined | null) => {
|
|
export const getInferCode = (extra: string | undefined | null) => {
|
|
|
if (!extra) return '';
|
|
if (!extra) return '';
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
return extraObj?.inferCode || '';
|
|
return extraObj?.inferCode || '';
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const getAlgoType = (extra: string | undefined | null) => {
|
|
export const getAlgoType = (extra: string | undefined | null) => {
|
|
|
if (!extra) return 0;
|
|
if (!extra) return 0;
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
const infers = extraObj?.inferParams;
|
|
const infers = extraObj?.inferParams;
|
|
|
if (!infers || infers.length === 0) return 0;
|
|
if (!infers || infers.length === 0) return 0;
|
|
|
return infers[0]?.algoType || 0;
|
|
return infers[0]?.algoType || 0;
|
|
@@ -122,7 +123,7 @@ export const getAlgoType = (extra: string | undefined | null) => {
|
|
|
|
|
|
|
|
export const getCriticalCounts = (extra: string | undefined | null) => {
|
|
export const getCriticalCounts = (extra: string | undefined | null) => {
|
|
|
if (!extra) return [];
|
|
if (!extra) return [];
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
const infers = extraObj?.inferParams;
|
|
const infers = extraObj?.inferParams;
|
|
|
if (!infers || infers.length === 0) return [];
|
|
if (!infers || infers.length === 0) return [];
|
|
|
return infers[0]?.criticalCounts || [];
|
|
return infers[0]?.criticalCounts || [];
|
|
@@ -149,7 +150,7 @@ interface CommonInfo {
|
|
|
|
|
|
|
|
const getCommonInfo = (extra: string | undefined | null): CommonInfo => {
|
|
const getCommonInfo = (extra: string | undefined | null): CommonInfo => {
|
|
|
if (!extra) return {};
|
|
if (!extra) return {};
|
|
|
- const extraObj = JSON.parse(extra);
|
|
|
|
|
|
|
+ const extraObj = safeParse(extra);
|
|
|
const params = extraObj?.inferParams;
|
|
const params = extraObj?.inferParams;
|
|
|
if (!params || (params && params.length == 0)) return {};
|
|
if (!params || (params && params.length == 0)) return {};
|
|
|
const regionJudge = params[0]?.regionJudge;
|
|
const regionJudge = params[0]?.regionJudge;
|