@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.
Files changed (61) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -30
  3. package/lib/client/MobileClientProvider.d.ts +2 -0
  4. package/lib/client/MobileClientProvider.js +64 -0
  5. package/lib/client/core/schema/components/container/Container.js +15 -30
  6. package/lib/client/core/schema/components/header/Header.Designer.js +8 -8
  7. package/lib/client/core/schema/components/header/Header.js +1 -8
  8. package/lib/client/core/schema/components/menu/Menu.Item.js +1 -8
  9. package/lib/client/core/schema/components/menu/Menu.d.ts +1 -1
  10. package/lib/client/core/schema/components/menu/Menu.js +15 -22
  11. package/lib/client/core/schema/components/page/Page.js +7 -14
  12. package/lib/client/core/schema/components/settings/Settings.js +1 -8
  13. package/lib/client/core/schema/components/tab-bar/TabBar.Item.d.ts +1 -1
  14. package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +10 -17
  15. package/lib/client/core/schema/components/tab-bar/TabBar.d.ts +1 -1
  16. package/lib/client/core/schema/components/tab-bar/TabBar.js +25 -32
  17. package/lib/client/core/schema/hooks/useSchemaPatch.js +4 -5
  18. package/lib/client/core/schema/scopes/grid-card.js +4 -4
  19. package/lib/client/devices/iOS6.js +4 -4
  20. package/lib/client/devices/index.js +9 -9
  21. package/lib/client/index.d.ts +11 -2
  22. package/lib/client/index.js +62 -26
  23. package/lib/client/router/Application.js +6 -14
  24. package/lib/client/router/InterfaceRouter.d.ts +1 -5
  25. package/lib/client/router/InterfaceRouter.js +10 -38
  26. package/lib/client/router/index.d.ts +0 -1
  27. package/lib/client/router/index.js +0 -11
  28. package/lib/server/migrations/20230620203218-mobile-ui-schema-uid.js +1 -1
  29. package/package.json +26 -10
  30. package/server.d.ts +2 -3
  31. package/server.js +1 -30
  32. package/src/client/MobileClientProvider.tsx +41 -0
  33. package/src/client/core/schema/components/container/Container.tsx +13 -29
  34. package/src/client/core/schema/components/header/Header.Designer.tsx +3 -3
  35. package/src/client/core/schema/components/header/Header.tsx +1 -2
  36. package/src/client/core/schema/components/menu/Menu.Item.tsx +10 -2
  37. package/src/client/core/schema/components/menu/Menu.tsx +7 -6
  38. package/src/client/core/schema/components/page/Page.tsx +3 -4
  39. package/src/client/core/schema/components/settings/Settings.tsx +1 -2
  40. package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +4 -5
  41. package/src/client/core/schema/components/tab-bar/TabBar.tsx +8 -7
  42. package/src/client/core/schema/hooks/useSchemaPatch.ts +2 -2
  43. package/src/client/core/schema/scopes/grid-card.ts +1 -1
  44. package/src/client/devices/iOS6.tsx +1 -1
  45. package/src/client/devices/index.tsx +1 -1
  46. package/src/client/index.tsx +45 -30
  47. package/src/client/router/Application.tsx +3 -3
  48. package/src/client/router/InterfaceRouter.tsx +11 -43
  49. package/src/client/router/index.ts +0 -1
  50. package/docs/en-US/index.md +0 -7
  51. package/docs/en-US/installation.md +0 -13
  52. package/docs/en-US/tabs.json +0 -14
  53. package/docs/en-US/usage.md +0 -1
  54. package/docs/zh-CN/index.md +0 -7
  55. package/docs/zh-CN/installation.md +0 -13
  56. package/docs/zh-CN/tabs.json +0 -14
  57. package/docs/zh-CN/usage.md +0 -2
  58. package/lib/client/router/RouteSwitchProvider.d.ts +0 -2
  59. package/lib/client/router/RouteSwitchProvider.js +0 -59
  60. package/src/client/router/RouteSwitchProvider.tsx +0 -31
  61. 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 { RouteSwitch, SchemaComponent, SortableItem, useDesigner } from '@nocobase/client';
