mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-02 08:17:48 +08:00
Refactor: Remove ant design component (#13143)
### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [x] Refactoring
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Images, SupportedPreviewDocumentTypes } from '@/constants/common';
|
||||
import { UploadFile } from '@/interfaces/antd-compat';
|
||||
import { IReferenceChunk } from '@/interfaces/database/chat';
|
||||
import { IChunk } from '@/interfaces/database/knowledge';
|
||||
import { UploadFile } from 'antd';
|
||||
import { get } from 'lodash';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { FileMimeType } from '@/constants/common';
|
||||
import { UploadFile } from '@/interfaces/antd-compat';
|
||||
import fileManagerService from '@/services/file-manager-service';
|
||||
import { UploadFile } from 'antd';
|
||||
|
||||
export const transformFile2Base64 = (
|
||||
val: any,
|
||||
|
||||
@ -5,7 +5,7 @@ import authorizationUtil, {
|
||||
getAuthorization,
|
||||
redirectToLogin,
|
||||
} from '@/utils/authorization-util';
|
||||
import { notification } from 'antd';
|
||||
import notification from '@/utils/notification';
|
||||
import axios from 'axios';
|
||||
import { convertTheKeysOfTheObjectToSnake } from './common-util';
|
||||
|
||||
|
||||
58
web/src/utils/notification.ts
Normal file
58
web/src/utils/notification.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { ExternalToast, toast } from 'sonner';
|
||||
|
||||
const defaultConfig: ExternalToast = { duration: 4000, position: 'top-right' };
|
||||
|
||||
type NotificationOptions = {
|
||||
message: string;
|
||||
description?: string;
|
||||
duration?: number;
|
||||
};
|
||||
|
||||
const notification = {
|
||||
success: (options: NotificationOptions) => {
|
||||
const messageText = options.description
|
||||
? `${options.message}\n${options.description}`
|
||||
: options.message;
|
||||
toast.success(messageText, {
|
||||
...defaultConfig,
|
||||
duration: options.duration
|
||||
? options.duration * 1000
|
||||
: defaultConfig.duration,
|
||||
});
|
||||
},
|
||||
error: (options: NotificationOptions) => {
|
||||
const messageText = options.description
|
||||
? `${options.message}\n${options.description}`
|
||||
: options.message;
|
||||
toast.error(messageText, {
|
||||
...defaultConfig,
|
||||
duration: options.duration
|
||||
? options.duration * 1000
|
||||
: defaultConfig.duration,
|
||||
});
|
||||
},
|
||||
warning: (options: NotificationOptions) => {
|
||||
const messageText = options.description
|
||||
? `${options.message}\n${options.description}`
|
||||
: options.message;
|
||||
toast.warning(messageText, {
|
||||
...defaultConfig,
|
||||
duration: options.duration
|
||||
? options.duration * 1000
|
||||
: defaultConfig.duration,
|
||||
});
|
||||
},
|
||||
info: (options: NotificationOptions) => {
|
||||
const messageText = options.description
|
||||
? `${options.message}\n${options.description}`
|
||||
: options.message;
|
||||
toast.info(messageText, {
|
||||
...defaultConfig,
|
||||
duration: options.duration
|
||||
? options.duration * 1000
|
||||
: defaultConfig.duration,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default notification;
|
||||
@ -1,3 +1,4 @@
|
||||
import message from '@/components/ui/message';
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import { ResponseType } from '@/interfaces/database/base';
|
||||
import i18n from '@/locales/config';
|
||||
@ -5,7 +6,7 @@ import authorizationUtil, {
|
||||
getAuthorization,
|
||||
redirectToLogin,
|
||||
} from '@/utils/authorization-util';
|
||||
import { message, notification } from 'antd';
|
||||
import notification from '@/utils/notification';
|
||||
import { RequestMethod, extend } from 'umi-request';
|
||||
import { convertTheKeysOfTheObjectToSnake } from './common-util';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user