mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:37:37 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
4dcbf01a89
@ -32,5 +32,9 @@ test.describe('redirect to other page from mobile', () => {
|
|||||||
await page.goto('/m/admin/settings/@nocobase/plugin-api-keys');
|
await page.goto('/m/admin/settings/@nocobase/plugin-api-keys');
|
||||||
await page.waitForURL(`${baseURL}/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`);
|
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`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -48,14 +48,12 @@ import './js-bridge';
|
|||||||
import { MobileSettings } from './mobile-blocks/settings-block/MobileSettings';
|
import { MobileSettings } from './mobile-blocks/settings-block/MobileSettings';
|
||||||
import { MobileSettingsBlockInitializer } from './mobile-blocks/settings-block/MobileSettingsBlockInitializer';
|
import { MobileSettingsBlockInitializer } from './mobile-blocks/settings-block/MobileSettingsBlockInitializer';
|
||||||
import { MobileSettingsBlockSchemaSettings } from './mobile-blocks/settings-block/schemaSettings';
|
import { MobileSettingsBlockSchemaSettings } from './mobile-blocks/settings-block/schemaSettings';
|
||||||
import { MobileCheckerProvider } from './providers';
|
|
||||||
|
|
||||||
export * from './desktop-mode';
|
export * from './desktop-mode';
|
||||||
export * from './mobile';
|
export * from './mobile';
|
||||||
export * from './mobile-layout';
|
export * from './mobile-layout';
|
||||||
export * from './mobile-providers';
|
export * from './mobile-providers';
|
||||||
export * from './pages';
|
export * from './pages';
|
||||||
export * from './providers';
|
|
||||||
|
|
||||||
export class PluginMobileClient extends Plugin {
|
export class PluginMobileClient extends Plugin {
|
||||||
mobileRouter?: RouterManager;
|
mobileRouter?: RouterManager;
|
||||||
@ -107,7 +105,6 @@ export class PluginMobileClient extends Plugin {
|
|||||||
this.addInitializers();
|
this.addInitializers();
|
||||||
this.addSettings();
|
this.addSettings();
|
||||||
this.addScopes();
|
this.addScopes();
|
||||||
this.app.addProvider(MobileCheckerProvider);
|
|
||||||
|
|
||||||
this.app.pluginSettingsManager.add('mobile', {
|
this.app.pluginSettingsManager.add('mobile', {
|
||||||
title: generatePluginTranslationTemplate('Mobile'),
|
title: generatePluginTranslationTemplate('Mobile'),
|
||||||
@ -196,7 +193,7 @@ export class PluginMobileClient extends Plugin {
|
|||||||
this.mobileRouter.add('admin', {
|
this.mobileRouter.add('admin', {
|
||||||
path: `/admin/*`,
|
path: `/admin/*`,
|
||||||
Component: () => {
|
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 + '/', '/'));
|
window.location.replace(window.location.href.replace(this.mobilePath + '/', '/'));
|
||||||
}
|
}
|
||||||
return null;
|
return 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';
|
|
@ -1,11 +0,0 @@
|
|||||||
# Providers
|
|
||||||
|
|
||||||
主应用 Providers。
|
|
||||||
|
|
||||||
|
|
||||||
## MobileCheckerProvider
|
|
||||||
|
|
||||||
当为移动端时,访问 `/admin` 会自动跳转到 `/m`。
|
|
||||||
|
|
||||||
用于在移动端访问后台时,自动跳转到移动端后台。
|
|
||||||
|
|
@ -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';
|
|
Loading…
Reference in New Issue
Block a user