4.8.16 test (#3442)

* perf: simple app save

* fix: notify config i18n

* perf: service side props render

* perf: model selector

* update doc
This commit is contained in:
Archer
2024-12-20 18:58:40 +08:00
committed by GitHub
parent 922cb433d3
commit e6d53e3daa
77 changed files with 878 additions and 326 deletions

View File

@@ -1,5 +1,6 @@
import { useTranslation } from 'next-i18next';
import { useEffect } from 'react';
import { isProduction } from '@fastgpt/global/common/system/constants';
export const useBeforeunload = (props?: { callback?: () => any; tip?: string }) => {
const { t } = useTranslation();
@@ -7,16 +8,15 @@ export const useBeforeunload = (props?: { callback?: () => any; tip?: string })
const { tip = t('common:common.Confirm to leave the page'), callback } = props || {};
useEffect(() => {
const listen =
process.env.NODE_ENV === 'production'
? (e: any) => {
e.preventDefault();
e.returnValue = tip;
callback?.();
}
: () => {
callback?.();
};
const listen = isProduction
? (e: any) => {
e.preventDefault();
e.returnValue = tip;
callback?.();
}
: () => {
callback?.();
};
window.addEventListener('beforeunload', listen);
return () => {

View File

@@ -1,7 +1,8 @@
import { useMediaQuery } from '@chakra-ui/react';
import { useSystemStoreContext } from '../context/useSystem';
import { useContextSelector } from 'use-context-selector';
export const useSystem = () => {
const [isPc] = useMediaQuery('(min-width: 900px)');
const isPc = useContextSelector(useSystemStoreContext, (state) => state.isPc);
return { isPc };
};