@nocobase/plugin-mobile-client 0.10.1-alpha.1 → 0.11.1-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 (78) 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.Designer.js +2 -2
  6. package/lib/client/core/schema/components/container/Container.js +20 -51
  7. package/lib/client/core/schema/components/container/style.d.ts +5 -0
  8. package/lib/client/core/schema/components/container/style.js +48 -0
  9. package/lib/client/core/schema/components/header/Header.Designer.js +8 -8
  10. package/lib/client/core/schema/components/header/Header.js +10 -11
  11. package/lib/client/core/schema/components/menu/Menu.Designer.js +18 -18
  12. package/lib/client/core/schema/components/menu/Menu.Item.js +1 -8
  13. package/lib/client/core/schema/components/menu/Menu.d.ts +1 -1
  14. package/lib/client/core/schema/components/menu/Menu.js +18 -26
  15. package/lib/client/core/schema/components/menu/style.d.ts +4 -0
  16. package/lib/client/core/schema/components/menu/style.js +34 -0
  17. package/lib/client/core/schema/components/page/Page.Designer.js +2 -2
  18. package/lib/client/core/schema/components/page/Page.js +9 -43
  19. package/lib/client/core/schema/components/page/style.d.ts +6 -0
  20. package/lib/client/core/schema/components/page/style.js +55 -0
  21. package/lib/client/core/schema/components/settings/Settings.js +1 -8
  22. package/lib/client/core/schema/components/tab-bar/TabBar.Item.d.ts +1 -1
  23. package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +10 -17
  24. package/lib/client/core/schema/components/tab-bar/TabBar.d.ts +1 -1
  25. package/lib/client/core/schema/components/tab-bar/TabBar.js +30 -33
  26. package/lib/client/core/schema/hooks/useSchemaPatch.js +9 -6
  27. package/lib/client/core/schema/scopes/grid-card.js +4 -4
  28. package/lib/client/devices/iOS6.js +4 -4
  29. package/lib/client/devices/index.js +9 -9
  30. package/lib/client/index.d.ts +11 -2
  31. package/lib/client/index.js +62 -26
  32. package/lib/client/locale/index.js +2 -5
  33. package/lib/client/router/Application.js +8 -15
  34. package/lib/client/router/InterfaceRouter.d.ts +1 -5
  35. package/lib/client/router/InterfaceRouter.js +10 -38
  36. package/lib/client/router/index.d.ts +0 -1
  37. package/lib/client/router/index.js +0 -11
  38. package/lib/server/migrations/20230620203218-mobile-ui-schema-uid.js +1 -1
  39. package/package.json +26 -10
  40. package/server.d.ts +2 -3
  41. package/server.js +1 -30
  42. package/src/client/MobileClientProvider.tsx +41 -0
  43. package/src/client/core/schema/components/container/Container.Designer.tsx +2 -2
  44. package/src/client/core/schema/components/container/Container.tsx +18 -64
  45. package/src/client/core/schema/components/container/style.ts +35 -0
  46. package/src/client/core/schema/components/header/Header.Designer.tsx +3 -3
  47. package/src/client/core/schema/components/header/Header.tsx +11 -12
  48. package/src/client/core/schema/components/menu/Menu.Designer.tsx +5 -5
  49. package/src/client/core/schema/components/menu/Menu.Item.tsx +10 -2
  50. package/src/client/core/schema/components/menu/Menu.tsx +9 -16
  51. package/src/client/core/schema/components/menu/style.ts +20 -0
  52. package/src/client/core/schema/components/page/Page.Designer.tsx +2 -2
  53. package/src/client/core/schema/components/page/Page.tsx +6 -46
  54. package/src/client/core/schema/components/page/style.ts +43 -0
  55. package/src/client/core/schema/components/settings/Settings.tsx +1 -2
  56. package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +4 -5
  57. package/src/client/core/schema/components/tab-bar/TabBar.tsx +15 -8
  58. package/src/client/core/schema/hooks/useSchemaPatch.ts +8 -2
  59. package/src/client/core/schema/scopes/grid-card.ts +1 -1
  60. package/src/client/devices/iOS6.tsx +1 -1
  61. package/src/client/devices/index.tsx +1 -1
  62. package/src/client/index.tsx +45 -30
  63. package/src/client/locale/index.ts +2 -4
  64. package/src/client/router/Application.tsx +5 -4
  65. package/src/client/router/InterfaceRouter.tsx +11 -43
  66. package/src/client/router/index.ts +0 -1
  67. package/docs/en-US/index.md +0 -7
  68. package/docs/en-US/installation.md +0 -13
  69. package/docs/en-US/tabs.json +0 -14
  70. package/docs/en-US/usage.md +0 -1
  71. package/docs/zh-CN/index.md +0 -7
  72. package/docs/zh-CN/installation.md +0 -13
  73. package/docs/zh-CN/tabs.json +0 -14
  74. package/docs/zh-CN/usage.md +0 -2
  75. package/lib/client/router/RouteSwitchProvider.d.ts +0 -2
  76. package/lib/client/router/RouteSwitchProvider.js +0 -59
  77. package/src/client/router/RouteSwitchProvider.tsx +0 -31
  78. package/types.d.ts +0 -0
