mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
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:
@@ -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 () => {
|
||||
|
@@ -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 };
|
||||
};
|
||||
|
Reference in New Issue
Block a user