Fix some bug (#5048)

* fix: chat log time range

* fix: repeat system prompt

* perf: nanoid random

* fix: get files from histories

* fix: ts

* ts config

* perf: search dataset collection
This commit is contained in:
Archer
2025-06-17 16:10:01 +08:00
committed by GitHub
parent 7981b61ca9
commit af3221fa47
21 changed files with 121 additions and 79 deletions

View File

@@ -1,12 +1,17 @@
import React, { useState, useMemo, useRef, useEffect } from 'react';
import { Box, Card, Flex, useTheme, useOutsideClick, Button } from '@chakra-ui/react';
import { addDays, format } from 'date-fns';
import { type DateRange, DayPicker } from 'react-day-picker';
import { DayPicker } from 'react-day-picker';
import 'react-day-picker/dist/style.css';
import zhCN from 'date-fns/locale/zh-CN';
import { useTranslation } from 'next-i18next';
import MyIcon from '../Icon';
export type DateRangeType = {
from: Date;
to: Date;
};
const DateRangePicker = ({
onChange,
onSuccess,
@@ -17,16 +22,16 @@ const DateRangePicker = ({
},
dateRange
}: {
onChange?: (date: DateRange) => void;
onSuccess?: (date: DateRange) => void;
onChange?: (date: DateRangeType) => void;
onSuccess?: (date: DateRangeType) => void;
position?: 'bottom' | 'top';
defaultDate?: DateRange;
dateRange?: DateRange;
defaultDate?: DateRangeType;
dateRange?: DateRangeType;
}) => {
const { t } = useTranslation();
const theme = useTheme();
const OutRangeRef = useRef(null);
const [range, setRange] = useState<DateRange | undefined>(defaultDate);
const [range, setRange] = useState<DateRangeType>(defaultDate);
const [showSelected, setShowSelected] = useState(false);
useEffect(() => {
@@ -87,28 +92,30 @@ const DateRangePicker = ({
defaultMonth={defaultDate.to}
selected={range}
disabled={[
{ from: new Date(2022, 3, 1), to: addDays(new Date(), -90) },
{ from: new Date(2022, 3, 1), to: addDays(new Date(), -180) },
{ from: addDays(new Date(), 1), to: new Date(2099, 1, 1) }
]}
onSelect={(date) => {
if (date?.from === undefined) {
date = {
let typeDate = date as DateRangeType;
if (!typeDate || typeDate?.from === undefined) {
typeDate = {
from: range?.from,
to: range?.from
};
}
if (date?.to === undefined) {
date.to = date.from;
if (typeDate?.to === undefined) {
typeDate.to = typeDate.from;
}
if (date?.from) {
date.from = new Date(date.from.setHours(0, 0, 0, 0));
if (typeDate?.from) {
typeDate.from = new Date(typeDate.from.setHours(0, 0, 0, 0));
}
if (date?.to) {
date.to = new Date(date.to.setHours(23, 59, 59, 999));
if (typeDate?.to) {
typeDate.to = new Date(typeDate.to.setHours(23, 59, 59, 999));
}
setRange(date);
onChange?.(date);
setRange(typeDate);
onChange?.(typeDate);
}}
footer={
<Flex justifyContent={'flex-end'}>
@@ -139,4 +146,3 @@ const DateRangePicker = ({
};
export default DateRangePicker;
export type DateRangeType = DateRange;

View File

@@ -258,6 +258,7 @@ export function usePagination<DataT, ResT = {}>(
return {
pageNum,
setPageNum,
pageSize,
total: totalDataLength,
data,

View File

@@ -1,10 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@fastgpt/web/*": ["./*"]
}
"baseUrl": "."
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts", "../**/*.d.ts"]
}