@@ -1,9 +1,9 @@
1
- import { GeneralSchemaDesigner, SchemaSettings, useDesignable } from '@nocobase/client';
2
1
  import { MenuOutlined } from '@ant-design/icons';
2
+ import { useField, useFieldSchema } from '@formily/react';
3
+ import { SchemaSettings, useDesignable } from '@nocobase/client';
4
+ import { Button } from 'antd';
3
5
  import React from 'react';
4
6
  import { useTranslation } from '../../../../locale';
5
- import { Button } from 'antd';
6
- import { useFieldSchema, useField } from '@formily/react';
7
7
 
8
8
  export const MenuDesigner: React.FC = (props) => {
9
9
  const { t } = useTranslation();
@@ -20,8 +20,8 @@ export const MenuDesigner: React.FC = (props) => {
20
20
  title={
21
21
  <Button
22
22
  style={{
23
- borderColor: 'rgb(241, 139, 98)',
24
- color: 'rgb(241, 139, 98)',
23
+ borderColor: 'var(--colorSettings)',
24
+ color: 'var(--colorSettings)',
25
25
  }}
26
26
  icon={<MenuOutlined />}
27
27
  type="dashed"
@@ -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
+ GeneralSchemaDesigner,
4
+ Icon,
5
+ SchemaSettings,
6
+ SortableItem,
7
+ css,
8
+ cx,
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,6 @@
1
- import React from 'react';
2
- import { MenuItem } from './Menu.Item';
1
+ import { useFieldSchema } from '@formily/react';
3
2
  import {
3
+ cx,
4
4
  DndContext,
5
5
  SchemaComponent,
6
6
  SchemaInitializer,
@@ -8,15 +8,17 @@ import {
8
8
  useDesignable,
9
9
  useDesigner,
10
10
  } from '@nocobase/client';
11
- import { css, cx } from '@emotion/css';
12
- import { MenuDesigner } from './Menu.Designer';
13
- import { useFieldSchema } from '@formily/react';
14
11
  import { List } from 'antd-mobile';
12
+ import React from 'react';
15
13
  import { useTranslation } from '../../../../locale';
16
- import { menuItemSchema } from './schema';
17
14
  import { PageSchema } from '../../common';
15
+ import { MenuDesigner } from './Menu.Designer';
16
+ import { MenuItem } from './Menu.Item';
17
+ import { menuItemSchema } from './schema';
18
+ import useStyles from './style';
18
19
 
19
20
  const InternalMenu: React.FC = (props) => {
21
+ const { styles } = useStyles();
20
22
  const Designer = useDesigner();
21
23
  const fieldSchema = useFieldSchema();
22
24
  const { insertBeforeEnd, designable } = useDesignable();
@@ -39,16 +41,7 @@ const InternalMenu: React.FC = (props) => {
39
41
  };
40
42
 
41
43
  return (
42
- <SortableItem
43
- className={cx(
44
- 'nb-mobile-menu',
45
- css`
46
- background: #ffffff;
47
- width: 100%;
48
- margin-bottom: var(--nb-spacing);
49
- `,
50
- )}
51
- >
44
+ <SortableItem className={cx('nb-mobile-menu', styles.mobileMenu)}>
52
45
  <List>
53
46
  {designable && (
54
47
  <List.Item>
@@ -0,0 +1,20 @@
1
+ import { createStyles } from '@nocobase/client';
2
+
3
+ const useStyles = createStyles(({ token, css }) => {
4
+ return {
5
+ mobileMenu: css`
6
+ --adm-color-primary: ${token.colorPrimary};
7
+ --adm-color-primary-hover: ${token.colorPrimaryHover};
8
+ --adm-color-primary-active: ${token.colorPrimaryActive};
9
+ --padding-left: ${token.paddingSM}px;
10
+ --adm-color-background: ${token.colorBgContainer};
11
+ --adm-color-border: ${token.colorBorder};
12
+
13
+ background: ${token.colorBgContainer};
14
+ width: 100%;
15
+ margin-bottom: var(--nb-spacing);
16
+ `,
17
+ };
18
+ });
19
+
20
+ export default useStyles;
@@ -26,8 +26,8 @@ export const PageDesigner = (props) => {
26
26
  title={
27
27
  <Button
28
28
  style={{
29
- borderColor: 'rgb(241, 139, 98)',
30
- color: 'rgb(241, 139, 98)',
29
+ borderColor: 'var(--colorSettings)',
30
+ color: 'var(--colorSettings)',
31
31
  width: '100%',
32
32
  }}
33
33
  icon={<MenuOutlined />}
@@ -1,26 +1,14 @@
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, SortableItem, TabsContextProvider, cx, 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';
7
6
  import { countGridCol } from '../../helpers';
8
7
  import { PageDesigner } from './Page.Designer';
9
-
10
- const globalActionCSS = css`
11
- #nb-position-container > & {
12
- height: 49px;
13
- border-top: 1px solid #f0f2f5;
14
- margin-bottom: 0px !important;
15
- padding: 0 var(--nb-spacing);
16
- align-items: center;
17
- overflow-x: auto;
18
- background: #ffffff;
19
- z-index: 100;
20
- }
21
- `;
8
+ import useStyles from './style';
22
9
 
23
10
  const InternalPage: React.FC = (props) => {
11
+ const { styles } = useStyles();
24
12
  const Designer = useDesigner();
25
13
  const fieldSchema = useFieldSchema();
26
14
  const [searchParams, setSearchParams] = useSearchParams();
@@ -65,7 +53,7 @@ const InternalPage: React.FC = (props) => {
65
53
  }
66
54
  forceProps={{
67
55
  layout: 'one-column',
68
- className: globalActionCSS,
56
+ className: styles.globalActionCSS,
69
57
  }}
70
58
  >
71
59
  {props.children}
@@ -79,41 +67,13 @@ const InternalPage: React.FC = (props) => {
79
67
  );
80
68
 
81
69
  return (
82
- <SortableItem
83
- eid="nb-mobile-scroll-wrapper"
84
- className={cx(
85
- 'nb-mobile-page',
86
- css`
87
- background: #f0f2f5;
88
- display: flex;
89
- flex-direction: column;
90
- width: 100%;
91
- height: 100%;
92
- overflow-x: hidden;
93
- overflow-y: auto;
94
- padding-bottom: var(--nb-spacing);
95
- `,
96
- )}
97
- >
70
+ <SortableItem eid="nb-mobile-scroll-wrapper" className={cx('nb-mobile-page', styles.mobilePage)}>
98
71
  <Designer {...fieldSchema?.['x-designer-props']}></Designer>
99
72
  <div
100
73
  style={{
101
74
  paddingBottom: tabsSchema ? null : 'var(--nb-spacing)',
102
75
  }}
103
- className={cx(
104
- 'nb-mobile-page-header',
105
- css`
106
- & > .ant-tabs > .ant-tabs-nav {
107
- .ant-tabs-tab {
108
- margin: 0 !important;
109
- padding: 0 16px !important;
110
- }
111
- background: #fff;
112
- }
113
- display: flex;
114
- flex-direction: column;
115
- `,
116
- )}
76
+ className={cx('nb-mobile-page-header', styles.mobilePageHeader)}
117
77
  >
118
78
  <RecursionField
119
79
  schema={fieldSchema}
@@ -0,0 +1,43 @@
1
+ import { createStyles } from '@nocobase/client';
2
+
3
+ const useStyles = createStyles(({ token, css }) => {
4
+ return {
5
+ globalActionCSS: css`
6
+ #nb-position-container > & {
7
+ height: ${token.sizeXXL}px;
8
+ border-top: 1px solid var(--nb-box-bg);
9
+ margin-bottom: 0px !important;
10
+ padding: 0 var(--nb-spacing);
11
+ align-items: center;
12
+ overflow-x: auto;
13
+ background: ${token.colorBgContainer};
14
+ z-index: 100;
15
+ }
16
+ `,
17
+
18
+ mobilePage: css`
19
+ background: var(--nb-box-bg);
20
+ display: flex;
21
+ flex-direction: column;
22
+ width: 100%;
23
+ height: 100%;
24
+ overflow-x: hidden;
25
+ overflow-y: auto;
26
+ padding-bottom: var(--nb-spacing);
27
+ `,
28
+
29
+ mobilePageHeader: css`
30
+ & > .ant-tabs > .ant-tabs-nav {
31
+ .ant-tabs-tab {
32
+ margin: 0 !important;
33
+ padding: 0 ${token.paddingContentHorizontal}px !important;
34
+ }
35
+ background: ${token.colorBgContainer};
36
+ }
37
+ display: flex;
38
+ flex-direction: column;
39
+ `,
40
+ };
41
+ });
42
+
43
+ export default useStyles;
@@ -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();
@@ -36,6 +37,12 @@ export const InternalTabBar: React.FC = (props) => {
36
37
  properties: {
37
38
  [uid()]: PageSchema,
38
39
  },
40
+ 'x-server-hooks': [
41
+ {
42
+ type: 'onSelfSave',
43
+ method: 'extractTextToLocale',
44
+ },
45
+ ],
39
46
  });
40
47
  }, []);
41
48
 
@@ -75,7 +82,7 @@ export const InternalTabBar: React.FC = (props) => {
75
82
  key={`tab_${schema['x-uid']}`}
76
83
  title={
77
84
  <>
78
- {compile(cp.title)}
85
+ {t(compile(cp.title))}
79
86
  <SchemaComponent schema={schema} name={name} />
80
87
  </>
81
88
  }
@@ -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,12 +9,18 @@ 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: {
16
16
  ['x-uid']: fieldSchema['x-uid'],
17
17
  'x-component-props': fieldSchema['x-component-props'],
18
+ 'x-server-hooks': [
19
+ {
20
+ type: 'onSelfSave',
21
+ method: 'extractTextToLocale',
22
+ },
23
+ ],
18
24
  },
19
25
  });
20
26
  dn.refresh();
@@ -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,12 +1,10 @@
1
1
  import { i18n } from '@nocobase/client';
2
2
  import { useTranslation as useT } from 'react-i18next';
3
- import enUS from './en-US';
4
- import zhCN from './zh-CN';
5
3
 
6
4
  export const NAMESPACE = 'mobile-client';
7
5
 
8
- i18n.addResources('zh-CN', NAMESPACE, zhCN);
9
- i18n.addResources('en-US', NAMESPACE, enUS);
6
+ // i18n.addResources('zh-CN', NAMESPACE, zhCN);
7
+ // i18n.addResources('en-US', NAMESPACE, enUS);
10
8
 
11
9
  export function lang(key: string) {
12
10
  return i18n.t(key, { ns: NAMESPACE });
@@ -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,
@@ -42,11 +43,12 @@ const commonDesignerCSS = css`
42
43
  line-height: 16px;
43
44
  pointer-events: all;
44
45
  .ant-space-item {
45
- background-color: #f18b62;
46
+ background-color: var(--colorSettings);
46
47
  color: #fff;
47
48
  line-height: 16px;
48
49
  width: 16px;
49
50
  padding-left: 1px;
51
+ align-self: stretch;
50
52
  }
51
53
  }
52
54
  }
@@ -68,7 +70,7 @@ const modalProps = {
68
70
  position: 'absolute',
69
71
  },
70
72
  wrapClassName: css`
71
- position: absolute;
73
+ position: absolute !important;
72
74
  `,
73
75
  };
74
76
 
@@ -79,7 +81,6 @@ const useMobileSchemaUid = () => {
79
81
 
80
82
  const MApplication: React.FC = (props) => {
81
83
  const mobileSchemaUid = useMobileSchemaUid();
82
- console.log('mobileSchemaUid', mobileSchemaUid);
83
84
  const params = useParams<{ name: string }>();
84
85
  const interfaceContext = useInterfaceContext();
85
86
  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;