mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 11:43:56 +00:00
fix: load member list (#2536)
* fix: load member list * fix: extract field type error * fix: workflow runtime error * fix: ts
This commit is contained in:
@@ -67,3 +67,5 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4810' \
|
||||
18. 修复 - 选择 Milvus 部署时,无法导出知识库。
|
||||
19. 修复 - 创建 APP 副本,无法复制系统配置。
|
||||
20. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
|
||||
21. 修复 - 内容提取的数据类型与输出数据类型未一致。
|
||||
22. 修复 - 工作流运行时间统计错误。
|
||||
|
@@ -1,5 +1,10 @@
|
||||
import { WorkflowIOValueTypeEnum } from '../../../constants';
|
||||
|
||||
export type ContextExtractAgentItemType = {
|
||||
valueType: 'string' | 'number' | 'boolean';
|
||||
valueType:
|
||||
| WorkflowIOValueTypeEnum.string
|
||||
| WorkflowIOValueTypeEnum.number
|
||||
| WorkflowIOValueTypeEnum.boolean;
|
||||
desc: string;
|
||||
key: string;
|
||||
required: boolean;
|
||||
|
@@ -46,6 +46,7 @@ const ResponseTags = ({
|
||||
};
|
||||
}>();
|
||||
const [quoteFolded, setQuoteFolded] = useState<boolean>(true);
|
||||
|
||||
const {
|
||||
isOpen: isOpenWholeModal,
|
||||
onOpen: onOpenWholeModal,
|
||||
@@ -56,6 +57,7 @@ const ResponseTags = ({
|
||||
onOpen: onOpenContextModal,
|
||||
onClose: onCloseContextModal
|
||||
} = useDisclosure();
|
||||
|
||||
useSize(quoteListRef);
|
||||
const quoteIsOverflow = quoteListRef.current
|
||||
? quoteListRef.current.scrollHeight > (isPc ? 50 : 55)
|
||||
|
@@ -100,7 +100,7 @@ const WholeResponseModal = ({
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { appId, chatId, getHistoryResponseData } = useContextSelector(ChatBoxContext, (v) => v);
|
||||
const { getHistoryResponseData } = useContextSelector(ChatBoxContext, (v) => v);
|
||||
const { loading: isLoading, data: response } = useRequest2(
|
||||
() => getHistoryResponseData({ dataId }),
|
||||
{
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { getTeamMembers } from '@/web/support/user/team/api';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import {
|
||||
Box,
|
||||
Flex,
|
||||
@@ -31,11 +31,13 @@ export function ChangeOwnerModal({
|
||||
onChangeOwner
|
||||
}: ChangeOwnerModalProps & { onClose: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const { loadAndGetTeamMembers } = useUserStore();
|
||||
|
||||
const [inputValue, setInputValue] = React.useState('');
|
||||
const { data: teamMembers = [] } = useRequest2(getTeamMembers, {
|
||||
|
||||
const { data: teamMembers = [] } = useRequest2(loadAndGetTeamMembers, {
|
||||
manual: false
|
||||
});
|
||||
|
||||
const memberList = teamMembers.filter((item) => {
|
||||
return item.memberName.includes(inputValue);
|
||||
});
|
||||
|
@@ -20,7 +20,6 @@ import PermissionSelect from './PermissionSelect';
|
||||
import PermissionTags from './PermissionTags';
|
||||
import { CollaboratorContext } from './context';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { getTeamMembers } from '@/web/support/user/team/api';
|
||||
import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||
import { ChevronDownIcon } from '@chakra-ui/icons';
|
||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
@@ -33,15 +32,16 @@ export type AddModalPropsType = {
|
||||
|
||||
function AddMemberModal({ onClose }: AddModalPropsType) {
|
||||
const { t } = useTranslation();
|
||||
const { userInfo } = useUserStore();
|
||||
const { userInfo, loadAndGetTeamMembers } = useUserStore();
|
||||
|
||||
const { permissionList, collaboratorList, onUpdateCollaborators, getPerLabelList } =
|
||||
useContextSelector(CollaboratorContext, (v) => v);
|
||||
const [searchText, setSearchText] = useState<string>('');
|
||||
|
||||
const { data: members = [], loading: loadingMembers } = useRequest2(
|
||||
async () => {
|
||||
if (!userInfo?.team?.teamId) return [];
|
||||
const members = await getTeamMembers();
|
||||
const members = await loadAndGetTeamMembers(true);
|
||||
return members;
|
||||
},
|
||||
{
|
||||
|
@@ -6,7 +6,6 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import {
|
||||
delMemberPermission,
|
||||
getTeamList,
|
||||
getTeamMembers,
|
||||
putSwitchTeam,
|
||||
updateMemberPermission
|
||||
} from '@/web/support/user/team/api';
|
||||
@@ -56,7 +55,7 @@ export const TeamModalContext = createContext<TeamModalContextType>({
|
||||
export const TeamModalContextProvider = ({ children }: { children: ReactNode }) => {
|
||||
const { t } = useTranslation();
|
||||
const [editTeamData, setEditTeamData] = useState<EditTeamFormDataType>();
|
||||
const { userInfo, initUserInfo } = useUserStore();
|
||||
const { userInfo, initUserInfo, loadAndGetTeamMembers } = useUserStore();
|
||||
|
||||
const {
|
||||
data: myTeams = [],
|
||||
@@ -72,7 +71,7 @@ export const TeamModalContextProvider = ({ children }: { children: ReactNode })
|
||||
} = useRequest2(
|
||||
() => {
|
||||
if (!userInfo?.team?.teamId) return Promise.resolve([]);
|
||||
return getTeamMembers();
|
||||
return loadAndGetTeamMembers();
|
||||
},
|
||||
{
|
||||
manual: false,
|
||||
|
@@ -27,6 +27,7 @@ export function addStatisticalDataToHistoryItem(historyItem: ChatItemType) {
|
||||
return item;
|
||||
})
|
||||
.flat() || [];
|
||||
|
||||
return {
|
||||
...historyItem,
|
||||
llmModuleAccount: flatResData.filter(isLLMNode).length,
|
||||
@@ -36,7 +37,7 @@ export function addStatisticalDataToHistoryItem(historyItem: ChatItemType) {
|
||||
.flat()
|
||||
.filter(Boolean) as SearchDataResponseItemType[],
|
||||
totalRunningTime: Number(
|
||||
flatResData.reduce((sum, item) => sum + (item.runningTime || 0), 0).toFixed(2)
|
||||
historyItem.responseData?.reduce((sum, item) => sum + (item.runningTime || 0), 0).toFixed(2)
|
||||
),
|
||||
historyPreviewLength: flatResData.find(isLLMNode)?.historyPreview?.length
|
||||
};
|
||||
|
@@ -26,7 +26,6 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { getTeamMembers } from '@/web/support/user/team/api';
|
||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
import MySelect from '@fastgpt/web/components/common/MySelect';
|
||||
import { formatNumber } from '@fastgpt/global/common/math/tools';
|
||||
@@ -43,7 +42,7 @@ const UsageTable = () => {
|
||||
});
|
||||
const [usageSource, setUsageSource] = useState<UsageSourceEnum | ''>('');
|
||||
const { isPc } = useSystem();
|
||||
const { userInfo } = useUserStore();
|
||||
const { userInfo, loadAndGetTeamMembers } = useUserStore();
|
||||
const [usageDetail, setUsageDetail] = useState<UsageItemType>();
|
||||
|
||||
const sourceList = useMemo(
|
||||
@@ -64,7 +63,7 @@ const UsageTable = () => {
|
||||
const [selectTmbId, setSelectTmbId] = useState(userInfo?.team?.tmbId);
|
||||
const { data: members = [] } = useQuery(['getMembers', userInfo?.team?.teamId], () => {
|
||||
if (!userInfo?.team?.teamId) return [];
|
||||
return getTeamMembers();
|
||||
return loadAndGetTeamMembers();
|
||||
});
|
||||
const tmbList = useMemo(
|
||||
() =>
|
||||
|
@@ -20,7 +20,7 @@ import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
|
||||
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
|
||||
export const defaultField: ContextExtractAgentItemType = {
|
||||
valueType: 'string',
|
||||
valueType: WorkflowIOValueTypeEnum.string,
|
||||
required: false,
|
||||
defaultValue: '',
|
||||
desc: '',
|
||||
|
@@ -198,7 +198,7 @@ const NodeExtract = ({ data }: NodeProps<FlowNodeItemType>) => {
|
||||
id: getNanoid(),
|
||||
key: data.key,
|
||||
label: `${t('common:extraction_results')}-${data.desc}`,
|
||||
valueType: WorkflowIOValueTypeEnum.string,
|
||||
valueType: data.valueType || WorkflowIOValueTypeEnum.string,
|
||||
type: FlowNodeOutputTypeEnum.static
|
||||
};
|
||||
|
||||
@@ -215,7 +215,8 @@ const NodeExtract = ({ data }: NodeProps<FlowNodeItemType>) => {
|
||||
key: data.key,
|
||||
value: {
|
||||
...output,
|
||||
label: `${t('common:extraction_results')}-${data.desc}`
|
||||
valueType: newOutput.valueType,
|
||||
label: newOutput.label
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@@ -6,7 +6,6 @@ import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
import PermissionIconText from '@/components/support/permission/IconText';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||
@@ -35,19 +34,19 @@ const ConfigPerModal = dynamic(() => import('@/components/support/permission/Con
|
||||
|
||||
import type { EditHttpPluginProps } from './HttpPluginEditModal';
|
||||
import { postCopyApp } from '@/web/core/app/api/app';
|
||||
import { getTeamMembers } from '@/web/support/user/team/api';
|
||||
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
|
||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useChatStore } from '@/web/core/chat/context/storeChat';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
const HttpEditModal = dynamic(() => import('./HttpPluginEditModal'));
|
||||
|
||||
const ListItem = () => {
|
||||
const { t } = useTranslation();
|
||||
const { appT, commonT } = useI18n();
|
||||
const router = useRouter();
|
||||
const { parentId = null } = router.query;
|
||||
const { isPc } = useSystem();
|
||||
|
||||
const { loadAndGetTeamMembers } = useUserStore();
|
||||
const { lastChatAppId, setLastChatAppId } = useChatStore();
|
||||
|
||||
const { myApps, loadMyApps, onUpdateApp, setMoveAppId, folderDetail } = useContextSelector(
|
||||
@@ -59,7 +58,6 @@ const ListItem = () => {
|
||||
const [editedApp, setEditedApp] = useState<EditResourceInfoFormType>();
|
||||
const [editHttpPlugin, setEditHttpPlugin] = useState<EditHttpPluginProps>();
|
||||
const [editPerAppIndex, setEditPerAppIndex] = useState<number>();
|
||||
const { feConfigs } = useSystemStore();
|
||||
|
||||
const editPerApp = useMemo(
|
||||
() => (editPerAppIndex !== undefined ? myApps[editPerAppIndex] : undefined),
|
||||
@@ -100,18 +98,18 @@ const ListItem = () => {
|
||||
);
|
||||
|
||||
const { openConfirm: openConfirmCopy, ConfirmModal: ConfirmCopyModal } = useConfirm({
|
||||
content: appT('confirm_copy_app_tip')
|
||||
content: t('app:confirm_copy_app_tip')
|
||||
});
|
||||
const { runAsync: onclickCopy } = useRequest2(postCopyApp, {
|
||||
onSuccess({ appId }) {
|
||||
router.push(`/app/detail?appId=${appId}`);
|
||||
loadMyApps();
|
||||
},
|
||||
successToast: appT('create_copy_success')
|
||||
successToast: t('app:create_copy_success')
|
||||
});
|
||||
|
||||
const { data: members = [] } = useRequest2(getTeamMembers, {
|
||||
manual: !feConfigs.isPlus
|
||||
const { data: members = [] } = useRequest2(loadAndGetTeamMembers, {
|
||||
manual: false
|
||||
});
|
||||
|
||||
const { runAsync: onResumeInheritPermission } = useRequest2(
|
||||
@@ -120,7 +118,7 @@ const ListItem = () => {
|
||||
},
|
||||
{
|
||||
manual: true,
|
||||
errorToast: commonT('permission.Resume InheritPermission Failed'),
|
||||
errorToast: t('common:permission.Resume InheritPermission Failed'),
|
||||
onSuccess() {
|
||||
loadMyApps();
|
||||
}
|
||||
@@ -267,7 +265,7 @@ const ListItem = () => {
|
||||
children: [
|
||||
{
|
||||
icon: 'core/chat/chatLight',
|
||||
label: appT('go_to_chat'),
|
||||
label: t('app:go_to_chat'),
|
||||
onClick: () => {
|
||||
router.push(`/chat?appId=${app._id}`);
|
||||
}
|
||||
@@ -282,7 +280,7 @@ const ListItem = () => {
|
||||
children: [
|
||||
{
|
||||
icon: 'core/chat/chatLight',
|
||||
label: appT('go_to_run'),
|
||||
label: t('app:go_to_run'),
|
||||
onClick: () => {
|
||||
router.push(`/chat?appId=${app._id}`);
|
||||
}
|
||||
@@ -342,7 +340,7 @@ const ListItem = () => {
|
||||
children: [
|
||||
{
|
||||
icon: 'copy',
|
||||
label: appT('copy_one_app'),
|
||||
label: t('app:copy_one_app'),
|
||||
onClick: () =>
|
||||
openConfirmCopy(() => onclickCopy({ appId: app._id }))()
|
||||
}
|
||||
@@ -363,8 +361,8 @@ const ListItem = () => {
|
||||
() => onclickDelApp(app._id),
|
||||
undefined,
|
||||
app.type === AppTypeEnum.folder
|
||||
? appT('confirm_delete_folder_tip')
|
||||
: appT('confirm_del_app_tip')
|
||||
? t('app:confirm_delete_folder_tip')
|
||||
: t('app:confirm_del_app_tip')
|
||||
)()
|
||||
}
|
||||
]
|
||||
|
@@ -8,6 +8,7 @@ import { FeTeamPlanStatusType } from '@fastgpt/global/support/wallet/sub/type';
|
||||
import { getTeamPlanStatus } from './team/api';
|
||||
import { getTeamMembers } from '@/web/support/user/team/api';
|
||||
import { TeamMemberItemType } from '@fastgpt/global/support/user/team/type';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
|
||||
type State = {
|
||||
systemMsgReadId: string;
|
||||
@@ -22,7 +23,7 @@ type State = {
|
||||
initTeamPlanStatus: () => Promise<any>;
|
||||
|
||||
teamMembers: TeamMemberItemType[];
|
||||
loadAndGetTeamMembers: () => Promise<TeamMemberItemType[]>;
|
||||
loadAndGetTeamMembers: (init?: boolean) => Promise<TeamMemberItemType[]>;
|
||||
};
|
||||
|
||||
export const useUserStore = create<State>()(
|
||||
@@ -85,8 +86,12 @@ export const useUserStore = create<State>()(
|
||||
});
|
||||
},
|
||||
teamMembers: [],
|
||||
loadAndGetTeamMembers: async () => {
|
||||
if (get().teamMembers.length) return Promise.resolve(get().teamMembers);
|
||||
loadAndGetTeamMembers: async (init = false) => {
|
||||
if (!useSystemStore.getState()?.feConfigs?.isPlus) return [];
|
||||
|
||||
const randomRefresh = Math.random() > 0.7;
|
||||
if (!randomRefresh && !init && get().teamMembers.length)
|
||||
return Promise.resolve(get().teamMembers);
|
||||
|
||||
const res = await getTeamMembers();
|
||||
set((state) => {
|
||||
|
Reference in New Issue
Block a user