mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
fix: chat quote number (#4679)
This commit is contained in:
@@ -56,9 +56,6 @@ const A = ({ children, ...props }: any) => {
|
||||
|
||||
// Quote
|
||||
if (props.href?.startsWith('QUOTE') && typeof children?.[0] === 'string') {
|
||||
const indexMatch = props.href.match(/QUOTE(\d+)/);
|
||||
const index = indexMatch ? indexMatch[1] : '1';
|
||||
|
||||
const sourceData = useMemo(
|
||||
() => getCollectionSourceData(quoteData?.collection),
|
||||
[quoteData?.collection]
|
||||
@@ -80,27 +77,17 @@ const A = ({ children, ...props }: any) => {
|
||||
onOpen();
|
||||
runAsync(String(children));
|
||||
}}
|
||||
trigger={'hover'}
|
||||
gutter={4}
|
||||
>
|
||||
<PopoverTrigger>
|
||||
<Button variant={'unstyled'} minH={0} minW={0} h={'auto'}>
|
||||
<MyTooltip label={t('common:read_quote')}>
|
||||
<Box
|
||||
w={'14px'}
|
||||
h={'14px'}
|
||||
borderRadius={'full'}
|
||||
bg={'rgba(0, 0, 0, 0.08)'}
|
||||
color={'myGray.600'}
|
||||
fontSize={'10px'}
|
||||
display={'flex'}
|
||||
alignItems={'center'}
|
||||
justifyContent={'center'}
|
||||
ml={0.5}
|
||||
transform={'translateY(-3px)'}
|
||||
>
|
||||
{index}
|
||||
</Box>
|
||||
</MyTooltip>
|
||||
<MyIcon
|
||||
name={'core/chat/quoteSign'}
|
||||
w={'1rem'}
|
||||
color={'primary.700'}
|
||||
cursor={'pointer'}
|
||||
/>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent boxShadow={'lg'} w={'500px'} py={4}>
|
||||
@@ -118,19 +105,6 @@ const A = ({ children, ...props }: any) => {
|
||||
height={6}
|
||||
mr={1}
|
||||
>
|
||||
<Flex
|
||||
color={'myGray.500'}
|
||||
bg={'myGray.150'}
|
||||
w={4}
|
||||
justifyContent={'center'}
|
||||
fontSize={'10px'}
|
||||
h={'full'}
|
||||
alignItems={'center'}
|
||||
mr={1}
|
||||
flexShrink={0}
|
||||
>
|
||||
{index}
|
||||
</Flex>
|
||||
<Flex px={1.5}>
|
||||
<MyIcon name={icon as any} mr={1} flexShrink={0} w={'12px'} />
|
||||
<Box
|
||||
@@ -151,7 +125,7 @@ const A = ({ children, ...props }: any) => {
|
||||
onClick={() => {
|
||||
onClose();
|
||||
eventBus.emit(EventNameEnum.openQuoteReader, {
|
||||
// quoteId: String(children),
|
||||
quoteId: String(children),
|
||||
sourceId: sourceData.sourceId,
|
||||
sourceName: sourceData.sourceName,
|
||||
datasetId: quoteData?.collection.datasetId,
|
||||
|
@@ -227,12 +227,14 @@ const ChatItem = (props: Props) => {
|
||||
collectionId,
|
||||
sourceId,
|
||||
sourceName,
|
||||
datasetId
|
||||
datasetId,
|
||||
quoteId
|
||||
}: {
|
||||
collectionId?: string;
|
||||
sourceId?: string;
|
||||
sourceName?: string;
|
||||
datasetId?: string;
|
||||
quoteId?: string;
|
||||
}) => {
|
||||
if (!setQuoteData) return;
|
||||
|
||||
@@ -252,7 +254,8 @@ const ChatItem = (props: Props) => {
|
||||
sourceId: sourceId || '',
|
||||
sourceName: sourceName || '',
|
||||
datasetId: datasetId || '',
|
||||
outLinkAuthData
|
||||
outLinkAuthData,
|
||||
quoteId
|
||||
}
|
||||
: {
|
||||
appId: appId,
|
||||
|
@@ -72,6 +72,7 @@ type RenderHeaderProps = {
|
||||
onUpdateParentId: (parentId: ParentIdType) => void;
|
||||
};
|
||||
type RenderListProps = {
|
||||
templateType: TemplateTypeEnum;
|
||||
templates: NodeTemplateListItemType[];
|
||||
type: TemplateTypeEnum;
|
||||
onClose: () => void;
|
||||
@@ -247,6 +248,7 @@ const NodeTemplatesModal = ({ isOpen, onClose }: ModuleTemplateListProps) => {
|
||||
setSearchKey={setSearchKey}
|
||||
/>
|
||||
<RenderList
|
||||
templateType={templateType}
|
||||
templates={templates}
|
||||
type={templateType}
|
||||
onClose={onClose}
|
||||
@@ -402,6 +404,7 @@ const RenderHeader = React.memo(function RenderHeader({
|
||||
});
|
||||
|
||||
const RenderList = React.memo(function RenderList({
|
||||
templateType,
|
||||
templates,
|
||||
type,
|
||||
onClose,
|
||||
@@ -712,7 +715,7 @@ const RenderList = React.memo(function RenderList({
|
||||
{t(template.name as any)}
|
||||
</Box>
|
||||
|
||||
{template.isFolder && (
|
||||
{template.isFolder && templateType === TemplateTypeEnum.teamPlugin && (
|
||||
<Box
|
||||
color={'myGray.500'}
|
||||
_hover={{
|
||||
|
@@ -94,8 +94,8 @@ const EditModal = ({ onClose, ...props }: RenderInputProps & { onClose: () => vo
|
||||
icon: 'core/app/simpleMode/variable'
|
||||
},
|
||||
{
|
||||
key: 'sourceIndex',
|
||||
label: t('common:core.dataset.search.Source index'),
|
||||
key: 'sourceId',
|
||||
label: t('common:core.dataset.search.Source id'),
|
||||
icon: 'core/app/simpleMode/variable'
|
||||
},
|
||||
{
|
||||
|
@@ -35,7 +35,7 @@ const CollectionReader = ({
|
||||
const router = useRouter();
|
||||
const { userInfo } = useUserStore();
|
||||
|
||||
const { collectionId, datasetId, chatItemDataId, sourceId, sourceName } = metadata;
|
||||
const { collectionId, datasetId, chatItemDataId, sourceId, sourceName, quoteId } = metadata;
|
||||
const [quoteIndex, setQuoteIndex] = useState(0);
|
||||
|
||||
// Get dataset permission
|
||||
@@ -45,11 +45,19 @@ const CollectionReader = ({
|
||||
});
|
||||
|
||||
const filterResults = useMemo(() => {
|
||||
setQuoteIndex(0);
|
||||
return rawSearch
|
||||
const res = rawSearch
|
||||
.filter((item) => item.collectionId === collectionId)
|
||||
.sort((a, b) => (a.chunkIndex || 0) - (b.chunkIndex || 0));
|
||||
}, [collectionId, rawSearch]);
|
||||
|
||||
if (quoteId) {
|
||||
setQuoteIndex(res.findIndex((item) => item.id === quoteId));
|
||||
} else {
|
||||
setQuoteIndex(0);
|
||||
}
|
||||
|
||||
return res;
|
||||
}, [collectionId, quoteId, rawSearch]);
|
||||
|
||||
const currentQuoteItem = useMemo(() => {
|
||||
const item = filterResults[quoteIndex];
|
||||
if (item) {
|
||||
|
@@ -41,6 +41,7 @@ export type GetQuoteDataBasicProps = {
|
||||
};
|
||||
// 获取单个集合引用
|
||||
export type GetCollectionQuoteDataProps = GetQuoteDataBasicProps & {
|
||||
quoteId?: string;
|
||||
collectionId: string;
|
||||
sourceId: string;
|
||||
sourceName: string;
|
||||
|
Reference in New Issue
Block a user