mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 13:38:00 +00:00
v4.5.1 (#417)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { sseResponseEventEnum, TaskResponseKeyEnum } from '@/constants/chat';
|
||||
import { getErrText } from '@/utils/tools';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { parseStreamChunk, SSEParseData } from '@/utils/sse';
|
||||
import type { ChatHistoryItemResType } from '@/types/chat';
|
||||
import { StartChatFnProps } from '@/components/ChatBox';
|
||||
import { getToken } from '@/utils/user';
|
||||
import { getToken } from '@/web/support/user/auth';
|
||||
|
||||
type StreamFetchProps = {
|
||||
url?: string;
|
||||
|
@@ -1,6 +0,0 @@
|
||||
import { GET, POST, PUT, DELETE } from './request';
|
||||
|
||||
import type { FetchResultItem } from '@/global/common/api/pluginRes.d';
|
||||
|
||||
export const postFetchUrls = (urlList: string[]) =>
|
||||
POST<FetchResultItem[]>(`/plugins/urlFetch`, { urlList });
|
@@ -4,8 +4,8 @@ import axios, {
|
||||
AxiosResponse,
|
||||
AxiosProgressEvent
|
||||
} from 'axios';
|
||||
import { clearToken, getToken } from '@/utils/user';
|
||||
import { TOKEN_ERROR_CODE } from '@fastgpt/common/constant/errorCode';
|
||||
import { clearToken, getToken } from '@/web/support/user/auth';
|
||||
import { TOKEN_ERROR_CODE } from '@fastgpt/global/common/error/errorCode';
|
||||
|
||||
interface ConfigType {
|
||||
headers?: { [key: string]: string };
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
|
||||
import type { CreateTrainingBillType } from '@/global/common/api/billReq.d';
|
||||
import type { CreateTrainingBillType } from '@fastgpt/global/common/bill/types/billReq.d';
|
||||
import type { PaySchema } from '@/types/mongoSchema';
|
||||
import type { PagingData, RequestPaging } from '@/types';
|
||||
import { UserBillType } from '@/types/user';
|
||||
import { delay } from '@/utils/tools';
|
||||
|
||||
export const getUserBills = (data: RequestPaging) =>
|
||||
POST<PagingData<UserBillType>>(`/user/getBill`, data);
|
||||
@@ -20,8 +21,14 @@ export const getPayCode = (amount: number) =>
|
||||
|
||||
export const checkPayResult = (payId: string) =>
|
||||
GET<number>(`/plusApi/support/user/pay/checkPayResult`, { payId }).then(() => {
|
||||
try {
|
||||
GET('/user/account/paySuccess');
|
||||
} catch (error) {}
|
||||
async function startQueue() {
|
||||
try {
|
||||
await GET('/user/account/paySuccess');
|
||||
} catch (error) {
|
||||
await delay(1000);
|
||||
startQueue();
|
||||
}
|
||||
}
|
||||
startQueue();
|
||||
return 'success';
|
||||
});
|
@@ -1,6 +1,6 @@
|
||||
import React, { useRef, useCallback } from 'react';
|
||||
import { Box } from '@chakra-ui/react';
|
||||
import { useToast } from './useToast';
|
||||
import { useToast } from '@/web/common/hooks/useToast';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const useSelectFile = (props?: { fileType?: string; multiple?: boolean }) => {
|
@@ -1,6 +1,6 @@
|
||||
import mammoth from 'mammoth';
|
||||
import Papa from 'papaparse';
|
||||
import { postUploadImg, postUploadFiles, getFileViewUrl } from '@/web/common/api/system';
|
||||
import { postUploadImg, postUploadFiles, getFileViewUrl } from '@/web/common/system/api';
|
||||
|
||||
/**
|
||||
* upload file to mongo gridfs
|
16
projects/app/src/web/common/hooks/useDrag.tsx
Normal file
16
projects/app/src/web/common/hooks/useDrag.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
export const useDrag = () => {
|
||||
const [moveDataId, setMoveDataId] = useState<string>();
|
||||
const [dragStartId, setDragStartId] = useState<string>();
|
||||
const [dragTargetId, setDragTargetId] = useState<string>();
|
||||
|
||||
return {
|
||||
moveDataId,
|
||||
setMoveDataId,
|
||||
dragStartId,
|
||||
setDragStartId,
|
||||
dragTargetId,
|
||||
setDragTargetId
|
||||
};
|
||||
};
|
@@ -1,12 +1,14 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import { ModalFooter, ModalBody, Input, useDisclosure, Button } from '@chakra-ui/react';
|
||||
import { ModalFooter, ModalBody, Input, useDisclosure, Button, Box } from '@chakra-ui/react';
|
||||
import MyModal from '@/components/MyModal';
|
||||
|
||||
export const useEditTitle = ({
|
||||
title,
|
||||
tip,
|
||||
placeholder = ''
|
||||
}: {
|
||||
title: string;
|
||||
tip?: string;
|
||||
placeholder?: string;
|
||||
}) => {
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
@@ -51,6 +53,12 @@ export const useEditTitle = ({
|
||||
() => (
|
||||
<MyModal isOpen={isOpen} onClose={onClose} title={title}>
|
||||
<ModalBody>
|
||||
{!!tip && (
|
||||
<Box mb={2} color={'myGray.500'} fontSize={'sm'}>
|
||||
{tip}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Input
|
||||
ref={inputRef}
|
||||
defaultValue={defaultValue.current}
|
||||
@@ -67,7 +75,7 @@ export const useEditTitle = ({
|
||||
</ModalFooter>
|
||||
</MyModal>
|
||||
),
|
||||
[isOpen, onClose, onclickConfirm, placeholder, title]
|
||||
[isOpen, onClose, onclickConfirm, placeholder, tip, title]
|
||||
);
|
||||
|
||||
return {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { useToast } from '@/web/common/hooks/useToast';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import type { UseMutationOptions } from '@tanstack/react-query';
|
||||
import { getErrText } from '@/utils/tools';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
interface Props extends UseMutationOptions<any, any, any, any> {
|
||||
|
6
projects/app/src/web/common/plugin/api.ts
Normal file
6
projects/app/src/web/common/plugin/api.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
|
||||
|
||||
import type { FetchResultItem } from '@fastgpt/global/common/plugin/types/pluginRes.d';
|
||||
|
||||
export const postFetchUrls = (urlList: string[]) =>
|
||||
POST<FetchResultItem[]>(`/plugins/urlFetch`, { urlList });
|
15
projects/app/src/web/common/plusApi/censor.ts
Normal file
15
projects/app/src/web/common/plusApi/censor.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { POST } from '@fastgpt/service/common/api/plusRequest';
|
||||
|
||||
export const postTextCensor = (data: { text: string }) =>
|
||||
POST<{ code?: number; message: string }>('/common/censor/text_baidu', data)
|
||||
.then((res) => {
|
||||
if (res?.code === 5000) {
|
||||
return Promise.reject(res);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err?.code === 5000) {
|
||||
return Promise.reject(err.message);
|
||||
}
|
||||
return Promise.resolve('');
|
||||
});
|
@@ -1,4 +1,4 @@
|
||||
import { GET, POST, PUT } from './request';
|
||||
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
|
||||
import type { InitDateResponse } from '@/global/common/api/systemRes';
|
||||
import { AxiosProgressEvent } from 'axios';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import type { InitDateResponse } from '@/global/common/api/systemRes';
|
||||
import { getSystemInitData } from '@/web/common/api/system';
|
||||
import { getSystemInitData } from '@/web/common/system/api';
|
||||
import { delay } from '@/utils/tools';
|
||||
import type { FeConfigsType } from '@fastgpt/common/type/index.d';
|
||||
import type { FeConfigsType } from '@fastgpt/global/common/system/types/index.d';
|
||||
import {
|
||||
defaultChatModels,
|
||||
defaultQAModels,
|
@@ -21,7 +21,7 @@ type State = {
|
||||
loadGitStar: () => Promise<void>;
|
||||
};
|
||||
|
||||
export const useGlobalStore = create<State>()(
|
||||
export const useSystemStore = create<State>()(
|
||||
devtools(
|
||||
persist(
|
||||
immer((set, get) => ({
|
@@ -1,5 +1,6 @@
|
||||
export enum EventNameEnum {
|
||||
guideClick = 'guideClick'
|
||||
guideClick = 'guideClick',
|
||||
updaterNode = 'updaterNode'
|
||||
}
|
||||
type EventNameType = `${EventNameEnum}`;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { useState, useCallback, useEffect, useMemo } from 'react';
|
||||
import { useToast } from '@/web/common/hooks/useToast';
|
||||
import { getErrText } from '@/utils/tools';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
|
||||
export const useAudioPlay = (props?: { ttsUrl?: string }) => {
|
||||
const { ttsUrl } = props || {};
|
||||
|
Reference in New Issue
Block a user