chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
+72
@@ -0,0 +1,72 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import * as React from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useCSVReader } from 'react-papaparse'
|
||||
|
||||
type Props = Readonly<{
|
||||
onParsed: (data: string[][]) => void
|
||||
}>
|
||||
|
||||
const CSVReader: FC<Props> = ({ onParsed }) => {
|
||||
const { t } = useTranslation(['share'])
|
||||
const { CSVReader } = useCSVReader()
|
||||
const [zoneHover, setZoneHover] = useState(false)
|
||||
return (
|
||||
<CSVReader
|
||||
onUploadAccepted={(results: any) => {
|
||||
onParsed(results.data)
|
||||
setZoneHover(false)
|
||||
}}
|
||||
onDragOver={(event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
setZoneHover(true)
|
||||
}}
|
||||
onDragLeave={(event: DragEvent) => {
|
||||
event.preventDefault()
|
||||
setZoneHover(false)
|
||||
}}
|
||||
>
|
||||
{({ getRootProps, acceptedFile }: any) => (
|
||||
<>
|
||||
<div
|
||||
{...getRootProps()}
|
||||
className={cn(
|
||||
'flex h-20 items-center rounded-xl border border-dashed border-components-dropzone-border bg-components-dropzone-bg system-sm-regular',
|
||||
acceptedFile &&
|
||||
'border-solid border-components-panel-border bg-components-panel-on-panel-item-bg px-6 hover:border-components-panel-bg-blur hover:bg-components-panel-on-panel-item-bg-hover',
|
||||
zoneHover &&
|
||||
'border border-components-dropzone-border-accent bg-components-dropzone-bg-accent',
|
||||
)}
|
||||
>
|
||||
{acceptedFile ? (
|
||||
<div className="flex w-full items-center space-x-2">
|
||||
<span aria-hidden className="i-custom-public-files-csv h-8.5 w-8 shrink-0" />
|
||||
<div className="flex w-0 grow">
|
||||
<span className="max-w-[calc(100%-30px)] truncate text-text-secondary">
|
||||
{acceptedFile.name.replace(/.csv$/, '')}
|
||||
</span>
|
||||
<span className="shrink-0 text-text-tertiary">.csv</span>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full items-center justify-center space-x-2">
|
||||
<span aria-hidden className="i-custom-public-files-csv h-8.5 w-8 shrink-0" />
|
||||
<div className="text-text-tertiary">
|
||||
{t(($) => $['generation.csvUploadTitle'], { ns: 'share' })}
|
||||
<span className="cursor-pointer text-text-accent">
|
||||
{t(($) => $['generation.browse'], { ns: 'share' })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</CSVReader>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(CSVReader)
|
||||
Reference in new issue
Block a user