Global variables support external variable; Extract module support default value (#921)

This commit is contained in:
Archer
2024-03-05 14:13:22 +08:00
committed by GitHub
parent 42a8184ea0
commit af581bc903
30 changed files with 306 additions and 200 deletions

View File

@@ -4,7 +4,7 @@ import Script from 'next/script';
import Head from 'next/head';
import { ChakraProvider, ColorModeScript } from '@chakra-ui/react';
import Layout from '@/components/Layout';
import { theme } from '@/web/styles/theme';
import { theme } from '@fastgpt/web/styles/theme';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import NProgress from 'nprogress'; //nprogress module
import Router from 'next/router';

View File

@@ -31,7 +31,6 @@ import Avatar from '@/components/Avatar';
import MyIcon from '@fastgpt/web/components/common/Icon';
import VariableEdit from '@/components/core/module/Flow/components/modules/VariableEdit';
import MyTextarea from '@/components/common/Textarea/MyTextarea/index';
import { DatasetSearchModeMap } from '@fastgpt/global/core/dataset/constants';
import SelectAiModel from '@/components/Select/SelectAiModel';
import PromptEditor from '@fastgpt/web/components/common/Textarea/PromptEditor';
import { formatEditorVariablePickerIcon } from '@fastgpt/global/core/module/utils';

View File

@@ -30,24 +30,29 @@ import { MongoOutLink } from '@fastgpt/service/support/outLink/schema';
import { OutLinkWithAppType } from '@fastgpt/global/support/outLink/type';
const OutLink = ({
shareId,
chatId,
showHistory,
authToken,
appName,
appIntro,
appAvatar
}: {
shareId: string;
chatId: string;
showHistory: '0' | '1';
authToken?: string;
appName?: string;
appIntro?: string;
appAvatar?: string;
}) => {
const { t } = useTranslation();
const router = useRouter();
const {
shareId = '',
chatId = '',
showHistory = '1',
authToken,
...customVariables
} = router.query as {
shareId: string;
chatId: string;
showHistory: '0' | '1';
authToken: string;
[key: string]: string;
};
const { toast } = useToast();
const { isOpen: isOpenSlider, onClose: onCloseSlider, onOpen: onOpenSlider } = useDisclosure();
const { isPc } = useSystemStore();
@@ -56,11 +61,7 @@ const OutLink = ({
const initSign = useRef(false);
const [isEmbed, setIdEmbed] = useState(true);
const {
localUId,
shareChatHistory, // abandon
clearLocalHistory // abandon
} = useShareChatStore();
const { localUId } = useShareChatStore();
const {
histories,
loadHistories,
@@ -83,7 +84,10 @@ const OutLink = ({
const { responseText, responseData } = await streamFetch({
data: {
messages: prompts,
variables,
variables: {
...customVariables,
...variables
},
shareId,
chatId: completionChatId,
outLinkUid
@@ -159,6 +163,7 @@ const OutLink = ({
},
[
chatId,
customVariables,
shareId,
outLinkUid,
t,
@@ -391,9 +396,6 @@ const OutLink = ({
export async function getServerSideProps(context: any) {
const shareId = context?.query?.shareId || '';
const chatId = context?.query?.chatId || '';
const showHistory = context?.query?.showHistory || '1';
const authToken = context?.query?.authToken || '';
const app = await (async () => {
try {
@@ -413,13 +415,9 @@ export async function getServerSideProps(context: any) {
return {
props: {
shareId,
chatId,
showHistory,
authToken,
appName: app?.appId?.name,
appAvatar: app?.appId?.avatar,
appIntro: app?.appId?.intro,
appName: app?.appId?.name || '',
appAvatar: app?.appId?.avatar || '',
appIntro: app?.appId?.intro || '',
...(await serviceSideProps(context))
}
};

View File

@@ -85,7 +85,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
}
setRequesting(false);
},
[loginSuccess, toast]
[loginSuccess, t, toast]
);
return (

View File

@@ -57,11 +57,10 @@ const Login = () => {
/* default login type */
useEffect(() => {
if (!feConfigs.oauth) return;
setPageType(
feConfigs.oauth?.wechat ? LoginPageTypeEnum.wechat : LoginPageTypeEnum.passwordLogin
feConfigs?.oauth?.wechat ? LoginPageTypeEnum.wechat : LoginPageTypeEnum.passwordLogin
);
}, [feConfigs.oauth, feConfigs.oauth?.wechat]);
}, [feConfigs.oauth]);
useEffect(() => {
clearToken();
router.prefetch('/app/list');