mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
30 lines
656 B
TypeScript
30 lines
656 B
TypeScript
import { useToast as uToast, UseToastOptions } from '@chakra-ui/react';
|
|
import { CSSProperties, useCallback } from 'react';
|
|
|
|
export const useToast = (props?: UseToastOptions & { containerStyle?: CSSProperties }) => {
|
|
const { containerStyle, ...toastProps } = props || {};
|
|
|
|
const toast = uToast({
|
|
position: 'top',
|
|
duration: 2000,
|
|
containerStyle: {
|
|
fontSize: 'sm',
|
|
...containerStyle
|
|
},
|
|
...toastProps
|
|
});
|
|
|
|
const myToast = useCallback(
|
|
(options?: UseToastOptions) => {
|
|
if (options?.title || options?.description) {
|
|
toast(options);
|
|
}
|
|
},
|
|
[props]
|
|
);
|
|
|
|
return {
|
|
toast: myToast
|
|
};
|
|
};
|