fix: config
This commit is contained in:
@@ -37,15 +37,15 @@ function App({ Component, pageProps }: AppProps) {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const [googleClientVerKey, setGoogleVerKey] = useState<string>();
|
||||
const [baiduTongji, setBaiduTongji] = useState<string>();
|
||||
const [baiduTongjiUrl, setBaiduTongjiUrl] = useState<string>();
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const {
|
||||
systemEnv: { googleClientVerKey, baiduTongji }
|
||||
feConfigs: { googleClientVerKey, baiduTongjiUrl }
|
||||
} = await clientInitData();
|
||||
setGoogleVerKey(googleClientVerKey);
|
||||
setBaiduTongji(baiduTongji);
|
||||
setBaiduTongjiUrl(baiduTongjiUrl);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
@@ -69,7 +69,7 @@ function App({ Component, pageProps }: AppProps) {
|
||||
<Script src="/js/qrcode.min.js" strategy="lazyOnload"></Script>
|
||||
<Script src="/js/pdf.js" strategy="lazyOnload"></Script>
|
||||
<Script src="/js/html2pdf.bundle.min.js" strategy="lazyOnload"></Script>
|
||||
{baiduTongji && <Script src={baiduTongji} strategy="lazyOnload"></Script>}
|
||||
{baiduTongjiUrl && <Script src={baiduTongjiUrl} strategy="lazyOnload"></Script>}
|
||||
{googleClientVerKey && (
|
||||
<>
|
||||
<Script
|
||||
|
||||
@@ -28,10 +28,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
export async function sensitiveCheck({ input }: Props) {
|
||||
if (!global.systemEnv.sensitiveCheck) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
...axiosConfig(),
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FeConfigsType, SystemEnvType } from '@/types';
|
||||
import type { FeConfigsType } from '@/types';
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { readFileSync } from 'fs';
|
||||
@@ -12,7 +12,6 @@ export type InitDateResponse = {
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModels: QAModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
systemEnv: SystemEnvType;
|
||||
feConfigs: FeConfigsType;
|
||||
};
|
||||
|
||||
@@ -22,7 +21,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
jsonRes<InitDateResponse>(res, {
|
||||
data: {
|
||||
systemEnv: global.systemEnv,
|
||||
feConfigs: global.feConfigs,
|
||||
chatModels: global.chatModels,
|
||||
qaModels: global.qaModels,
|
||||
@@ -34,8 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
const defaultSystemEnv = {
|
||||
vectorMaxProcess: 15,
|
||||
qaMaxProcess: 15,
|
||||
pgIvfflatProbe: 20,
|
||||
sensitiveCheck: false
|
||||
pgIvfflatProbe: 20
|
||||
};
|
||||
const defaultFeConfigs = {
|
||||
show_emptyChat: true,
|
||||
@@ -102,7 +99,7 @@ export async function getInitConfig() {
|
||||
global.vectorModels = res.VectorModels || defaultVectorModels;
|
||||
} catch (error) {
|
||||
setDefaultData();
|
||||
console.log('get init config error, set default');
|
||||
console.log('get init config error, set default', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
|
||||
import { Card, Box, Link, Flex, Image, Button } from '@chakra-ui/react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import { beianText } from '@/store/static';
|
||||
import { feConfigs } from '@/store/static';
|
||||
import { serviceSideProps } from '@/utils/i18n';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -215,19 +214,17 @@ const Home = () => {
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
{feConfigs?.authorText && (
|
||||
<Box w={'100%'} mt={'100vh'} px={[5, 10]} pb={[5, 10]}>
|
||||
<Card p={5} mt={4} textAlign={'center'}>
|
||||
{beianText && (
|
||||
<Link href="https://beian.miit.gov.cn/" target="_blank">
|
||||
{beianText}
|
||||
</Link>
|
||||
)}
|
||||
<Box w={'100%'} mt={'100vh'} px={[5, 10]} pb={[5, 10]}>
|
||||
<Card p={5} mt={4} textAlign={'center'}>
|
||||
{feConfigs?.beianText && (
|
||||
<Link href="https://beian.miit.gov.cn/" target="_blank">
|
||||
{feConfigs.beianText}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<Box>{feConfigs?.authorText}</Box>
|
||||
</Card>
|
||||
</Box>
|
||||
)}
|
||||
{feConfigs?.authorText && <Box>{feConfigs?.authorText}</Box>}
|
||||
</Card>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user