fix: price page init data;perf: usage code;fix: reasoning tokens;fix: workflow basic node cannot upgrade (#3816)
* fix: img read * fix: price page init data * perf: ai model avatar * perf: refresh in change team * perf: null checker * perf: usage code * fix: reasoning tokens * fix: workflow basic node cannot upgrade * perf: model refresh * perf: icon refresh
This commit is contained in:
@@ -13,11 +13,11 @@ import { useRouter } from 'next/router';
|
||||
|
||||
const TeamSelector = ({
|
||||
showManage,
|
||||
afterSwitchTeam,
|
||||
onChange,
|
||||
...props
|
||||
}: ButtonProps & {
|
||||
}: Omit<ButtonProps, 'onChange'> & {
|
||||
showManage?: boolean;
|
||||
afterSwitchTeam?: () => void;
|
||||
onChange?: () => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
@@ -38,7 +38,7 @@ const TeamSelector = ({
|
||||
{
|
||||
onFinally: () => {
|
||||
setLoading(false);
|
||||
afterSwitchTeam?.();
|
||||
onChange?.();
|
||||
},
|
||||
errorToast: t('common:user.team.Switch Team Failed')
|
||||
}
|
||||
|
||||
@@ -142,19 +142,36 @@ const NodeCard = (props: Props) => {
|
||||
|
||||
const { runAsync: onClickSyncVersion } = useRequest2(
|
||||
async () => {
|
||||
if (!node?.pluginId) return;
|
||||
const template = await getPreviewPluginNode({ appId: node.pluginId });
|
||||
if (!node) return;
|
||||
|
||||
if (!!template) {
|
||||
if (node.pluginId) {
|
||||
const template = await getPreviewPluginNode({ appId: node.pluginId });
|
||||
|
||||
if (!!template) {
|
||||
onResetNode({
|
||||
id: nodeId,
|
||||
node: template
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const template = moduleTemplatesFlat.find(
|
||||
(item) => item.flowNodeType === node.flowNodeType
|
||||
);
|
||||
if (!template) {
|
||||
return toast({
|
||||
title: t('app:app.modules.not_found_tips'),
|
||||
status: 'warning'
|
||||
});
|
||||
}
|
||||
onResetNode({
|
||||
id: nodeId,
|
||||
node: template
|
||||
});
|
||||
}
|
||||
onCloseConfirmSync();
|
||||
},
|
||||
{
|
||||
refreshDeps: [node, nodeId, onResetNode]
|
||||
refreshDeps: [node, nodeId, onResetNode],
|
||||
onFinally() {}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -311,7 +328,6 @@ const NodeCard = (props: Props) => {
|
||||
</Box>
|
||||
)}
|
||||
<MenuRender nodeId={nodeId} menuForbid={menuForbid} nodeList={nodeList} />
|
||||
<ConfirmSyncModal />
|
||||
</Box>
|
||||
);
|
||||
}, [
|
||||
@@ -335,7 +351,6 @@ const NodeCard = (props: Props) => {
|
||||
intro,
|
||||
menuForbid,
|
||||
nodeList,
|
||||
ConfirmSyncModal,
|
||||
onChangeNode,
|
||||
onOpenCustomTitleModal,
|
||||
toast
|
||||
|
||||
@@ -7,7 +7,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import React, { DragEvent, useCallback, useMemo, useState } from 'react';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { useRequest } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { getFileIcon } from '@fastgpt/global/common/file/icon';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { uploadFile2DB } from '@/web/common/file/controller';
|
||||
@@ -66,9 +66,50 @@ const FileSelector = ({
|
||||
'i'
|
||||
);
|
||||
|
||||
const { mutate: onSelectFile, isLoading } = useRequest({
|
||||
mutationFn: async (files: SelectFileItemType[]) => {
|
||||
const { runAsync: onSelectFile, loading: isLoading } = useRequest2(
|
||||
async (files: SelectFileItemType[]) => {
|
||||
{
|
||||
await Promise.all(
|
||||
files.map(async ({ fileId, file }) => {
|
||||
const { fileId: uploadFileId } = await uploadFile2DB({
|
||||
file,
|
||||
bucketName: BucketNameEnum.dataset,
|
||||
data: {
|
||||
datasetId
|
||||
},
|
||||
percentListen: (e) => {
|
||||
setSelectFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === fileId
|
||||
? {
|
||||
...item,
|
||||
uploadedFileRate: item.uploadedFileRate
|
||||
? Math.max(e, item.uploadedFileRate)
|
||||
: e
|
||||
}
|
||||
: item
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
setSelectFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === fileId
|
||||
? {
|
||||
...item,
|
||||
dbFileId: uploadFileId,
|
||||
isUploading: false,
|
||||
uploadedFileRate: 100
|
||||
}
|
||||
: item
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
onBefore([files]) {
|
||||
onStartSelect();
|
||||
setSelectFiles((state) => {
|
||||
const formatFiles = files.map<ImportSourceItemType>((selectFile) => {
|
||||
@@ -88,52 +129,12 @@ const FileSelector = ({
|
||||
const results = formatFiles.concat(state).slice(0, maxCount);
|
||||
return results;
|
||||
});
|
||||
try {
|
||||
// upload file
|
||||
await Promise.all(
|
||||
files.map(async ({ fileId, file }) => {
|
||||
const { fileId: uploadFileId } = await uploadFile2DB({
|
||||
file,
|
||||
bucketName: BucketNameEnum.dataset,
|
||||
data: {
|
||||
datasetId
|
||||
},
|
||||
percentListen: (e) => {
|
||||
setSelectFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === fileId
|
||||
? {
|
||||
...item,
|
||||
uploadedFileRate: item.uploadedFileRate
|
||||
? Math.max(e, item.uploadedFileRate)
|
||||
: e
|
||||
}
|
||||
: item
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
setSelectFiles((state) =>
|
||||
state.map((item) =>
|
||||
item.id === fileId
|
||||
? {
|
||||
...item,
|
||||
dbFileId: uploadFileId,
|
||||
isUploading: false,
|
||||
uploadedFileRate: 100
|
||||
}
|
||||
: item
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
onFinally() {
|
||||
onFinishSelect();
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
const selectFileCallback = useCallback(
|
||||
(files: SelectFileItemType[]) => {
|
||||
|
||||
Reference in New Issue
Block a user