🐛 web缺失函数

This commit is contained in:
Martial BE 2023-12-22 11:16:48 +08:00
parent 5a8fef00e5
commit 89e6b9fe33
No known key found for this signature in database
GPG Key ID: D06C32DF0EDB9084
2 changed files with 10 additions and 1 deletions

View File

@ -140,6 +140,15 @@ export function renderQuota(quota, digits = 2) {
return renderNumber(quota);
}
export const verifyJSON = (str) => {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
};
export function renderNumber(num) {
if (num >= 1000000000) {
return (num / 1000000000).toFixed(1) + 'B';

View File

@ -2,7 +2,7 @@ require('dayjs/locale/zh-cn');
import { useState, useEffect } from 'react';
import SubCard from 'ui-component/cards/SubCard';
import { Stack, FormControl, InputLabel, OutlinedInput, Checkbox, Button, FormControlLabel, TextField } from '@mui/material';
import { showSuccess, showError } from 'utils/common';
import { showSuccess, showError, verifyJSON } from 'utils/common';
import { API } from 'utils/api';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';