Skip to content

Commit

Permalink
Updae theme and fix some bug (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Jun 7, 2024
1 parent 19c8a06 commit b20d075
Show file tree
Hide file tree
Showing 153 changed files with 1,586 additions and 1,435 deletions.
22 changes: 22 additions & 0 deletions docSite/content/zh-cn/docs/development/upgrading/484.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: 'V4.8.4(进行中)'
description: 'FastGPT V4.8.4 更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 821
---

<!-- ## 升级指南
- fastgpt 镜像 tag 修改成 v4.8.4
- fastgpt-sandbox 镜像 tag 修改成 v4.8.4 (选择性,无变更)
- 商业版镜像 tag 修改成 v4.8.4 -->

## V4.8.4 更新说明

1. 新增 - 应用使用新权限系统。
2. 优化 - 文本分割增加连续换行、制表符清除,避免大文本性能问题。
3. 修复 - Debug 模式下,相同 source 和 target 内容,导致连线显示异常。
4. 修复 - 定时执行初始化错误。
5. 调整组件库全局theme。
6 changes: 4 additions & 2 deletions packages/global/common/string/textSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const commonSplit = (props: SplitProps): SplitResponse => {
text = text.replace(/(```[\s\S]*?```|~~~[\s\S]*?~~~)/g, function (match) {
return match.replace(/\n/g, codeBlockMarker);
});
// replace invalid \n
text = text.replace(/(\r?\n|\r){3,}/g, '\n\n\n');

// The larger maxLen is, the next sentence is less likely to trigger splitting
const stepReges: { reg: RegExp; maxLen: number }[] = [
Expand Down Expand Up @@ -338,7 +340,7 @@ const commonSplit = (props: SplitProps): SplitResponse => {
*/
export const splitText2Chunks = (props: SplitProps): SplitResponse => {
let { text = '' } = props;

const start = Date.now();
const splitWithCustomSign = text.split(CUSTOM_SPLIT_SIGN);

const splitResult = splitWithCustomSign.map((item) => {
Expand All @@ -348,7 +350,7 @@ export const splitText2Chunks = (props: SplitProps): SplitResponse => {

return commonSplit(props);
});

console.log(Date.now() - start);
return {
chunks: splitResult.map((item) => item.chunks).flat(),
chars: splitResult.reduce((sum, item) => sum + item.chars, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FlowNodeTypeEnum } from '../../node/constant';
import { FlowNodeTemplateType } from '../../type/index.d';
import { FlowNodeTemplateTypeEnum, WorkflowIOValueTypeEnum } from '../../constants';
import { FlowNodeTemplateTypeEnum } from '../../constants';
import { getHandleConfig } from '../utils';

export const SystemConfigNode: FlowNodeTemplateType = {
Expand Down
48 changes: 9 additions & 39 deletions packages/service/common/file/gridfs/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { detectFileEncoding } from '@fastgpt/global/common/file/tools';
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
import { MongoRawTextBuffer } from '../../buffer/rawText/schema';
import { readRawContentByFileBuffer } from '../read/utils';
import { PassThrough } from 'stream';
import { gridFsStream2Buffer } from './utils';

export function getGFSCollection(bucket: `${BucketNameEnum}`) {
MongoFileSchema;
Expand Down Expand Up @@ -113,35 +113,16 @@ export async function getDownloadStream({
fileId: string;
}) {
const bucket = getGridBucket(bucketName);
const stream = bucket.openDownloadStream(new Types.ObjectId(fileId));
const copyStream = stream.pipe(new PassThrough());
const encodeStream = bucket.openDownloadStream(new Types.ObjectId(fileId), { end: 100 });
const rawStream = bucket.openDownloadStream(new Types.ObjectId(fileId));

/* get encoding */
const buffer = await (() => {
return new Promise<Buffer>((resolve, reject) => {
let tmpBuffer: Buffer = Buffer.from([]);

stream.on('data', (chunk) => {
if (tmpBuffer.length < 20) {
tmpBuffer = Buffer.concat([tmpBuffer, chunk]);
}
if (tmpBuffer.length >= 20) {
resolve(tmpBuffer);
}
});
stream.on('end', () => {
resolve(tmpBuffer);
});
stream.on('error', (err) => {
reject(err);
});
});
})();
const buffer = await gridFsStream2Buffer(encodeStream);

const encoding = detectFileEncoding(buffer);

return {
fileStream: copyStream,
fileStream: rawStream,
encoding
// encoding: 'utf-8'
};
Expand Down Expand Up @@ -169,32 +150,21 @@ export const readFileContentFromMongo = async ({
filename: fileBuffer.metadata?.filename || ''
};
}
const start = Date.now();

const [file, { encoding, fileStream }] = await Promise.all([
getFileById({ bucketName, fileId }),
getDownloadStream({ bucketName, fileId })
]);

// console.log('get file stream', Date.now() - start);
if (!file) {
return Promise.reject(CommonErrEnum.fileNotFound);
}

const extension = file?.filename?.split('.')?.pop()?.toLowerCase() || '';

const fileBuffers = await (() => {
return new Promise<Buffer>((resolve, reject) => {
let buffer = Buffer.from([]);
fileStream.on('data', (chunk) => {
buffer = Buffer.concat([buffer, chunk]);
});
fileStream.on('end', () => {
resolve(buffer);
});
fileStream.on('error', (err) => {
reject(err);
});
});
})();
const fileBuffers = await gridFsStream2Buffer(fileStream);
// console.log('get file buffer', Date.now() - start);

const { rawText } = await readRawContentByFileBuffer({
extension,
Expand Down
15 changes: 15 additions & 0 deletions packages/service/common/file/gridfs/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const gridFsStream2Buffer = (stream: NodeJS.ReadableStream) => {
return new Promise<Buffer>((resolve, reject) => {
let tmpBuffer: Buffer = Buffer.from([]);

stream.on('data', (chunk) => {
tmpBuffer = Buffer.concat([tmpBuffer, chunk]);
});
stream.on('end', () => {
resolve(tmpBuffer);
});
stream.on('error', (err) => {
reject(err);
});
});
};
6 changes: 4 additions & 2 deletions packages/web/components/common/DateRangePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ const DateRangePicker = ({
py={1}
borderRadius={'sm'}
cursor={'pointer'}
bg={'myWhite.600'}
bg={'myGray.100'}
fontSize={'sm'}
onClick={() => setShowSelected(true)}
>
<Box>{formatSelected}</Box>
<Box color={'myGray.600'} fontWeight={'400'}>
{formatSelected}
</Box>
<MyIcon ml={2} name={'date'} w={'16px'} color={'myGray.600'} />
</Flex>
{showSelected && (
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/DndDrag/DragIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DraggableProvided } from 'react-beautiful-dnd';

const DragIcon = ({ provided, ...props }: { provided: DraggableProvided } & BoxProps) => {
return (
<Box {...provided.dragHandleProps} {...props}>
<Box {...provided.dragHandleProps} {...props} lineHeight={1}>
<DragHandleIcon color={'myGray.500'} _hover={{ color: 'primary.600' }} />
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/EmptyTip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const EmptyTip = ({ text, ...props }: Props) => {
return (
<Flex mt={5} flexDirection={'column'} alignItems={'center'} py={'10vh'} {...props}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'}>
<Box mt={2} color={'myGray.500'} fontSize={'sm'}>
{text || t('common.empty.Common Tip')}
</Box>
</Flex>
Expand Down
17 changes: 17 additions & 0 deletions packages/web/components/common/MyBox/FormLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { Box, BoxProps } from '@chakra-ui/react';

const FormLabel = ({
children,
...props
}: BoxProps & {
children: React.ReactNode;
}) => {
return (
<Box color={'myGray.900'} fontSize={'sm'} {...props}>
{children}
</Box>
);
};

export default FormLabel;
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const CustomRightDrawer = ({
)}
</>
)}
<Box flex={'1'} fontSize={'lg'}>
<Box flex={'1'} fontSize={'md'}>
{title}
</Box>
<CloseButton position={'relative'} fontSize={'sm'} top={0} right={0} onClick={onClose} />
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/MyDrawer/MyRightDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const MyRightDrawer = ({
)}
</>
)}
<Box flex={'1'} fontSize={'lg'}>
<Box flex={'1'} fontSize={'md'}>
{title}
</Box>
<DrawerCloseButton position={'relative'} fontSize={'sm'} top={0} right={0} />
Expand Down
63 changes: 39 additions & 24 deletions packages/web/components/common/MyMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MenuItemProps
} from '@chakra-ui/react';
import MyIcon from '../Icon';
import MyDivider from '../MyDivider';

type MenuItemType = 'primary' | 'danger';

Expand All @@ -18,11 +19,14 @@ export type Props = {
Button: React.ReactNode;
trigger?: 'hover' | 'click';
menuList: {
isActive?: boolean;
label: string | React.ReactNode;
icon?: string;
type?: MenuItemType;
onClick: () => any;
label?: string;
children: {
isActive?: boolean;
type?: MenuItemType;
icon?: string;
label: string | React.ReactNode;
onClick: () => any;
}[];
}[];
};

Expand All @@ -49,9 +53,11 @@ const MyMenu = ({
};
const menuItemStyles: MenuItemProps = {
borderRadius: 'sm',
py: 3,
py: 2,
px: 3,
display: 'flex',
alignItems: 'center'
alignItems: 'center',
fontSize: 'sm'
};
const ref = useRef<HTMLDivElement>(null);
const closeTimer = useRef<any>();
Expand Down Expand Up @@ -109,23 +115,32 @@ const MyMenu = ({
'0px 2px 4px rgba(161, 167, 179, 0.25), 0px 0px 1px rgba(121, 141, 159, 0.25);'
}
>
{menuList.map((item, i) => (
<MenuItem
key={i}
{...menuItemStyles}
{...typeMapStyle[item.type || 'primary']}
onClick={(e) => {
e.stopPropagation();
setIsOpen(false);
item.onClick && item.onClick();
}}
color={item.isActive ? 'primary.700' : 'myGray.600'}
whiteSpace={'pre-wrap'}
>
{!!item.icon && <MyIcon name={item.icon as any} w={'16px'} mr={2} />}
{item.label}
</MenuItem>
))}
{menuList.map((item, i) => {
return (
<Box key={i}>
{item.label && <Box fontSize={'sm'}>{item.label}</Box>}
{i !== 0 && <MyDivider h={'1.5px'} my={1} />}
{item.children.map((child, index) => (
<MenuItem
key={index}
{...menuItemStyles}
{...typeMapStyle[child.type || 'primary']}
onClick={(e) => {
e.stopPropagation();
setIsOpen(false);
child.onClick && child.onClick();
}}
color={child.isActive ? 'primary.700' : 'myGray.600'}
whiteSpace={'pre-wrap'}
_notLast={{ mb: 0.5 }}
>
{!!child.icon && <MyIcon name={child.icon as any} w={'16px'} mr={2} />}
<Box>{child.label}</Box>
</MenuItem>
))}
</Box>
);
})}
</MenuList>
</Box>
</Menu>
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/common/MyModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const MyModal = ({
borderBottom={'1px solid #F4F6F8'}
roundedTop={'lg'}
py={'10px'}
fontSize={'md'}
>
{iconSrc && (
<>
Expand Down
6 changes: 3 additions & 3 deletions packages/web/components/common/MySelect/MultipleSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Flex, useDisclosure, useOutsideClick } from '@chakra-ui/react';
import React, { useRef } from 'react';
import { useTranslation } from 'next-i18next';
import FillTag from '../Tag/index';
import MyTag from '../Tag/index';
import MyIcon from '../Icon';

export type SelectProps = {
Expand Down Expand Up @@ -51,7 +51,7 @@ const MultipleSelect = ({
if (!listItem) return null;

return (
<FillTag colorSchema="blue" p={2} cursor={'default'}>
<MyTag colorSchema="blue" p={2} cursor={'default'}>
{listItem.alias || listItem.label}
<MyIcon
name={'common/closeLight'}
Expand All @@ -63,7 +63,7 @@ const MultipleSelect = ({
onSelect(value.filter((i) => i !== item));
}}
/>
</FillTag>
</MyTag>
);
})}
{value.length === 0 && placeholder && (
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/common/MySelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const MySelect = (
}
}}
whiteSpace={'pre-wrap'}
fontSize={'sm'}
>
{item.label}
</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/MyTooltip/QuestionTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = IconProps & {
const QuestionTip = ({ label, maxW, ...props }: Props) => {
return (
<MyTooltip label={label} maxW={maxW}>
<QuestionOutlineIcon {...props} />
<QuestionOutlineIcon w={'0.9rem'} {...props} />
</MyTooltip>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/MyTooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ...
})}
>
<Tooltip
className="tooltip"
className="chakra-tooltip"
bg={'white'}
arrowShadowColor={'rgba(0,0,0,0.05)'}
hasArrow
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/common/Radio/LeftRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { Box, Flex, useTheme, Grid, type GridProps } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import MyTooltip from '../MyTooltip';
import { QuestionOutlineIcon } from '@chakra-ui/icons';
import QuestionTip from '../MyTooltip/QuestionTip';

// @ts-ignore
Expand Down Expand Up @@ -95,6 +94,7 @@ const LeftRadio = ({
color={'myGray.900'}
fontWeight={item.desc ? '500' : 'normal'}
whiteSpace={'nowrap'}
fontSize={'sm'}
>
{typeof item.title === 'string' ? t(item.title) : item.title}
</Box>
Expand Down
Loading

0 comments on commit b20d075

Please sign in to comment.