mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-26 02:07:28 +08:00
fix: support upload import duplicate plugin (#5926)
This commit is contained in:
@@ -109,6 +109,7 @@
|
|||||||
"custom_plugin_default_installed_label": "Default Installed",
|
"custom_plugin_default_installed_label": "Default Installed",
|
||||||
"custom_plugin_delete_success": "Delete successful",
|
"custom_plugin_delete_success": "Delete successful",
|
||||||
"custom_plugin_duplicate": "Duplicate ID",
|
"custom_plugin_duplicate": "Duplicate ID",
|
||||||
|
"custom_plugin_duplicate_tip": "Confirm that the import will overwrite the original resources",
|
||||||
"custom_plugin_has_token_fee_label": "Charge Token Fee",
|
"custom_plugin_has_token_fee_label": "Charge Token Fee",
|
||||||
"custom_plugin_intro_label": "Introduction",
|
"custom_plugin_intro_label": "Introduction",
|
||||||
"custom_plugin_intro_placeholder": "Add an introduction for this application",
|
"custom_plugin_intro_placeholder": "Add an introduction for this application",
|
||||||
|
|||||||
@@ -111,6 +111,7 @@
|
|||||||
"custom_plugin_default_installed_label": "默认安装",
|
"custom_plugin_default_installed_label": "默认安装",
|
||||||
"custom_plugin_delete_success": "删除成功",
|
"custom_plugin_delete_success": "删除成功",
|
||||||
"custom_plugin_duplicate": "ID 重复",
|
"custom_plugin_duplicate": "ID 重复",
|
||||||
|
"custom_plugin_duplicate_tip": "确认导入将覆盖原有资源",
|
||||||
"custom_plugin_has_token_fee_label": "是否收取 Token 费用",
|
"custom_plugin_has_token_fee_label": "是否收取 Token 费用",
|
||||||
"custom_plugin_intro_label": "介绍",
|
"custom_plugin_intro_label": "介绍",
|
||||||
"custom_plugin_intro_placeholder": "为这个应用添加一个介绍",
|
"custom_plugin_intro_placeholder": "为这个应用添加一个介绍",
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
"custom_plugin_default_installed_label": "預設安裝",
|
"custom_plugin_default_installed_label": "預設安裝",
|
||||||
"custom_plugin_delete_success": "刪除成功",
|
"custom_plugin_delete_success": "刪除成功",
|
||||||
"custom_plugin_duplicate": "ID 重複",
|
"custom_plugin_duplicate": "ID 重複",
|
||||||
|
"custom_plugin_duplicate_tip": "確認導入將覆蓋原有資源",
|
||||||
"custom_plugin_has_token_fee_label": "是否收取 Token 費用",
|
"custom_plugin_has_token_fee_label": "是否收取 Token 費用",
|
||||||
"custom_plugin_intro_label": "介紹",
|
"custom_plugin_intro_label": "介紹",
|
||||||
"custom_plugin_intro_placeholder": "為這個應用程式新增一個介紹",
|
"custom_plugin_intro_placeholder": "為這個應用程式新增一個介紹",
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ const ImportPluginModal = ({
|
|||||||
const isDuplicated = tools.some((tool) => tool.id.includes(toolDetail.toolId));
|
const isDuplicated = tools.some((tool) => tool.id.includes(toolDetail.toolId));
|
||||||
|
|
||||||
setUploadedFiles((prev) =>
|
setUploadedFiles((prev) =>
|
||||||
prev.map((f) =>
|
prev.map((prevFile) =>
|
||||||
f.name === file.name
|
prevFile.name === file.name
|
||||||
? {
|
? {
|
||||||
...f,
|
...prevFile,
|
||||||
status: isDuplicated ? 'duplicate' : 'success',
|
status: isDuplicated ? 'duplicate' : 'success',
|
||||||
toolId: parentId,
|
toolId: parentId,
|
||||||
toolName: parseI18nString(toolDetail.name || '', i18n.language),
|
toolName: parseI18nString(toolDetail.name || '', i18n.language),
|
||||||
@@ -97,12 +97,16 @@ const ImportPluginModal = ({
|
|||||||
return parseI18nString(currentTag?.tagName || '', i18n.language) || '';
|
return parseI18nString(currentTag?.tagName || '', i18n.language) || '';
|
||||||
}) || []
|
}) || []
|
||||||
}
|
}
|
||||||
: f
|
: prevFile
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setUploadedFiles((prev) =>
|
setUploadedFiles((prev) =>
|
||||||
prev.map((f) => (f.name === file.name ? { ...f, status: 'error', errorMsg: error } : f))
|
prev.map((prevFile) =>
|
||||||
|
prevFile.name === file.name
|
||||||
|
? { ...prevFile, status: 'error', errorMsg: error.message }
|
||||||
|
: prevFile
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -160,7 +164,7 @@ const ImportPluginModal = ({
|
|||||||
const { runAsync: handleConfirmImport, loading: confirmLoading } = useRequest2(
|
const { runAsync: handleConfirmImport, loading: confirmLoading } = useRequest2(
|
||||||
async () => {
|
async () => {
|
||||||
const successToolIds = uploadedFiles
|
const successToolIds = uploadedFiles
|
||||||
.filter((file) => file.status === 'success' && file.toolId)
|
.filter((file) => (file.status === 'success' || file.status === 'duplicate') && file.toolId)
|
||||||
.map((file) => file.toolId!);
|
.map((file) => file.toolId!);
|
||||||
|
|
||||||
await confirmPkgPluginUpload({ toolIds: successToolIds });
|
await confirmPkgPluginUpload({ toolIds: successToolIds });
|
||||||
@@ -248,11 +252,15 @@ const ImportPluginModal = ({
|
|||||||
textOverflow={'ellipsis'}
|
textOverflow={'ellipsis'}
|
||||||
whiteSpace={'nowrap'}
|
whiteSpace={'nowrap'}
|
||||||
>
|
>
|
||||||
{item.status === 'success' && item.toolName ? item.toolName : item.name}
|
{(item.status === 'success' || item.status === 'duplicate') && item.toolName
|
||||||
|
? item.toolName
|
||||||
|
: item.name}
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex w={'20%'} px={1} py={'15px'} align={'center'} gap={1} flexWrap={'wrap'}>
|
<Flex w={'20%'} px={1} py={'15px'} align={'center'} gap={1} flexWrap={'wrap'}>
|
||||||
{item.status === 'success' && item.toolTags && item.toolTags.length > 0 ? (
|
{(item.status === 'success' || item.status === 'duplicate') &&
|
||||||
|
item.toolTags &&
|
||||||
|
item.toolTags.length > 0 ? (
|
||||||
item.toolTags.map((tag, tagIndex) => (
|
item.toolTags.map((tag, tagIndex) => (
|
||||||
<Box
|
<Box
|
||||||
key={tagIndex}
|
key={tagIndex}
|
||||||
@@ -282,7 +290,9 @@ const ImportPluginModal = ({
|
|||||||
whiteSpace={'nowrap'}
|
whiteSpace={'nowrap'}
|
||||||
alignItems={'center'}
|
alignItems={'center'}
|
||||||
>
|
>
|
||||||
{item.status === 'success' && item.toolIntro ? item.toolIntro : '-'}
|
{(item.status === 'success' || item.status === 'duplicate') && item.toolIntro
|
||||||
|
? item.toolIntro
|
||||||
|
: '-'}
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex w={'10%'} px={1} py={'15px'}>
|
<Flex w={'10%'} px={1} py={'15px'}>
|
||||||
{(item.status === 'uploading' || item.status === 'parsing') && (
|
{(item.status === 'uploading' || item.status === 'parsing') && (
|
||||||
@@ -303,8 +313,10 @@ const ImportPluginModal = ({
|
|||||||
fontSize={'xs'}
|
fontSize={'xs'}
|
||||||
fontWeight={'medium'}
|
fontWeight={'medium'}
|
||||||
color={'yellow.500'}
|
color={'yellow.500'}
|
||||||
|
gap={1}
|
||||||
>
|
>
|
||||||
{t('app:custom_plugin_duplicate')}
|
{t('app:custom_plugin_duplicate')}
|
||||||
|
<QuestionTip label={t('app:custom_plugin_duplicate_tip')} />
|
||||||
</Flex>
|
</Flex>
|
||||||
)}
|
)}
|
||||||
{item.status === 'success' && (
|
{item.status === 'success' && (
|
||||||
@@ -371,7 +383,8 @@ const ImportPluginModal = ({
|
|||||||
<Button
|
<Button
|
||||||
onClick={handleConfirmImport}
|
onClick={handleConfirmImport}
|
||||||
isDisabled={
|
isDisabled={
|
||||||
uploadedFiles.length === 0 || uploadedFiles.every((f) => f.status !== 'success')
|
uploadedFiles.length === 0 ||
|
||||||
|
uploadedFiles.every((f) => f.status !== 'success' && f.status !== 'duplicate')
|
||||||
}
|
}
|
||||||
isLoading={confirmLoading || uploadLoading}
|
isLoading={confirmLoading || uploadLoading}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user