@nocobase/plugin-mobile-client 0.10.0-alpha.5 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/MobileClientProvider.d.ts +2 -0
- package/lib/client/MobileClientProvider.js +64 -0
- package/lib/client/core/schema/components/container/Container.js +15 -30
- package/lib/client/core/schema/components/header/Header.Designer.js +8 -8
- package/lib/client/core/schema/components/header/Header.js +1 -8
- package/lib/client/core/schema/components/menu/Menu.Item.js +1 -8
- package/lib/client/core/schema/components/menu/Menu.d.ts +1 -1
- package/lib/client/core/schema/components/menu/Menu.js +15 -22
- package/lib/client/core/schema/components/page/Page.js +7 -14
- package/lib/client/core/schema/components/settings/Settings.js +1 -8
- package/lib/client/core/schema/components/tab-bar/TabBar.Item.d.ts +1 -1
- package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +10 -17
- package/lib/client/core/schema/components/tab-bar/TabBar.d.ts +1 -1
- package/lib/client/core/schema/components/tab-bar/TabBar.js +25 -32
- package/lib/client/core/schema/hooks/useSchemaPatch.js +4 -5
- package/lib/client/core/schema/scopes/grid-card.js +4 -4
- package/lib/client/devices/iOS6.js +4 -4
- package/lib/client/devices/index.js +9 -9
- package/lib/client/index.d.ts +11 -2
- package/lib/client/index.js +62 -26
- package/lib/client/router/Application.js +6 -14
- package/lib/client/router/InterfaceRouter.d.ts +1 -5
- package/lib/client/router/InterfaceRouter.js +10 -38
- package/lib/client/router/index.d.ts +0 -1
- package/lib/client/router/index.js +0 -11
- package/lib/server/migrations/20230620203218-mobile-ui-schema-uid.js +1 -1
- package/package.json +26 -10
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/MobileClientProvider.tsx +41 -0
- package/src/client/core/schema/components/container/Container.tsx +13 -29
- package/src/client/core/schema/components/header/Header.Designer.tsx +3 -3
- package/src/client/core/schema/components/header/Header.tsx +1 -2
- package/src/client/core/schema/components/menu/Menu.Item.tsx +10 -2
- package/src/client/core/schema/components/menu/Menu.tsx +7 -6
- package/src/client/core/schema/components/page/Page.tsx +3 -4
- package/src/client/core/schema/components/settings/Settings.tsx +1 -2
- package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +4 -5
- package/src/client/core/schema/components/tab-bar/TabBar.tsx +8 -7
- package/src/client/core/schema/hooks/useSchemaPatch.ts +2 -2
- package/src/client/core/schema/scopes/grid-card.ts +1 -1
- package/src/client/devices/iOS6.tsx +1 -1
- package/src/client/devices/index.tsx +1 -1
- package/src/client/index.tsx +45 -30
- package/src/client/router/Application.tsx +3 -3
- package/src/client/router/InterfaceRouter.tsx +11 -43
- package/src/client/router/index.ts +0 -1
- package/docs/en-US/index.md +0 -7
- package/docs/en-US/installation.md +0 -13
- package/docs/en-US/tabs.json +0 -14
- package/docs/en-US/usage.md +0 -1
- package/docs/zh-CN/index.md +0 -7
- package/docs/zh-CN/installation.md +0 -13
- package/docs/zh-CN/tabs.json +0 -14
- package/docs/zh-CN/usage.md +0 -2
- package/lib/client/router/RouteSwitchProvider.d.ts +0 -2
- package/lib/client/router/RouteSwitchProvider.js +0 -59
- package/src/client/router/RouteSwitchProvider.tsx +0 -31
- package/types.d.ts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SettingsCenterProvider } from '@nocobase/client';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { AppConfiguration, InterfaceConfiguration } from './configuration';
|
|
5
|
+
import { isJSBridge } from './core/bridge';
|
|
6
|
+
import { useTranslation } from './locale';
|
|
7
|
+
|
|
8
|
+
export const MobileClientProvider = React.memo((props) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const location = useLocation();
|
|
11
|
+
const navigation = useNavigate();
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (isJSBridge() && location.pathname === '/admin') {
|
|
15
|
+
navigation('/mobile', { replace: true });
|
|
16
|
+
}
|
|
17
|
+
}, [location.pathname, navigation]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SettingsCenterProvider
|
|
21
|
+
settings={{
|
|
22
|
+
['mobile-client']: {
|
|
23
|
+
title: t('Mobile Client-side'),
|
|
24
|
+
icon: 'MobileOutlined',
|
|
25
|
+
tabs: {
|
|
26
|
+
interface: {
|
|
27
|
+
title: t('Interface Configuration'),
|
|
28
|
+
component: InterfaceConfiguration,
|
|
29
|
+
},
|
|
30
|
+
app: {
|
|
31
|
+
title: t('App Configuration'),
|
|
32
|
+
component: AppConfiguration,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{props.children}
|
|
39
|
+
</SettingsCenterProvider>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { css, cx } from '@emotion/css';
|
|
2
1
|
import { useFieldSchema } from '@formily/react';
|
|
3
|
-
import {
|
|
4
|
-
import React, {
|
|
5
|
-
import { Navigate,
|
|
2
|
+
import { css, cx, SchemaComponent, SortableItem, useDesigner } from '@nocobase/client';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { Navigate, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
6
5
|
import { ContainerDesigner } from './Container.Designer';
|
|
7
6
|
|
|
8
7
|
const findGrid = (schema, uid) => {
|
|
@@ -31,6 +30,7 @@ const TabContentComponent = () => {
|
|
|
31
30
|
const InternalContainer: React.FC = (props) => {
|
|
32
31
|
const Designer = useDesigner();
|
|
33
32
|
const fieldSchema = useFieldSchema();
|
|
33
|
+
const navigate = useNavigate();
|
|
34
34
|
const params = useParams<{ name: string }>();
|
|
35
35
|
const location = useLocation();
|
|
36
36
|
const tabBarSchema = fieldSchema?.properties?.['tabBar'];
|
|
@@ -39,28 +39,12 @@ const InternalContainer: React.FC = (props) => {
|
|
|
39
39
|
if (tabBarCurrentFirstKey) {
|
|
40
40
|
redirectToUid = tabBarSchema?.properties[tabBarCurrentFirstKey]?.['x-uid'];
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (redirectToUid && !params.name) {
|
|
44
|
+
const locationPath = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname;
|
|
45
|
+
navigate(`${locationPath}/tab_${redirectToUid}`, { replace: true });
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return [
|
|
50
|
-
!params.name
|
|
51
|
-
? {
|
|
52
|
-
type: 'redirect',
|
|
53
|
-
to: `${locationPath}/tab_${redirectToUid}`,
|
|
54
|
-
from: location.pathname,
|
|
55
|
-
}
|
|
56
|
-
: null,
|
|
57
|
-
{
|
|
58
|
-
type: 'route',
|
|
59
|
-
path: location.pathname,
|
|
60
|
-
component: TabContentComponent,
|
|
61
|
-
},
|
|
62
|
-
].filter(Boolean) as any[];
|
|
63
|
-
}, [redirectToUid, params.name, location.pathname]);
|
|
47
|
+
}, [location.pathname, navigate, params.name, redirectToUid]);
|
|
64
48
|
|
|
65
49
|
return (
|
|
66
50
|
<SortableItem
|
|
@@ -72,7 +56,7 @@ const InternalContainer: React.FC = (props) => {
|
|
|
72
56
|
right: unset;
|
|
73
57
|
left: 2px;
|
|
74
58
|
}
|
|
75
|
-
background:
|
|
59
|
+
background: var(--nb-box-bg);
|
|
76
60
|
display: flex;
|
|
77
61
|
flex-direction: column;
|
|
78
62
|
width: 100%;
|
|
@@ -85,12 +69,12 @@ const InternalContainer: React.FC = (props) => {
|
|
|
85
69
|
<Designer></Designer>
|
|
86
70
|
<div
|
|
87
71
|
style={{
|
|
88
|
-
paddingBottom:
|
|
72
|
+
paddingBottom: redirectToUid ? '50px' : '0px',
|
|
89
73
|
}}
|
|
90
74
|
className={cx('nb-mobile-container-content')}
|
|
91
75
|
>
|
|
92
|
-
{
|
|
93
|
-
<
|
|
76
|
+
{redirectToUid ? (
|
|
77
|
+
<TabContentComponent />
|
|
94
78
|
) : (
|
|
95
79
|
<SchemaComponent
|
|
96
80
|
filterProperties={(schema) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Switch } from '@formily/antd-v5';
|
|
2
|
+
import { useField } from '@formily/react';
|
|
3
|
+
import { GeneralSchemaDesigner, SchemaSettings } from '@nocobase/client';
|
|
3
4
|
import React from 'react';
|
|
4
|
-
import { Switch } from '@formily/antd';
|
|
5
5
|
import { useTranslation } from '../../../../locale';
|
|
6
6
|
import { useSchemaPatch } from '../../hooks';
|
|
7
7
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { css, cx } from '@emotion/css';
|
|
2
1
|
import { useField } from '@formily/react';
|
|
3
|
-
import { SortableItem, useCompile, useDesigner, useDocumentTitle } from '@nocobase/client';
|
|
2
|
+
import { css, cx, SortableItem, useCompile, useDesigner, useDocumentTitle } from '@nocobase/client';
|
|
4
3
|
import { NavBar, NavBarProps } from 'antd-mobile';
|
|
5
4
|
import React, { useEffect } from 'react';
|
|
6
5
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { css, cx } from '@emotion/css';
|
|
2
1
|
import { useField, useFieldSchema } from '@formily/react';
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
css,
|
|
4
|
+
cx,
|
|
5
|
+
GeneralSchemaDesigner,
|
|
6
|
+
Icon,
|
|
7
|
+
SchemaSettings,
|
|
8
|
+
SortableItem,
|
|
9
|
+
useCompile,
|
|
10
|
+
useDesigner,
|
|
11
|
+
} from '@nocobase/client';
|
|
4
12
|
import { List, ListItemProps } from 'antd-mobile';
|
|
5
13
|
import React from 'react';
|
|
6
14
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MenuItem } from './Menu.Item';
|
|
1
|
+
import { useFieldSchema } from '@formily/react';
|
|
3
2
|
import {
|
|
3
|
+
css,
|
|
4
|
+
cx,
|
|
4
5
|
DndContext,
|
|
5
6
|
SchemaComponent,
|
|
6
7
|
SchemaInitializer,
|
|
@@ -8,13 +9,13 @@ import {
|
|
|
8
9
|
useDesignable,
|
|
9
10
|
useDesigner,
|
|
10
11
|
} from '@nocobase/client';
|
|
11
|
-
import { css, cx } from '@emotion/css';
|
|
12
|
-
import { MenuDesigner } from './Menu.Designer';
|
|
13
|
-
import { useFieldSchema } from '@formily/react';
|
|
14
12
|
import { List } from 'antd-mobile';
|
|
13
|
+
import React from 'react';
|
|
15
14
|
import { useTranslation } from '../../../../locale';
|
|
16
|
-
import { menuItemSchema } from './schema';
|
|
17
15
|
import { PageSchema } from '../../common';
|
|
16
|
+
import { MenuDesigner } from './Menu.Designer';
|
|
17
|
+
import { MenuItem } from './Menu.Item';
|
|
18
|
+
import { menuItemSchema } from './schema';
|
|
18
19
|
|
|
19
20
|
const InternalMenu: React.FC = (props) => {
|
|
20
21
|
const Designer = useDesigner();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { css, cx } from '@emotion/css';
|
|
2
1
|
import { RecursionField, useFieldSchema } from '@formily/react';
|
|
3
|
-
import { ActionBarProvider, SortableItem, TabsContextProvider, useDesigner } from '@nocobase/client';
|
|
2
|
+
import { ActionBarProvider, css, cx, SortableItem, TabsContextProvider, useDesigner } from '@nocobase/client';
|
|
4
3
|
import { TabsProps } from 'antd';
|
|
5
4
|
import React, { useCallback } from 'react';
|
|
6
5
|
import { useSearchParams } from 'react-router-dom';
|
|
@@ -10,7 +9,7 @@ import { PageDesigner } from './Page.Designer';
|
|
|
10
9
|
const globalActionCSS = css`
|
|
11
10
|
#nb-position-container > & {
|
|
12
11
|
height: 49px;
|
|
13
|
-
border-top: 1px solid
|
|
12
|
+
border-top: 1px solid var(--nb-box-bg);
|
|
14
13
|
margin-bottom: 0px !important;
|
|
15
14
|
padding: 0 var(--nb-spacing);
|
|
16
15
|
align-items: center;
|
|
@@ -84,7 +83,7 @@ const InternalPage: React.FC = (props) => {
|
|
|
84
83
|
className={cx(
|
|
85
84
|
'nb-mobile-page',
|
|
86
85
|
css`
|
|
87
|
-
background:
|
|
86
|
+
background: var(--nb-box-bg);
|
|
88
87
|
display: flex;
|
|
89
88
|
flex-direction: column;
|
|
90
89
|
width: 100%;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { css, cx } from '@
|
|
2
|
-
import { SettingsMenu, SortableItem, useDesigner } from '@nocobase/client';
|
|
1
|
+
import { css, cx, SettingsMenu, SortableItem, useDesigner } from '@nocobase/client';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { SettingsDesigner } from './Settings.Designer';
|
|
5
4
|
export const InternalSettings = () => {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useField, useFieldSchema } from '@formily/react';
|
|
2
|
+
import { css, cx, GeneralSchemaDesigner, SchemaSettings, SortableItem, useDesigner } from '@nocobase/client';
|
|
3
|
+
import { TabBarItemProps } from 'antd-mobile';
|
|
4
|
+
import React from 'react';
|
|
4
5
|
import { useTranslation } from '../../../../locale';
|
|
5
|
-
import { Schema, useField, useFieldSchema } from '@formily/react';
|
|
6
6
|
import { useSchemaPatch } from '../../hooks';
|
|
7
|
-
import { css, cx } from '@emotion/css';
|
|
8
7
|
import { tabItemSchema } from './schema';
|
|
9
8
|
|
|
10
9
|
const InternalItem: React.FC<TabBarItemProps> = () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TabBar } from 'antd-mobile';
|
|
2
|
-
import { TabBarItem } from './TabBar.Item';
|
|
3
|
-
import React, { useCallback } from 'react';
|
|
4
1
|
import { useFieldSchema } from '@formily/react';
|
|
2
|
+
import { uid } from '@formily/shared';
|
|
5
3
|
import {
|
|
4
|
+
css,
|
|
5
|
+
cx,
|
|
6
6
|
DndContext,
|
|
7
7
|
Icon,
|
|
8
8
|
SchemaComponent,
|
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
useCompile,
|
|
12
12
|
useDesignable,
|
|
13
13
|
} from '@nocobase/client';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { uid } from '@formily/shared';
|
|
14
|
+
import { TabBar } from 'antd-mobile';
|
|
15
|
+
import React, { useCallback } from 'react';
|
|
17
16
|
import { useNavigate, useParams } from 'react-router-dom';
|
|
18
|
-
import {
|
|
17
|
+
import { useTranslation } from '../../../../locale';
|
|
19
18
|
import { PageSchema } from '../../common';
|
|
19
|
+
import { tabItemSchema } from './schema';
|
|
20
|
+
import { TabBarItem } from './TabBar.Item';
|
|
20
21
|
|
|
21
22
|
export const InternalTabBar: React.FC = (props) => {
|
|
22
23
|
const fieldSchema = useFieldSchema();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useField, useFieldSchema } from '@formily/react';
|
|
2
2
|
import { useDesignable } from '@nocobase/client';
|
|
3
|
-
import
|
|
3
|
+
import { lodash } from '@nocobase/utils/client';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
|
|
6
6
|
export const useSchemaPatch = () => {
|
|
@@ -9,7 +9,7 @@ export const useSchemaPatch = () => {
|
|
|
9
9
|
const field = useField();
|
|
10
10
|
|
|
11
11
|
const onUpdateComponentProps = useCallback((data) => {
|
|
12
|
-
|
|
12
|
+
lodash.set(fieldSchema, 'x-component-props', data);
|
|
13
13
|
field.componentProps = { ...field.componentProps, ...data };
|
|
14
14
|
dn.emit('patch', {
|
|
15
15
|
schema: {
|
package/src/client/index.tsx
CHANGED
|
@@ -1,33 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRouterManager, Plugin, RouterManager, RouteSchemaComponent } from '@nocobase/client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { MobileCore } from './core';
|
|
3
|
+
import { Navigate } from 'react-router-dom';
|
|
4
|
+
import { MobileClientProvider } from './MobileClientProvider';
|
|
5
|
+
import MApplication from './router/Application';
|
|
7
6
|
|
|
8
|
-
export
|
|
9
|
-
|
|
7
|
+
export class MobileClientPlugin extends Plugin {
|
|
8
|
+
public mobileRouter: RouterManager;
|
|
9
|
+
async load() {
|
|
10
|
+
this.setMobileRouter();
|
|
11
|
+
this.addRoutes();
|
|
12
|
+
this.app.use(MobileClientProvider);
|
|
13
|
+
}
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
33
|
-
|
|
15
|
+
setMobileRouter() {
|
|
16
|
+
const router = createRouterManager({ type: 'hash' });
|
|
17
|
+
router.add('root', {
|
|
18
|
+
path: '/',
|
|
19
|
+
element: <Navigate replace to="/mobile" />,
|
|
20
|
+
});
|
|
21
|
+
router.add('mobile', {
|
|
22
|
+
path: '/mobile',
|
|
23
|
+
element: <MApplication />,
|
|
24
|
+
});
|
|
25
|
+
router.add('mobile.page', {
|
|
26
|
+
path: '/mobile/:name',
|
|
27
|
+
element: <RouteSchemaComponent />,
|
|
28
|
+
});
|
|
29
|
+
this.mobileRouter = router;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getMobileRouterComponent() {
|
|
33
|
+
return this.mobileRouter.getRouterComponent();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
addRoutes() {
|
|
37
|
+
this.app.router.add('mobile', {
|
|
38
|
+
path: '/mobile',
|
|
39
|
+
element: <MApplication />,
|
|
40
|
+
});
|
|
41
|
+
this.app.router.add('mobile.page', {
|
|
42
|
+
path: '/mobile/:name',
|
|
43
|
+
Component: 'RouteSchemaComponent',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default MobileClientPlugin;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { css, cx } from '@emotion/css';
|
|
2
1
|
import {
|
|
3
2
|
ActionContextProvider,
|
|
4
3
|
AdminProvider,
|
|
4
|
+
css,
|
|
5
|
+
cx,
|
|
5
6
|
RemoteSchemaComponent,
|
|
6
7
|
useSystemSettings,
|
|
7
8
|
useViewport,
|
|
@@ -68,7 +69,7 @@ const modalProps = {
|
|
|
68
69
|
position: 'absolute',
|
|
69
70
|
},
|
|
70
71
|
wrapClassName: css`
|
|
71
|
-
position: absolute;
|
|
72
|
+
position: absolute !important;
|
|
72
73
|
`,
|
|
73
74
|
};
|
|
74
75
|
|
|
@@ -79,7 +80,6 @@ const useMobileSchemaUid = () => {
|
|
|
79
80
|
|
|
80
81
|
const MApplication: React.FC = (props) => {
|
|
81
82
|
const mobileSchemaUid = useMobileSchemaUid();
|
|
82
|
-
console.log('mobileSchemaUid', mobileSchemaUid);
|
|
83
83
|
const params = useParams<{ name: string }>();
|
|
84
84
|
const interfaceContext = useInterfaceContext();
|
|
85
85
|
const Provider = useMemo(() => {
|
|
@@ -1,48 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React
|
|
3
|
-
import {
|
|
1
|
+
import { usePlugin } from '@nocobase/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { MobileClientPlugin } from '../index';
|
|
4
4
|
import { InterfaceProvider } from './InterfaceProvider';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
value={{
|
|
10
|
-
outlet: null,
|
|
11
|
-
matches: [],
|
|
12
|
-
isDataRoute: false,
|
|
13
|
-
}}
|
|
14
|
-
>
|
|
15
|
-
<UNSAFE_LocationContext.Provider value={null as any}>{props.children}</UNSAFE_LocationContext.Provider>
|
|
16
|
-
</UNSAFE_RouteContext.Provider>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
6
|
+
export const InterfaceRouter: React.FC = React.memo(() => {
|
|
7
|
+
const plugin = usePlugin(MobileClientPlugin);
|
|
8
|
+
const MobileRouter = plugin.getMobileRouterComponent();
|
|
19
9
|
|
|
20
|
-
interface InterfaceRouterProps {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}
|
|
23
|
-
export const InterfaceRouter: React.FC<InterfaceRouterProps> = (props) => {
|
|
24
|
-
const allRoutes = useRoutes();
|
|
25
|
-
const routes = useMemo(
|
|
26
|
-
() =>
|
|
27
|
-
allRoutes.reduce((nextRoutes, item) => {
|
|
28
|
-
if (item['component'] === 'MApplication') {
|
|
29
|
-
nextRoutes.push(item, {
|
|
30
|
-
type: 'redirect',
|
|
31
|
-
to: '/mobile',
|
|
32
|
-
from: '/',
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return nextRoutes;
|
|
36
|
-
}, []),
|
|
37
|
-
[allRoutes],
|
|
38
|
-
);
|
|
39
10
|
return (
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
<RouteSwitch routes={routes}></RouteSwitch>
|
|
44
|
-
</InterfaceProvider>
|
|
45
|
-
</HashRouter>
|
|
46
|
-
</RouteCleaner>
|
|
11
|
+
<InterfaceProvider>
|
|
12
|
+
<MobileRouter />
|
|
13
|
+
</InterfaceProvider>
|
|
47
14
|
);
|
|
48
|
-
};
|
|
15
|
+
});
|
|
16
|
+
InterfaceRouter.displayName = 'InterfaceRouter';
|
package/docs/en-US/index.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Mobile-client overview
|
|
2
|
-
|
|
3
|
-
Provides a mobile client for the desktop client.
|
|
4
|
-
|
|
5
|
-
## How to visit mobile client?
|
|
6
|
-
|
|
7
|
-
When your desktop client is started, you can visit the mobile client in the browser by entering `http://localhost:3000/mobile`. Note that `/mobile` is the route of our mobile client.
|
package/docs/en-US/tabs.json
DELETED
package/docs/en-US/usage.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Mobile-client Usage
|
package/docs/zh-CN/index.md
DELETED
package/docs/zh-CN/tabs.json
DELETED
package/docs/zh-CN/usage.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RouterSwitchProvider = void 0;
|
|
7
|
-
function _client() {
|
|
8
|
-
const data = require("@nocobase/client");
|
|
9
|
-
_client = function _client() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
function _react() {
|
|
15
|
-
const data = _interopRequireWildcard(require("react"));
|
|
16
|
-
_react = function _react() {
|
|
17
|
-
return data;
|
|
18
|
-
};
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
function _reactRouterDom() {
|
|
22
|
-
const data = require("react-router-dom");
|
|
23
|
-
_reactRouterDom = function _reactRouterDom() {
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
return data;
|
|
27
|
-
}
|
|
28
|
-
var _bridge = require("../core/bridge");
|
|
29
|
-
var _Application = _interopRequireDefault(require("./Application"));
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
37
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
38
|
-
const RouterSwitchProvider = props => {
|
|
39
|
-
const _useRouteSwitchContex = (0, _client().useRouteSwitchContext)(),
|
|
40
|
-
routes = _useRouteSwitchContex.routes,
|
|
41
|
-
components = _useRouteSwitchContex.components;
|
|
42
|
-
// redirect to mobile
|
|
43
|
-
const location = (0, _reactRouterDom().useLocation)();
|
|
44
|
-
const navigate = (0, _reactRouterDom().useNavigate)();
|
|
45
|
-
(0, _react().useEffect)(() => {
|
|
46
|
-
if ((0, _bridge.isJSBridge)()) {
|
|
47
|
-
if (location.pathname.includes('/admin')) {
|
|
48
|
-
navigate('/mobile');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, [location.pathname, navigate]);
|
|
52
|
-
return _react().default.createElement(_client().RouteSwitchProvider, {
|
|
53
|
-
routes: routes,
|
|
54
|
-
components: _objectSpread(_objectSpread({}, components), {}, {
|
|
55
|
-
MApplication: _Application.default
|
|
56
|
-
})
|
|
57
|
-
}, props.children);
|
|
58
|
-
};
|
|
59
|
-
exports.RouterSwitchProvider = RouterSwitchProvider;
|