Commit 8151350d by archer

fix: register

parent 32395346
...@@ -11,7 +11,13 @@ import React, { ...@@ -11,7 +11,13 @@ import React, {
import { throttle } from 'lodash'; import { throttle } from 'lodash';
import { ChatItemType, ChatSiteItemType, ExportChatType } from '@/types/chat'; import { ChatItemType, ChatSiteItemType, ExportChatType } from '@/types/chat';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { useCopyData, voiceBroadcast, hasVoiceApi, getErrText } from '@/utils/tools'; import {
useCopyData,
voiceBroadcast,
cancelBroadcast,
hasVoiceApi,
getErrText
} from '@/utils/tools';
import { Box, Card, Flex, Input, Textarea, Button, useTheme } from '@chakra-ui/react'; import { Box, Card, Flex, Input, Textarea, Button, useTheme } from '@chakra-ui/react';
import { useUserStore } from '@/store/user'; import { useUserStore } from '@/store/user';
import { feConfigs } from '@/store/static'; import { feConfigs } from '@/store/static';
...@@ -387,7 +393,6 @@ const ChatBox = ( ...@@ -387,7 +393,6 @@ const ChatBox = (
zIndex: 1, zIndex: 1,
w: '100%' w: '100%'
}; };
console.log(ChatBoxRef.current?.clientWidth);
const messageCardMaxW = ['calc(100% - 48px)', 'calc(100% - 65px)']; const messageCardMaxW = ['calc(100% - 48px)', 'calc(100% - 65px)'];
...@@ -404,9 +409,22 @@ const ChatBox = ( ...@@ -404,9 +409,22 @@ const ChatBox = (
useEffect(() => { useEffect(() => {
return () => { return () => {
controller.current?.abort(); controller.current?.abort();
// close voice
cancelBroadcast();
}; };
}, [router.query]); }, [router.query]);
useEffect(() => {
const listen = () => {
cancelBroadcast();
};
window.addEventListener('beforeunload', listen);
return () => {
window.removeEventListener('beforeunload', listen);
};
}, []);
return ( return (
<Flex flexDirection={'column'} h={'100%'}> <Flex flexDirection={'column'} h={'100%'}>
<Box <Box
......
...@@ -35,9 +35,9 @@ function App({ Component, pageProps, isPc }: AppProps & { isPc?: boolean; respon ...@@ -35,9 +35,9 @@ function App({ Component, pageProps, isPc }: AppProps & { isPc?: boolean; respon
const [baiduTongji, setBaiduTongji] = useState<string>(); const [baiduTongji, setBaiduTongji] = useState<string>();
const { initIsPc } = useGlobalStore(); const { initIsPc } = useGlobalStore();
if (isPc !== undefined) { // if (isPc !== undefined) {
initIsPc(isPc); // initIsPc(isPc);
} // }
useEffect(() => { useEffect(() => {
(async () => { (async () => {
......
...@@ -64,16 +64,17 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => { ...@@ -64,16 +64,17 @@ const AppDetail = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
); );
useEffect(() => { useEffect(() => {
window.onbeforeunload = const listen =
process.env.NODE_ENV === 'production' process.env.NODE_ENV === 'production'
? (e) => { ? (e: any) => {
e.preventDefault(); e.preventDefault();
e.returnValue = '内容已修改,确认离开页面吗?'; e.returnValue = '内容已修改,确认离开页面吗?';
} }
: null; : () => {};
window.addEventListener('beforeunload', listen);
return () => { return () => {
window.onbeforeunload = null; window.removeEventListener('beforeunload', listen);
clearAppModules(); clearAppModules();
}; };
}, []); }, []);
......
...@@ -6,6 +6,7 @@ import { postFindPassword } from '@/api/user'; ...@@ -6,6 +6,7 @@ import { postFindPassword } from '@/api/user';
import { useSendCode } from '@/hooks/useSendCode'; import { useSendCode } from '@/hooks/useSendCode';
import type { ResLogin } from '@/api/response/user'; import type { ResLogin } from '@/api/response/user';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { feConfigs } from '@/store/static';
interface Props { interface Props {
setPageType: Dispatch<`${PageTypeEnum}`>; setPageType: Dispatch<`${PageTypeEnum}`>;
......
...@@ -9,6 +9,7 @@ import { useToast } from '@/hooks/useToast'; ...@@ -9,6 +9,7 @@ import { useToast } from '@/hooks/useToast';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { postCreateApp } from '@/api/app'; import { postCreateApp } from '@/api/app';
import { appTemplates } from '@/constants/flow/ModuleTemplate'; import { appTemplates } from '@/constants/flow/ModuleTemplate';
import { feConfigs } from '@/store/static';
interface Props { interface Props {
loginSuccess: (e: ResLogin) => void; loginSuccess: (e: ResLogin) => void;
......
...@@ -114,6 +114,9 @@ export const voiceBroadcast = ({ text }: { text: string }) => { ...@@ -114,6 +114,9 @@ export const voiceBroadcast = ({ text }: { text: string }) => {
cancel: () => window.speechSynthesis?.cancel() cancel: () => window.speechSynthesis?.cancel()
}; };
}; };
export const cancelBroadcast = () => {
window.speechSynthesis?.cancel();
};
export const getErrText = (err: any, def = '') => { export const getErrText = (err: any, def = '') => {
const msg: string = typeof err === 'string' ? err : err?.message || def || ''; const msg: string = typeof err === 'string' ? err : err?.message || def || '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment