mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
feat: data config set scripts
This commit is contained in:
@@ -7,7 +7,8 @@
|
|||||||
"show_git": true,
|
"show_git": true,
|
||||||
"systemTitle": "FastGPT",
|
"systemTitle": "FastGPT",
|
||||||
"authorText": "Made by FastGPT Team.",
|
"authorText": "Made by FastGPT Team.",
|
||||||
"gitLoginKey": ""
|
"gitLoginKey": "",
|
||||||
|
"scripts": []
|
||||||
},
|
},
|
||||||
"SystemParams": {
|
"SystemParams": {
|
||||||
"gitLoginSecret": "",
|
"gitLoginSecret": "",
|
||||||
|
@@ -15,6 +15,7 @@ import { useRouter } from 'next/router';
|
|||||||
|
|
||||||
import 'nprogress/nprogress.css';
|
import 'nprogress/nprogress.css';
|
||||||
import '@/styles/reset.scss';
|
import '@/styles/reset.scss';
|
||||||
|
import { FeConfigsType } from '@/types';
|
||||||
|
|
||||||
//Binding events.
|
//Binding events.
|
||||||
Router.events.on('routeChangeStart', () => NProgress.start());
|
Router.events.on('routeChangeStart', () => NProgress.start());
|
||||||
@@ -36,16 +37,16 @@ function App({ Component, pageProps }: AppProps) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
|
|
||||||
|
const [scripts, setScripts] = useState<FeConfigsType['scripts']>([]);
|
||||||
const [googleClientVerKey, setGoogleVerKey] = useState<string>();
|
const [googleClientVerKey, setGoogleVerKey] = useState<string>();
|
||||||
const [baiduTongjiUrl, setBaiduTongjiUrl] = useState<string>();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const {
|
const {
|
||||||
feConfigs: { googleClientVerKey, baiduTongjiUrl }
|
feConfigs: { scripts, googleClientVerKey }
|
||||||
} = await clientInitData();
|
} = await clientInitData();
|
||||||
|
setScripts(scripts || []);
|
||||||
setGoogleVerKey(googleClientVerKey);
|
setGoogleVerKey(googleClientVerKey);
|
||||||
setBaiduTongjiUrl(baiduTongjiUrl);
|
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -68,12 +69,14 @@ function App({ Component, pageProps }: AppProps) {
|
|||||||
<Script src="/js/qrcode.min.js" strategy="lazyOnload"></Script>
|
<Script src="/js/qrcode.min.js" strategy="lazyOnload"></Script>
|
||||||
<Script src="/js/pdf.js" strategy="lazyOnload"></Script>
|
<Script src="/js/pdf.js" strategy="lazyOnload"></Script>
|
||||||
<Script src="/js/html2pdf.bundle.min.js" strategy="lazyOnload"></Script>
|
<Script src="/js/html2pdf.bundle.min.js" strategy="lazyOnload"></Script>
|
||||||
{baiduTongjiUrl && <Script src={baiduTongjiUrl} strategy="lazyOnload"></Script>}
|
{scripts?.map((item, i) => (
|
||||||
|
<Script key={i} strategy="lazyOnload" {...item}></Script>
|
||||||
|
))}
|
||||||
{googleClientVerKey && (
|
{googleClientVerKey && (
|
||||||
<>
|
<>
|
||||||
<Script
|
<Script
|
||||||
src={`https://www.recaptcha.net/recaptcha/api.js?render=${googleClientVerKey}`}
|
src={`https://www.recaptcha.net/recaptcha/api.js?render=${googleClientVerKey}`}
|
||||||
strategy="afterInteractive"
|
strategy="lazyOnload"
|
||||||
></Script>
|
></Script>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
2
client/src/types/index.d.ts
vendored
2
client/src/types/index.d.ts
vendored
@@ -23,8 +23,8 @@ export type FeConfigsType = {
|
|||||||
authorText?: string;
|
authorText?: string;
|
||||||
beianText?: string;
|
beianText?: string;
|
||||||
googleClientVerKey?: string;
|
googleClientVerKey?: string;
|
||||||
baiduTongjiUrl?: string;
|
|
||||||
gitLoginKey?: string;
|
gitLoginKey?: string;
|
||||||
|
scripts?: { [key: string]: string }[];
|
||||||
};
|
};
|
||||||
export type SystemEnvType = {
|
export type SystemEnvType = {
|
||||||
googleServiceVerKey?: string;
|
googleServiceVerKey?: string;
|
||||||
|
Reference in New Issue
Block a user