4
- import React, { useMemo } from 'react';
5
- import { Navigate, RouteProps, useLocation, useParams } from 'react-router-dom';
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
- const tabRoutes = useMemo<RouteProps[]>(() => {
44
- if (!redirectToUid) {
45
- return [];
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
- const locationPath = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname;
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: #f0f2f5;
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: tabRoutes.length ? '50px' : '0px',
72
+ paddingBottom: redirectToUid ? '50px' : '0px',
89
73
  }}
90
74
  className={cx('nb-mobile-container-content')}
91
75
  >
92
- {tabRoutes.length ? (
93
- <RouteSwitch routes={tabRoutes as any} />
76
+ {redirectToUid ? (
77
+ <TabContentComponent />
94
78
  ) : (
95
79
  <SchemaComponent
96
80
  filterProperties={(schema) => {
@@ -1,7 +1,7 @@
1
- import { Schema, useField, useFieldSchema } from '@formily/react';
2
- import { GeneralSchemaDesigner, SchemaSettings, useDesignable } from '@nocobase/client';
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 { GeneralSchemaDesigner, Icon, SchemaSettings, SortableItem, useCompile, useDesigner } from '@nocobase/client';
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 React from 'react';
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 #f0f2f5;
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: #f0f2f5;
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 '@emotion/css';
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 React, { useEffect, useMemo } from 'react';
2
- import { TabBar, TabBarItemProps } from 'antd-mobile';
3
- import { GeneralSchemaDesigner, SchemaSettings, SortableItem, useDesigner } from '@nocobase/client';
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 { useTranslation } from '../../../../locale';
15
- import { css, cx } from '@emotion/css';
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 { tabItemSchema } from './schema';
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 _ from 'lodash';
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
- _.set(fieldSchema, 'x-component-props', data);
12
+ lodash.set(fieldSchema, 'x-component-props', data);
13
13
  field.componentProps = { ...field.componentProps, ...data };
14
14
  dn.emit('patch', {
15
15
  schema: {
@@ -1,4 +1,4 @@
1
- import { css } from '@emotion/css';
1
+ import { css } from '@nocobase/client';
2
2
  import { useInterfaceContext } from '../../../router/InterfaceProvider';
3
3
  import { PaginationProps } from 'antd';
4
4
 
@@ -1,4 +1,4 @@
1
- import { css, cx } from '@emotion/css';
1
+ import { css, cx } from '@nocobase/client';
2
2
  import React from 'react';
3
3
 
4
4
  const iOS6: React.FC<{
@@ -1,6 +1,6 @@
1
+ import { css, cx } from '@nocobase/client';
1
2
  import React from 'react';
2
3
  import Device from './iOS6';
3
- import { css, cx } from '@emotion/css';
4
4
 
5
5
  export const MobileDevice: React.FC = (props) => {
6
6
  return (
@@ -1,33 +1,48 @@
1
- import { SettingsCenterProvider } from '@nocobase/client';
1
+ import { createRouterManager, Plugin, RouterManager, RouteSchemaComponent } from '@nocobase/client';
2
2
  import React from 'react';
3
- import { useTranslation } from './locale';
4
- import { AppConfiguration, InterfaceConfiguration } from './configuration';
5
- import { RouterSwitchProvider } from './router';
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 default React.memo((props) => {
9
- const { t } = useTranslation();
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
- return (
12
- <SettingsCenterProvider
13
- settings={{
14
- ['mobile-client']: {
15
- title: t('Mobile Client-side'),
16
- icon: 'MobileOutlined',
17
- tabs: {
18
- interface: {
19
- title: t('Interface Configuration'),
20
- component: InterfaceConfiguration,
21
- },
22
- app: {
23
- title: t('App Configuration'),
24
- component: AppConfiguration,
25
- },
26
- },
27
- },
28
- }}
29
- >
30
- <RouterSwitchProvider>{props.children}</RouterSwitchProvider>
31
- </SettingsCenterProvider>
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 { RouteSwitch, useRoutes } from '@nocobase/client';
2
- import React, { useMemo } from 'react';
3
- import { HashRouter, UNSAFE_LocationContext, UNSAFE_RouteContext } from 'react-router-dom';
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
- function RouteCleaner(props) {
7
- return (
8
- <UNSAFE_RouteContext.Provider
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
- <RouteCleaner>
41
- <HashRouter>
42
- <InterfaceProvider>
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';
@@ -1,2 +1 @@
1
1
  export * from './InterfaceRouter';
2
- export * from './RouteSwitchProvider';
@@ -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.
@@ -1,13 +0,0 @@
1
- # Mobile-client Installation
2
-
3
- ## Installation
4
-
5
- ```bash
6
- yarn add @nocobase/plugin-mobile-client
7
- ```
8
-
9
- ## Activate the plugin
10
-
11
- ```bash
12
- yarn pm enable mobile-client
13
- ```
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "title": "Introduction",
4
- "path": "index"
5
- },
6
- {
7
- "title": "Installation",
8
- "path": "installation"
9
- },
10
- {
11
- "title": "Usage",
12
- "path": "usage"
13
- }
14
- ]
@@ -1 +0,0 @@
1
- # Mobile-client Usage
@@ -1,7 +0,0 @@
1
- # 移动端
2
-
3
- 提供移动端应用,独立于桌面端。
4
-
5
- ## 如何访问?
6
-
7
- 当你的桌面端启动后,可以在浏览器中输入 `http://localhost:3000/mobile` 访问移动端。注意,`/mobile` 就是我们移动端的路由。
@@ -1,13 +0,0 @@
1
- # 移动端安装方法
2
-
3
- ## 安装
4
-
5
- ```bash
6
- yarn add @nocobase/plugin-mobile-client
7
- ```
8
-
9
- ## 激活插件
10
-
11
- ```bash
12
- yarn pm enable mobile-client
13
- ```
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "title": "介绍",
4
- "path": "index"
5
- },
6
- {
7
- "title": "安装",
8
- "path": "installation"
9
- },
10
- {
11
- "title": "用法",
12
- "path": "usage"
13
- }
14
- ]
@@ -1,2 +0,0 @@
1
- # 移动端用法
2
-
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const RouterSwitchProvider: (props: any) => React.JSX.Element;
@@ -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;