diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/__e2e__/redirect.test.ts b/packages/plugins/@nocobase/plugin-mobile/src/client/__e2e__/redirect.test.ts index 49a32e01aa..a0e6960b97 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/__e2e__/redirect.test.ts +++ b/packages/plugins/@nocobase/plugin-mobile/src/client/__e2e__/redirect.test.ts @@ -32,5 +32,9 @@ test.describe('redirect to other page from mobile', () => { await page.goto('/m/admin/settings/@nocobase/plugin-api-keys'); await page.waitForURL(`${baseURL}/admin/settings/@nocobase/plugin-api-keys`); expect(page.url()).toBe(`${baseURL}/admin/settings/@nocobase/plugin-api-keys`); + + // do not redirect to mobile page + await page.waitForTimeout(5000); + expect(page.url()).toBe(`${baseURL}/admin/settings/@nocobase/plugin-api-keys`); }); }); diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/index.tsx b/packages/plugins/@nocobase/plugin-mobile/src/client/index.tsx index 701faf0d6e..2e7c211a04 100644 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/index.tsx +++ b/packages/plugins/@nocobase/plugin-mobile/src/client/index.tsx @@ -48,14 +48,12 @@ import './js-bridge'; import { MobileSettings } from './mobile-blocks/settings-block/MobileSettings'; import { MobileSettingsBlockInitializer } from './mobile-blocks/settings-block/MobileSettingsBlockInitializer'; import { MobileSettingsBlockSchemaSettings } from './mobile-blocks/settings-block/schemaSettings'; -import { MobileCheckerProvider } from './providers'; export * from './desktop-mode'; export * from './mobile'; export * from './mobile-layout'; export * from './mobile-providers'; export * from './pages'; -export * from './providers'; export class PluginMobileClient extends Plugin { mobileRouter?: RouterManager; @@ -107,7 +105,6 @@ export class PluginMobileClient extends Plugin { this.addInitializers(); this.addSettings(); this.addScopes(); - this.app.addProvider(MobileCheckerProvider); this.app.pluginSettingsManager.add('mobile', { title: generatePluginTranslationTemplate('Mobile'), @@ -196,7 +193,7 @@ export class PluginMobileClient extends Plugin { this.mobileRouter.add('admin', { path: `/admin/*`, Component: () => { - if (window.location.pathname.startsWith(this.mobilePath + '/')) { + if (window.location.pathname.includes(`${this.mobilePath}/admin/`)) { window.location.replace(window.location.href.replace(this.mobilePath + '/', '/')); } return null; diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/MobileCheckerProvider.tsx b/packages/plugins/@nocobase/plugin-mobile/src/client/providers/MobileCheckerProvider.tsx deleted file mode 100644 index 670ad0f16e..0000000000 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/MobileCheckerProvider.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file is part of the NocoBase (R) project. - * Copyright (c) 2020-2024 NocoBase Co., Ltd. - * Authors: NocoBase Team. - * - * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. - * For more information, please refer to: https://www.nocobase.com/agreement. - */ - -import React, { useEffect } from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; -import { usePlugin } from '@nocobase/client'; -import { isDesktop } from 'react-device-detect'; - -import PluginMobileClient from '../index'; - -export const MobileCheckerProvider = React.memo((props) => { - const location = useLocation(); - const navigation = useNavigate(); - const mobilePlugin = usePlugin(PluginMobileClient); - - useEffect(() => { - if (!isDesktop && location.pathname.startsWith(mobilePlugin.router.get('admin').path)) { - navigation(mobilePlugin.mobileBasename, { replace: true }); - } - }, [location.pathname]); - - return <>{props.children}; -}); -MobileCheckerProvider.displayName = 'MobileCheckerProvider'; diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.md b/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.md deleted file mode 100644 index 31483458c4..0000000000 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# Providers - -主应用 Providers。 - - -## MobileCheckerProvider - -当为移动端时,访问 `/admin` 会自动跳转到 `/m`。 - -用于在移动端访问后台时,自动跳转到移动端后台。 - diff --git a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.ts b/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.ts deleted file mode 100644 index afe67bb560..0000000000 --- a/packages/plugins/@nocobase/plugin-mobile/src/client/providers/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file is part of the NocoBase (R) project. - * Copyright (c) 2020-2024 NocoBase Co., Ltd. - * Authors: NocoBase Team. - * - * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. - * For more information, please refer to: https://www.nocobase.com/agreement. - */ - -export * from './MobileCheckerProvider';