mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 09:16:36 +08:00
feat: enhance error handling for utils.js
This commit is contained in:
parent
df5d2ca93d
commit
d6284bf6b0
@ -1,7 +1,7 @@
|
|||||||
import { toast } from 'react-toastify';
|
import {toast} from 'react-toastify';
|
||||||
import { toastConstants } from '../constants';
|
import {toastConstants} from '../constants';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { API } from './api';
|
import {API} from './api';
|
||||||
|
|
||||||
const HTMLToastContent = ({ htmlContent }) => {
|
const HTMLToastContent = ({ htmlContent }) => {
|
||||||
return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
|
return <div dangerouslySetInnerHTML={{ __html: htmlContent }} />;
|
||||||
@ -74,6 +74,7 @@ if (isMobile()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function showError(error) {
|
export function showError(error) {
|
||||||
|
if (!error) return;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (error.message) {
|
if (error.message) {
|
||||||
if (error.name === 'AxiosError') {
|
if (error.name === 'AxiosError') {
|
||||||
@ -158,17 +159,7 @@ export function timestamp2string(timestamp) {
|
|||||||
second = '0' + second;
|
second = '0' + second;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
year +
|
year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
|
||||||
'-' +
|
|
||||||
month +
|
|
||||||
'-' +
|
|
||||||
day +
|
|
||||||
' ' +
|
|
||||||
hour +
|
|
||||||
':' +
|
|
||||||
minute +
|
|
||||||
':' +
|
|
||||||
second
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +184,6 @@ export const verifyJSON = (str) => {
|
|||||||
export function shouldShowPrompt(id) {
|
export function shouldShowPrompt(id) {
|
||||||
let prompt = localStorage.getItem(`prompt-${id}`);
|
let prompt = localStorage.getItem(`prompt-${id}`);
|
||||||
return !prompt;
|
return !prompt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPromptShown(id) {
|
export function setPromptShown(id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user