feat: Extract the code for building categorize operator coordinates to hooks.ts #1739 (#2005)

### What problem does this PR solve?

feat: Extract the code for building categorize operator coordinates to
hooks.ts #1739

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-08-19 19:00:04 +08:00
committed by GitHub
parent 9cfd521d67
commit 85f10f84bd
7 changed files with 115 additions and 77 deletions

View File

@ -9,7 +9,7 @@ import { history } from 'umi';
import { RequestMethod, extend } from 'umi-request';
import { convertTheKeysOfTheObjectToSnake } from './common-util';
const ABORT_REQUEST_ERR_MESSAGE = 'The user aborted a request.';
const FAILED_TO_FETCH = 'Failed to fetch';
const RetcodeMessage = {
200: i18n.t('message.200'),
@ -50,8 +50,11 @@ const errorHandler = (error: {
message: string;
}): Response => {
const { response } = error;
if (error.message === ABORT_REQUEST_ERR_MESSAGE) {
console.log('user abort request');
if (error.message === FAILED_TO_FETCH) {
notification.error({
description: i18n.t('message.networkAnomalyDescription'),
message: i18n.t('message.networkAnomaly'),
});
} else {
if (response && response.status) {
const errorText =
@ -61,11 +64,6 @@ const errorHandler = (error: {
message: `${i18n.t('message.requestError')} ${status}: ${url}`,
description: errorText,
});
} else if (!response) {
notification.error({
description: i18n.t('message.networkAnomalyDescription'),
message: i18n.t('message.networkAnomaly'),
});
}
}
return response;
@ -102,6 +100,7 @@ request.interceptors.response.use(async (response: any, options) => {
if (options.responseType === 'blob') {
return response;
}
const data: ResponseType = await response.clone().json();
if (data.retcode === 401 || data.retcode === 401) {