Commit 254b29aa authored by Joel's avatar Joel

Merge branch 'feat/multi-generation' into deploy/dev

parents 8618a770 47bcf52a
'use client'
import type { FC } from 'react'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import copy from 'copy-to-clipboard'
......@@ -29,6 +29,7 @@ export type IGenerationItemProps = {
isInstalledApp: boolean
installedAppId?: string
taskId?: string
controlClearMoreLikeThis?: number
}
export const SimpleBtn = ({ className, onClick, children }: {
......@@ -84,6 +85,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
isInstalledApp,
installedAppId,
taskId,
controlClearMoreLikeThis,
}) => {
const { t } = useTranslation()
const isTop = depth === 1
......@@ -115,6 +117,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
isMobile,
isInstalledApp,
installedAppId,
controlClearMoreLikeThis,
}
const handleMoreLikeThis = async () => {
......@@ -141,6 +144,14 @@ const GenerationItem: FC<IGenerationItemProps> = ({
return res
})()
useEffect(() => {
if (controlClearMoreLikeThis) {
setChildMessageId(null)
setCompletionRes('')
}
}, [controlClearMoreLikeThis])
return (
<div className={cn(className, isTop ? 'rounded-xl border border-gray-200 bg-white' : 'rounded-br-xl !mt-0')}
style={isTop
......
......@@ -149,9 +149,13 @@ const Result: FC<IResultProps> = ({
},
}, isInstalledApp, installedAppInfo?.id)
}
const [controlClearMoreLikeThis, setControlClearMoreLikeThis] = useState(0)
useEffect(() => {
if (controlSend)
if (controlSend) {
handleSend()
setControlClearMoreLikeThis(Date.now())
}
}, [controlSend])
const renderTextGenerationRes = () => (
......@@ -169,6 +173,7 @@ const Result: FC<IResultProps> = ({
installedAppId={installedAppInfo?.id}
isLoading={isCallBatchAPI ? (!completionRes && isResponsing) : false}
taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined}
controlClearMoreLikeThis={controlClearMoreLikeThis}
/>
)
......
......@@ -55,7 +55,7 @@ const translation = {
empty: 'Please input content in the uploaded file.',
fileStructNotMatch: 'The uploaded CSV file not match the struct.',
emptyLine: 'Row {{rowIndex}} is empty',
invalidLine: 'Row {{rowIndex}}: {{varName}} is required',
invalidLine: 'Row {{rowIndex}}: variables value can not be empty',
atLeastOne: 'Please input at least one row in the uploaded file.',
},
},
......
......@@ -51,7 +51,7 @@ const translation = {
empty: '上传文件的内容不能为空',
fileStructNotMatch: '上传文件的内容与结构不匹配',
emptyLine: '第 {{rowIndex}} 行的内容为空',
invalidLine: '第 {{rowIndex}} 行: {{varName}} 的内容不能为空',
invalidLine: '第 {{rowIndex}} 行: 变量值必填',
atLeastOne: '上传文件的内容不能少于一条',
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment