fix: conditional Back key interception on Android (#1942)

This commit is contained in:
Huang Xin
2025-09-01 12:16:31 +08:00
committed by GitHub
parent 7f4c157a90
commit f69422a61c
@@ -51,12 +51,6 @@ const Reader: React.FC<{ ids?: string }> = ({ ids }) => {
setTimeout(getSysFontsList, 3000);
}
initDayjs(getLocale());
acquireBackKeyInterception();
return () => {
releaseBackKeyInterception();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleKeyDown = (event: CustomEvent) => {
@@ -74,6 +68,15 @@ const Reader: React.FC<{ ids?: string }> = ({ ids }) => {
return false;
};
useEffect(() => {
if (!appService?.isAndroidApp) return;
acquireBackKeyInterception();
return () => {
releaseBackKeyInterception();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [appService?.isAndroidApp]);
useEffect(() => {
if (!appService?.isAndroidApp) return;
eventDispatcher.onSync('native-key-down', handleKeyDown);