perf: Dataset new ui (#2555)

* perf: dataset detail ui

* fix: collection tag modal

* perf: data card support markdown

* fix :ts
This commit is contained in:
Archer
2024-08-28 12:48:55 +08:00
committed by GitHub
parent aba50e958e
commit b9a6b71fe9
16 changed files with 355 additions and 366 deletions

View File

@@ -3,7 +3,7 @@ import { Box, ImageProps, Skeleton } from '@chakra-ui/react';
import MyPhotoView from '@fastgpt/web/components/common/Image/PhotoView';
import { useBoolean } from 'ahooks';
const MdImage = ({ src, ...props }: { src?: string } & ImageProps) => {
const MdImage = ({ src, ...props }: { src?: string; forbidImgPreview?: boolean } & ImageProps) => {
const [isLoaded, { setTrue }] = useBoolean(false);
const [renderSrc, setRenderSrc] = useState(src);
@@ -11,7 +11,6 @@ const MdImage = ({ src, ...props }: { src?: string } & ImageProps) => {
if (src?.includes('base64') && !src.startsWith('data:image')) {
return <Box>Invalid base64 image</Box>;
}
return (
<Skeleton isLoaded={isLoaded}>
<MyPhotoView

View File

@@ -28,20 +28,22 @@ const QuestionGuide = dynamic(() => import('./chat/QuestionGuide'), { ssr: false
const Markdown = ({
source = '',
showAnimation = false
showAnimation = false,
forbidImgPreview = false
}: {
source?: string;
showAnimation?: boolean;
forbidImgPreview?: boolean;
}) => {
const components = useMemo<any>(
() => ({
img: Image,
img: (props: any) => <Image {...props} forbidImgPreview={forbidImgPreview} />,
pre: RewritePre,
p: (pProps: any) => <p {...pProps} dir="auto" />,
code: Code,
a: A
}),
[]
[forbidImgPreview]
);
const formatSource = useMemo(() => {
@@ -74,7 +76,7 @@ const Markdown = ({
export default React.memo(Markdown);
/* Custom dom */
const Code = React.memo(function Code(e: any) {
function Code(e: any) {
const { className, codeBlock, children } = e;
const match = /language-(\w+)/.exec(className || '');
const codeType = match?.[1];
@@ -103,11 +105,13 @@ const Code = React.memo(function Code(e: any) {
}, [codeType, className, codeBlock, match, children, strChildren]);
return Component;
});
const Image = React.memo(function Image({ src }: { src?: string }) {
return <MdImage src={src} />;
});
const A = React.memo(function A({ children, ...props }: any) {
}
function Image({ src, forbidImgPreview }: { forbidImgPreview: boolean; src?: string }) {
return <MdImage forbidImgPreview={forbidImgPreview} src={src} />;
}
function A({ children, ...props }: any) {
const { t } = useTranslation();
// empty href link
@@ -152,7 +156,7 @@ const A = React.memo(function A({ children, ...props }: any) {
}
return <Link {...props}>{children}</Link>;
});
}
function RewritePre({ children }: any) {
const modifiedChildren = React.Children.map(children, (child) => {

View File

@@ -61,7 +61,7 @@ const AIModelSelector = ({ list, onchange, disableTip, ...props }: Props) => {
router.push(AI_POINT_USAGE_CARD_ROUTE);
return;
}
onchange?.(e);
return onchange?.(e);
},
[onchange, router]
);

View File

@@ -1,4 +1,4 @@
import { Box, BoxProps, ButtonProps } from '@chakra-ui/react';
import { Box, BoxProps } from '@chakra-ui/react';
import MySelect from '@fastgpt/web/components/common/MySelect';
import React from 'react';
import type { PermissionValueType } from '@fastgpt/global/support/permission/type';
@@ -20,7 +20,6 @@ type Props = Omit<BoxProps, 'onChange'> & {
writePer?: PermissionValueType;
onChange: (v: PermissionValueType) => Promise<any> | any;
isInheritPermission?: boolean;
isDisabled?: boolean;
hasParent?: boolean;
};
@@ -42,15 +41,12 @@ const DefaultPermissionList = ({
{ label: t('user:permission.team_write'), value: writePer }
];
const { runAsync: onRequestChange, loading } = useRequest2((v: PermissionValueType) =>
onChange(v)
);
const { runAsync: onRequestChange } = useRequest2((v: PermissionValueType) => onChange(v));
return (
<>
<Box {...styles}>
<MySelect
isLoading={loading}
list={defaultPermissionSelectList}
value={per}
onchange={(per) => {