mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: jyong <718720800@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hj24 <mambahj24@gmail.com> Co-authored-by: hj24 <huangjian@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Co-authored-by: CodingOnStar <hanxujiang@dify.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Ayush Baluni <73417844+aayushbaluni@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: jimcody1995 <jjimcody@gmail.com> Co-authored-by: James <63717587+jamesrayammons@users.noreply.github.com> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: Stephen Zhou <hi@hyoban.cc> Co-authored-by: Coding On Star <447357187@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jerryzai <jerryzh8710@protonmail.com> Co-authored-by: NVIDIAN <speedy.hpc@hotmail.com> Co-authored-by: ai-hpc <ai-hpc@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Junghwan <70629228+shaun0927@users.noreply.github.com> Co-authored-by: HeYinKazune <70251095+HeYin-OS@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Jingyi <jingyi.qi@dify.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: sxxtony <166789813+sxxtony@users.noreply.github.com>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
'use client'
|
|
import type { FC } from 'react'
|
|
import * as React from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import {
|
|
useCSVDownloader,
|
|
} from 'react-papaparse'
|
|
import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vender/solid/general'
|
|
|
|
type ICSVDownloadProps = {
|
|
vars: { name: string }[]
|
|
}
|
|
|
|
const CSVDownload: FC<ICSVDownloadProps> = ({
|
|
vars,
|
|
}) => {
|
|
const { t } = useTranslation()
|
|
const { CSVDownloader, Type } = useCSVDownloader()
|
|
const addQueryContentVars = [...vars]
|
|
const template = (() => {
|
|
const res: Record<string, string> = {}
|
|
addQueryContentVars.forEach((item) => {
|
|
res[item.name] = ''
|
|
})
|
|
return res
|
|
})()
|
|
|
|
return (
|
|
<div className="mt-6">
|
|
<div className="system-sm-medium text-text-primary">{t('generation.csvStructureTitle', { ns: 'share' })}</div>
|
|
<div className="mt-2 max-h-[500px] overflow-auto">
|
|
<table className="w-full table-fixed border-separate border-spacing-0 rounded-lg border border-divider-regular text-xs">
|
|
<thead className="text-text-tertiary">
|
|
<tr>
|
|
{addQueryContentVars.map((item, i) => (
|
|
<td key={i} className="h-9 border-b border-divider-regular pr-2 pl-3">{item.name}</td>
|
|
))}
|
|
</tr>
|
|
</thead>
|
|
<tbody className="text-text-secondary">
|
|
<tr>
|
|
{addQueryContentVars.map((item, i) => (
|
|
<td key={i} className="h-9 pl-4">
|
|
{item.name}
|
|
{' '}
|
|
{t('generation.field', { ns: 'share' })}
|
|
</td>
|
|
))}
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<CSVDownloader
|
|
className="mt-2 block cursor-pointer"
|
|
type={Type.Link}
|
|
filename="template"
|
|
bom={true}
|
|
config={{
|
|
// delimiter: ';',
|
|
}}
|
|
data={[
|
|
template,
|
|
]}
|
|
>
|
|
<div className="flex h-[18px] items-center space-x-1 system-xs-medium text-text-accent">
|
|
<DownloadIcon className="h-3 w-3" />
|
|
<span>{t('generation.downloadTemplate', { ns: 'share' })}</span>
|
|
</div>
|
|
</CSVDownloader>
|
|
</div>
|
|
|
|
)
|
|
}
|
|
export default React.memo(CSVDownload)
|