feat: add more share config (#3120)
* feat: add more share config * add i18n en
This commit is contained in:
@@ -23,6 +23,8 @@ export const defaultApp: AppDetailType = {
|
||||
export const defaultOutLinkForm: OutLinkEditType = {
|
||||
name: '',
|
||||
responseDetail: false,
|
||||
showNodeStatus: false,
|
||||
showCompleteQuote: false,
|
||||
limit: {
|
||||
QPM: 100,
|
||||
maxUsagePoints: -1
|
||||
|
||||
@@ -16,7 +16,7 @@ import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { useScrollPagination } from '@fastgpt/web/hooks/useScrollPagination';
|
||||
|
||||
type ChatContextValueType = {
|
||||
params: Record<string, string | number>;
|
||||
params: Record<string, string | number | boolean>;
|
||||
};
|
||||
type ChatContextType = {
|
||||
chatId: string;
|
||||
@@ -44,6 +44,7 @@ type ChatContextType = {
|
||||
isLoading: boolean;
|
||||
histories: ChatHistoryItemType[];
|
||||
onUpdateHistoryTitle: ({ chatId, newTitle }: { chatId: string; newTitle: string }) => void;
|
||||
showCompleteQuote: boolean;
|
||||
};
|
||||
|
||||
export const ChatContext = createContext<ChatContextType>({
|
||||
@@ -85,7 +86,8 @@ export const ChatContext = createContext<ChatContextType>({
|
||||
onChangeAppId: function (appId: string): void {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
isLoading: false
|
||||
isLoading: false,
|
||||
showCompleteQuote: true
|
||||
});
|
||||
|
||||
const ChatContextProvider = ({
|
||||
@@ -94,6 +96,7 @@ const ChatContextProvider = ({
|
||||
}: ChatContextValueType & { children: ReactNode }) => {
|
||||
const router = useRouter();
|
||||
const { chatId = '' } = router.query as { chatId: string };
|
||||
const { showCompleteQuote }: { showCompleteQuote?: boolean } = params;
|
||||
|
||||
const forbidLoadChat = useRef(false);
|
||||
|
||||
@@ -225,7 +228,8 @@ const ChatContextProvider = ({
|
||||
ScrollData,
|
||||
loadHistories,
|
||||
histories,
|
||||
onUpdateHistoryTitle
|
||||
onUpdateHistoryTitle,
|
||||
showCompleteQuote: showCompleteQuote ?? true
|
||||
};
|
||||
return <ChatContext.Provider value={contextValue}>{children}</ChatContext.Provider>;
|
||||
};
|
||||
|
||||
@@ -56,6 +56,7 @@ import type { UpdateDatasetDataProps } from '@fastgpt/global/core/dataset/contro
|
||||
import type { DatasetFolderCreateBody } from '@/pages/api/core/dataset/folder/create';
|
||||
import type { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
|
||||
import type { GetScrollCollectionsProps } from '@/pages/api/core/dataset/collection/scrollList';
|
||||
import { AuthOutLinkProps } from '@fastgpt/global/support/outLink/api';
|
||||
|
||||
/* ======================== dataset ======================= */
|
||||
export const getDatasets = (data: GetDatasetListBody) =>
|
||||
@@ -197,5 +198,6 @@ export const getPreviewChunks = (data: PostPreviewFilesChunksProps) =>
|
||||
POST<PreviewChunksResponse>('/core/dataset/file/getPreviewChunks', data);
|
||||
|
||||
/* ================== read source ======================== */
|
||||
export const getCollectionSource = (collectionId: string) =>
|
||||
GET<readCollectionSourceResponse>('/core/dataset/collection/read', { collectionId });
|
||||
export const getCollectionSource = (
|
||||
data: { collectionId: string; isShare?: boolean } & AuthOutLinkProps
|
||||
) => POST<readCollectionSourceResponse>('/core/dataset/collection/read', data);
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { authOutLink } from '@/service/support/permission/auth/outLink';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { getCollectionSource } from '@/web/core/dataset/api';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { AuthOutLinkProps } from '@fastgpt/global/support/outLink/api';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
export function getCollectionSourceAndOpen(collectionId: string) {
|
||||
export function getCollectionSourceAndOpen({
|
||||
collectionId,
|
||||
authProps,
|
||||
isShare
|
||||
}: {
|
||||
collectionId: string;
|
||||
authProps: AuthOutLinkProps;
|
||||
isShare?: boolean;
|
||||
}) {
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const { setLoading } = useSystemStore();
|
||||
@@ -12,7 +22,8 @@ export function getCollectionSourceAndOpen(collectionId: string) {
|
||||
return async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const { value: url } = await getCollectionSource(collectionId);
|
||||
|
||||
const { value: url } = await getCollectionSource({ collectionId, isShare, ...authProps });
|
||||
|
||||
if (!url) {
|
||||
throw new Error('No file found');
|
||||
|
||||
Reference in New Issue
Block a user