From 2c174aa91c401cb371f420edaaa3314df29ad45e Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Wed, 16 Aug 2023 18:21:55 +0800 Subject: [PATCH] feat: copy settings config --- client/public/locales/en/common.json | 12 +- client/public/locales/zh/common.json | 12 +- client/src/pages/api/chat/chatTest.ts | 8 ++ .../pages/api/openapi/v1/chat/completions.ts | 8 ++ .../AdEdit/components/ImportSettings.tsx | 54 +++++++ .../app/detail/components/AdEdit/index.tsx | 134 ++++++++++-------- client/src/pages/app/detail/index.tsx | 6 +- client/src/utils/tools.ts | 8 +- 8 files changed, 173 insertions(+), 69 deletions(-) create mode 100644 client/src/pages/app/detail/components/AdEdit/components/ImportSettings.tsx diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json index ad36fed86..f9061f459 100644 --- a/client/public/locales/en/common.json +++ b/client/public/locales/en/common.json @@ -11,9 +11,15 @@ "Confirm Save App Tip": "The application may be in advanced orchestration mode, and the advanced orchestration configuration will be overwritten after saving, please confirm!", "Connection is invalid": "Connecting is invalid", "Connection type is different": "Connection type is different", + "Export Config Successful": "The configuration has been copied. Please check for important data", + "Export Configs": "Export Configs", + "Import Config": "Import Config", + "Import Config Failed": "Failed to import the configuration, please ensure that the configuration is normal!", + "Import Configs": "Import Configs", "Input Field Settings": "Input Field Settings", "My Apps": "My Apps", - "Output Field Settings": "Output Field Settings" + "Output Field Settings": "Output Field Settings", + "Paste Config": "Paste Config" }, "chat": { "Complete Response": "Complete Response", @@ -31,12 +37,14 @@ "Cancel": "Cancel", "Collect": "Collect", "Copy": "Copy", + "Copy Successful": "Copy Successful", "Course": "", "Delete": "Delete", "Filed is repeat": "Filed is repeated", "Filed is repeated": "", "Input": "Input", - "Output": "Output" + "Output": "Output", + "export": "" }, "dataset": { "Confirm to delete the data": "Confirm to delete the data?", diff --git a/client/public/locales/zh/common.json b/client/public/locales/zh/common.json index 358db1193..ff42aba65 100644 --- a/client/public/locales/zh/common.json +++ b/client/public/locales/zh/common.json @@ -11,9 +11,15 @@ "Confirm Save App Tip": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!", "Connection is invalid": "连接无效", "Connection type is different": "连接的类型不一致", + "Export Config Successful": "已复制配置,请注意检查是否有重要数据", + "Export Configs": "导出配置", + "Import Config": "导入配置", + "Import Config Failed": "导入配置失败,请确保配置正常!", + "Import Configs": "导入配置", "Input Field Settings": "输入字段编辑", "My Apps": "我的应用", - "Output Field Settings": "输出字段编辑" + "Output Field Settings": "输出字段编辑", + "Paste Config": "粘贴配置" }, "chat": { "Complete Response": "完整响应", @@ -31,12 +37,14 @@ "Cancel": "取消", "Collect": "收藏", "Copy": "复制", + "Copy Successful": "复制成功", "Course": "", "Delete": "删除", "Filed is repeat": "", "Filed is repeated": "字段重复了", "Input": "输入", - "Output": "输出" + "Output": "输出", + "export": "" }, "dataset": { "Confirm to delete the data": "确认删除该数据?", diff --git a/client/src/pages/api/chat/chatTest.ts b/client/src/pages/api/chat/chatTest.ts index ce3728ee1..6ba2560d4 100644 --- a/client/src/pages/api/chat/chatTest.ts +++ b/client/src/pages/api/chat/chatTest.ts @@ -81,3 +81,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) res.end(); } } + +export const config = { + api: { + bodyParser: { + sizeLimit: '20mb' + } + } +}; diff --git a/client/src/pages/api/openapi/v1/chat/completions.ts b/client/src/pages/api/openapi/v1/chat/completions.ts index b9e30429c..01141b93a 100644 --- a/client/src/pages/api/openapi/v1/chat/completions.ts +++ b/client/src/pages/api/openapi/v1/chat/completions.ts @@ -446,3 +446,11 @@ export function responseStatus({ }) }); } + +export const config = { + api: { + bodyParser: { + sizeLimit: '20mb' + } + } +}; diff --git a/client/src/pages/app/detail/components/AdEdit/components/ImportSettings.tsx b/client/src/pages/app/detail/components/AdEdit/components/ImportSettings.tsx new file mode 100644 index 000000000..61f57955a --- /dev/null +++ b/client/src/pages/app/detail/components/AdEdit/components/ImportSettings.tsx @@ -0,0 +1,54 @@ +import React, { useState } from 'react'; +import { Textarea, Button, ModalBody, ModalFooter } from '@chakra-ui/react'; +import MyModal from '@/components/MyModal'; +import { AppModuleItemType } from '@/types/app'; +import { useTranslation } from 'react-i18next'; +import { useToast } from '@/hooks/useToast'; + +const ImportSettings = ({ + onClose, + onSuccess +}: { + onClose: () => void; + onSuccess: (modules: AppModuleItemType[]) => void; +}) => { + const { t } = useTranslation(); + const { toast } = useToast(); + const [value, setValue] = useState(''); + + return ( + + +