feat translation of the user module
Signed-off-by: jingyang <3161362058@qq.com>
This commit is contained in:
@@ -13,7 +13,7 @@ import { TrainingModeEnum } from '@/constants/plugin';
|
||||
import FileSelect from './FileSelect';
|
||||
import { useRouter } from 'next/router';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 12);
|
||||
import { readCsvContent } from '@/utils/file';
|
||||
import { fileDownload, readCsvContent } from '@/utils/file';
|
||||
|
||||
const fileExtension = '.csv';
|
||||
|
||||
@@ -137,6 +137,7 @@ const CsvImport = ({ kbId }: { kbId: string }) => {
|
||||
isLoading={selecting}
|
||||
tipText={'如果导入文件乱码,请将 CSV 转成 utf-8 编码格式'}
|
||||
py={emptyFiles ? '100px' : 5}
|
||||
isCsv
|
||||
/>
|
||||
|
||||
{!emptyFiles && (
|
||||
|
||||
@@ -4,16 +4,26 @@ import { useLoading } from '@/hooks/useLoading';
|
||||
import { useSelectFile } from '@/hooks/useSelectFile';
|
||||
|
||||
import MyIcon from '@/components/Icon';
|
||||
import { fileDownload } from '@/utils/file';
|
||||
|
||||
interface Props extends BoxProps {
|
||||
fileExtension: string;
|
||||
tipText?: string;
|
||||
onSelectFile: (files: File[]) => Promise<void>;
|
||||
isLoading?: boolean;
|
||||
isCsv?: boolean;
|
||||
}
|
||||
|
||||
const FileSelect = ({ fileExtension, onSelectFile, isLoading, tipText, ...props }: Props) => {
|
||||
const FileSelect = ({
|
||||
fileExtension,
|
||||
onSelectFile,
|
||||
isLoading,
|
||||
tipText,
|
||||
isCsv = false,
|
||||
...props
|
||||
}: Props) => {
|
||||
const { Loading: FileSelectLoading } = useLoading();
|
||||
const csvTemplate = `question,answer\n"什么是 laf","laf 是一个云函数开发平台……"\n"什么是 sealos","Sealos 是以 kubernetes 为内核的云操作系统发行版,可以……"`;
|
||||
|
||||
const { File, onOpen } = useSelectFile({
|
||||
fileType: fileExtension,
|
||||
@@ -47,6 +57,24 @@ const FileSelect = ({ fileExtension, onSelectFile, isLoading, tipText, ...props
|
||||
{tipText}
|
||||
</Box>
|
||||
)}
|
||||
{isCsv && (
|
||||
<Box
|
||||
my={3}
|
||||
cursor={'pointer'}
|
||||
textDecoration={'underline'}
|
||||
color={'myBlue.600'}
|
||||
fontSize={'12px'}
|
||||
onClick={() =>
|
||||
fileDownload({
|
||||
text: csvTemplate,
|
||||
type: 'text/csv',
|
||||
filename: 'template.csv'
|
||||
})
|
||||
}
|
||||
>
|
||||
点击下载csv模板
|
||||
</Box>
|
||||
)}
|
||||
<FileSelectLoading loading={isLoading} fixed={false} />
|
||||
<File onSelect={onSelectFile} />
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user