From edf2e8b6bf73ff612b9ce9c6580401267c14d528 Mon Sep 17 00:00:00 2001 From: linleiqin <278438611@qq.com> Date: Tue, 15 Aug 2023 09:55:43 +0800 Subject: [PATCH] OK-22356 fix:exit App. (#3403) --- packages/kit-bg/src/services/ServiceApp.ts | 5 ++--- packages/shared/src/exitApp/index.native.ts | 5 +++++ packages/shared/src/exitApp/index.ts | 1 + .../modules3rdParty/react-native-exit-app/index.native.ts | 3 --- .../src/modules3rdParty/react-native-exit-app/index.ts | 4 ---- 5 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 packages/shared/src/exitApp/index.native.ts create mode 100644 packages/shared/src/exitApp/index.ts delete mode 100644 packages/shared/src/modules3rdParty/react-native-exit-app/index.native.ts delete mode 100644 packages/shared/src/modules3rdParty/react-native-exit-app/index.ts diff --git a/packages/kit-bg/src/services/ServiceApp.ts b/packages/kit-bg/src/services/ServiceApp.ts index 769b610b27b..7ca5e7eeaba 100644 --- a/packages/kit-bg/src/services/ServiceApp.ts +++ b/packages/kit-bg/src/services/ServiceApp.ts @@ -49,8 +49,8 @@ import { AppEventBusNames, appEventBus, } from '@onekeyhq/shared/src/eventBus/appEventBus'; +import { exitApp } from '@onekeyhq/shared/src/exitApp'; import debugLogger from '@onekeyhq/shared/src/logger/debugLogger'; -import RNExitApp from '@onekeyhq/shared/src/modules3rdParty/react-native-exit-app'; import platformEnv from '@onekeyhq/shared/src/platformEnv'; import appStorage from '@onekeyhq/shared/src/storage/appStorage'; import timerUtils from '@onekeyhq/shared/src/utils/timerUtils'; @@ -167,8 +167,7 @@ class ServiceApp extends ServiceBase { @backgroundMethod() exitApp() { if (platformEnv.isNative) { - if (!RNExitApp) return; - return RNExitApp.exitApp(); + exitApp(); } } diff --git a/packages/shared/src/exitApp/index.native.ts b/packages/shared/src/exitApp/index.native.ts new file mode 100644 index 00000000000..03a11eba1a4 --- /dev/null +++ b/packages/shared/src/exitApp/index.native.ts @@ -0,0 +1,5 @@ +import RNExitApp from 'react-native-exit-app'; + +export function exitApp() { + return RNExitApp.exitApp(); +} diff --git a/packages/shared/src/exitApp/index.ts b/packages/shared/src/exitApp/index.ts new file mode 100644 index 00000000000..0dbb32ca4e7 --- /dev/null +++ b/packages/shared/src/exitApp/index.ts @@ -0,0 +1 @@ +export function exitApp() {} diff --git a/packages/shared/src/modules3rdParty/react-native-exit-app/index.native.ts b/packages/shared/src/modules3rdParty/react-native-exit-app/index.native.ts deleted file mode 100644 index 2cdf3854317..00000000000 --- a/packages/shared/src/modules3rdParty/react-native-exit-app/index.native.ts +++ /dev/null @@ -1,3 +0,0 @@ -const RNExitApp: typeof import('react-native-exit-app') = require('react-native-exit-app'); - -export default RNExitApp; diff --git a/packages/shared/src/modules3rdParty/react-native-exit-app/index.ts b/packages/shared/src/modules3rdParty/react-native-exit-app/index.ts deleted file mode 100644 index 081c43e17db..00000000000 --- a/packages/shared/src/modules3rdParty/react-native-exit-app/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type RNExitApp from 'react-native-exit-app'; - -const module: typeof RNExitApp | undefined = {} as any; -export default module;