@nocobase/plugin-mobile-client 0.10.0-alpha.2
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 +4 -0
- package/client.js +30 -0
- package/docs/en-US/index.md +7 -0
- package/docs/en-US/installation.md +13 -0
- package/docs/en-US/tabs.json +14 -0
- package/docs/en-US/usage.md +1 -0
- package/docs/zh-CN/index.md +7 -0
- package/docs/zh-CN/installation.md +13 -0
- package/docs/zh-CN/tabs.json +14 -0
- package/docs/zh-CN/usage.md +2 -0
- package/lib/client/configuration/App.d.ts +2 -0
- package/lib/client/configuration/App.js +40 -0
- package/lib/client/configuration/Interface.d.ts +2 -0
- package/lib/client/configuration/Interface.js +20 -0
- package/lib/client/configuration/index.d.ts +2 -0
- package/lib/client/configuration/index.js +27 -0
- package/lib/client/core/bridge/index.d.ts +2 -0
- package/lib/client/core/bridge/index.js +17 -0
- package/lib/client/core/bridge/injects.d.ts +13 -0
- package/lib/client/core/bridge/injects.js +13 -0
- package/lib/client/core/bridge/native-call.d.ts +1 -0
- package/lib/client/core/bridge/native-call.js +24 -0
- package/lib/client/core/index.d.ts +3 -0
- package/lib/client/core/index.js +46 -0
- package/lib/client/core/schema/common/index.d.ts +1 -0
- package/lib/client/core/schema/common/index.js +16 -0
- package/lib/client/core/schema/common/page.d.ts +16 -0
- package/lib/client/core/schema/common/page.js +23 -0
- package/lib/client/core/schema/components/container/Container.Designer.d.ts +2 -0
- package/lib/client/core/schema/components/container/Container.Designer.js +138 -0
- package/lib/client/core/schema/components/container/Container.d.ts +5 -0
- package/lib/client/core/schema/components/container/Container.js +150 -0
- package/lib/client/core/schema/components/container/index.d.ts +1 -0
- package/lib/client/core/schema/components/container/index.js +16 -0
- package/lib/client/core/schema/components/header/Header.Designer.d.ts +2 -0
- package/lib/client/core/schema/components/header/Header.Designer.js +72 -0
- package/lib/client/core/schema/components/header/Header.d.ts +10 -0
- package/lib/client/core/schema/components/header/Header.js +85 -0
- package/lib/client/core/schema/components/header/index.d.ts +1 -0
- package/lib/client/core/schema/components/header/index.js +16 -0
- package/lib/client/core/schema/components/index.d.ts +6 -0
- package/lib/client/core/schema/components/index.js +71 -0
- package/lib/client/core/schema/components/menu/Menu.Designer.d.ts +2 -0
- package/lib/client/core/schema/components/menu/Menu.Designer.js +81 -0
- package/lib/client/core/schema/components/menu/Menu.Item.d.ts +6 -0
- package/lib/client/core/schema/components/menu/Menu.Item.js +129 -0
- package/lib/client/core/schema/components/menu/Menu.d.ts +7 -0
- package/lib/client/core/schema/components/menu/Menu.js +88 -0
- package/lib/client/core/schema/components/menu/MenuBlockInitializer.d.ts +2 -0
- package/lib/client/core/schema/components/menu/MenuBlockInitializer.js +51 -0
- package/lib/client/core/schema/components/menu/index.d.ts +2 -0
- package/lib/client/core/schema/components/menu/index.js +27 -0
- package/lib/client/core/schema/components/menu/schema.d.ts +17 -0
- package/lib/client/core/schema/components/menu/schema.js +24 -0
- package/lib/client/core/schema/components/page/Page.Designer.d.ts +2 -0
- package/lib/client/core/schema/components/page/Page.Designer.js +160 -0
- package/lib/client/core/schema/components/page/Page.d.ts +5 -0
- package/lib/client/core/schema/components/page/Page.js +157 -0
- package/lib/client/core/schema/components/page/index.d.ts +1 -0
- package/lib/client/core/schema/components/page/index.js +16 -0
- package/lib/client/core/schema/components/settings/Settings.Designer.d.ts +2 -0
- package/lib/client/core/schema/components/settings/Settings.Designer.js +37 -0
- package/lib/client/core/schema/components/settings/Settings.d.ts +6 -0
- package/lib/client/core/schema/components/settings/Settings.js +43 -0
- package/lib/client/core/schema/components/settings/SettingsBlockInitializer.d.ts +2 -0
- package/lib/client/core/schema/components/settings/SettingsBlockInitializer.js +51 -0
- package/lib/client/core/schema/components/settings/index.d.ts +2 -0
- package/lib/client/core/schema/components/settings/index.js +27 -0
- package/lib/client/core/schema/components/tab-bar/TabBar.Item.d.ts +6 -0
- package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +80 -0
- package/lib/client/core/schema/components/tab-bar/TabBar.d.ts +6 -0
- package/lib/client/core/schema/components/tab-bar/TabBar.js +138 -0
- package/lib/client/core/schema/components/tab-bar/index.d.ts +1 -0
- package/lib/client/core/schema/components/tab-bar/index.js +16 -0
- package/lib/client/core/schema/components/tab-bar/schema.d.ts +18 -0
- package/lib/client/core/schema/components/tab-bar/schema.js +25 -0
- package/lib/client/core/schema/helpers/index.d.ts +67 -0
- package/lib/client/core/schema/helpers/index.js +49 -0
- package/lib/client/core/schema/hooks/index.d.ts +1 -0
- package/lib/client/core/schema/hooks/index.js +16 -0
- package/lib/client/core/schema/hooks/useSchemaPatch.d.ts +3 -0
- package/lib/client/core/schema/hooks/useSchemaPatch.js +61 -0
- package/lib/client/core/schema/index.d.ts +3 -0
- package/lib/client/core/schema/index.js +38 -0
- package/lib/client/core/schema/initializers/BlockInitializers.d.ts +147 -0
- package/lib/client/core/schema/initializers/BlockInitializers.js +79 -0
- package/lib/client/core/schema/initializers/index.d.ts +1 -0
- package/lib/client/core/schema/initializers/index.js +16 -0
- package/lib/client/core/schema/scopes/grid-card.d.ts +15 -0
- package/lib/client/core/schema/scopes/grid-card.js +45 -0
- package/lib/client/core/schema/scopes/index.d.ts +1 -0
- package/lib/client/core/schema/scopes/index.js +16 -0
- package/lib/client/devices/iOS6.d.ts +5 -0
- package/lib/client/devices/iOS6.js +32 -0
- package/lib/client/devices/index.d.ts +2 -0
- package/lib/client/devices/index.js +43 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +47 -0
- package/lib/client/locale/en-US.d.ts +2 -0
- package/lib/client/locale/en-US.js +9 -0
- package/lib/client/locale/index.d.ts +4 -0
- package/lib/client/locale/index.js +43 -0
- package/lib/client/locale/zh-CN.d.ts +32 -0
- package/lib/client/locale/zh-CN.js +39 -0
- package/lib/client/router/Application.d.ts +3 -0
- package/lib/client/router/Application.js +129 -0
- package/lib/client/router/InterfaceProvider.d.ts +4 -0
- package/lib/client/router/InterfaceProvider.js +29 -0
- package/lib/client/router/InterfaceRouter.d.ts +6 -0
- package/lib/client/router/InterfaceRouter.js +58 -0
- package/lib/client/router/RouteSwitchProvider.d.ts +2 -0
- package/lib/client/router/RouteSwitchProvider.js +59 -0
- package/lib/client/router/index.d.ts +2 -0
- package/lib/client/router/index.js +27 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +13 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +13 -0
- package/lib/server/plugin.d.ts +10 -0
- package/lib/server/plugin.js +57 -0
- package/lib/server/routes.d.ts +34 -0
- package/lib/server/routes.js +41 -0
- package/package.json +28 -0
- package/server.d.ts +4 -0
- package/server.js +30 -0
- package/src/client/configuration/App.tsx +23 -0
- package/src/client/configuration/Interface.tsx +11 -0
- package/src/client/configuration/index.ts +2 -0
- package/src/client/core/bridge/index.ts +2 -0
- package/src/client/core/bridge/injects.ts +14 -0
- package/src/client/core/bridge/native-call.ts +23 -0
- package/src/client/core/index.tsx +45 -0
- package/src/client/core/schema/common/index.ts +1 -0
- package/src/client/core/schema/common/page.ts +16 -0
- package/src/client/core/schema/components/container/Container.Designer.tsx +88 -0
- package/src/client/core/schema/components/container/Container.tsx +135 -0
- package/src/client/core/schema/components/container/index.ts +1 -0
- package/src/client/core/schema/components/header/Header.Designer.tsx +39 -0
- package/src/client/core/schema/components/header/Header.tsx +49 -0
- package/src/client/core/schema/components/header/index.ts +1 -0
- package/src/client/core/schema/components/index.ts +6 -0
- package/src/client/core/schema/components/menu/Menu.Designer.tsx +46 -0
- package/src/client/core/schema/components/menu/Menu.Item.tsx +97 -0
- package/src/client/core/schema/components/menu/Menu.tsx +82 -0
- package/src/client/core/schema/components/menu/MenuBlockInitializer.tsx +20 -0
- package/src/client/core/schema/components/menu/index.ts +2 -0
- package/src/client/core/schema/components/menu/schema.ts +17 -0
- package/src/client/core/schema/components/page/Page.Designer.tsx +106 -0
- package/src/client/core/schema/components/page/Page.tsx +132 -0
- package/src/client/core/schema/components/page/index.ts +1 -0
- package/src/client/core/schema/components/settings/Settings.Designer.tsx +22 -0
- package/src/client/core/schema/components/settings/Settings.tsx +25 -0
- package/src/client/core/schema/components/settings/SettingsBlockInitializer.tsx +20 -0
- package/src/client/core/schema/components/settings/index.ts +2 -0
- package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +67 -0
- package/src/client/core/schema/components/tab-bar/TabBar.tsx +108 -0
- package/src/client/core/schema/components/tab-bar/index.ts +1 -0
- package/src/client/core/schema/components/tab-bar/schema.ts +18 -0
- package/src/client/core/schema/helpers/index.ts +38 -0
- package/src/client/core/schema/hooks/index.ts +1 -0
- package/src/client/core/schema/hooks/useSchemaPatch.ts +24 -0
- package/src/client/core/schema/index.ts +3 -0
- package/src/client/core/schema/initializers/BlockInitializers.ts +81 -0
- package/src/client/core/schema/initializers/index.ts +1 -0
- package/src/client/core/schema/scopes/grid-card.ts +35 -0
- package/src/client/core/schema/scopes/index.ts +1 -0
- package/src/client/devices/iOS6.tsx +24 -0
- package/src/client/devices/index.tsx +27 -0
- package/src/client/index.tsx +33 -0
- package/src/client/locale/en-US.ts +5 -0
- package/src/client/locale/index.ts +23 -0
- package/src/client/locale/zh-CN.ts +33 -0
- package/src/client/router/Application.tsx +114 -0
- package/src/client/router/InterfaceProvider.tsx +11 -0
- package/src/client/router/InterfaceRouter.tsx +48 -0
- package/src/client/router/RouteSwitchProvider.tsx +31 -0
- package/src/client/router/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/index.ts +1 -0
- package/src/server/plugin.ts +25 -0
- package/src/server/routes.ts +38 -0
- package/types.d.ts +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { useInterfaceContext } from '../../../router/InterfaceProvider';
|
|
3
|
+
import { PaginationProps } from 'antd';
|
|
4
|
+
|
|
5
|
+
const listCss = css`
|
|
6
|
+
padding: 0 var(--nb-spacing);
|
|
7
|
+
& > .nb-action-bar {
|
|
8
|
+
padding: unset !important;
|
|
9
|
+
background: unset !important;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export const useGridCardBlockItemProps = () => {
|
|
13
|
+
return {
|
|
14
|
+
className: listCss,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const columnCountConfig = {
|
|
19
|
+
xs: 1,
|
|
20
|
+
sm: 1,
|
|
21
|
+
md: 1,
|
|
22
|
+
lg: 1,
|
|
23
|
+
xl: 1,
|
|
24
|
+
xxl: 1,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const useGridCardBlockProps = () => {
|
|
28
|
+
const isInterface = useInterfaceContext();
|
|
29
|
+
return {
|
|
30
|
+
columnCount: isInterface ? columnCountConfig : null,
|
|
31
|
+
pagination: {
|
|
32
|
+
simple: true,
|
|
33
|
+
} as PaginationProps,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './grid-card';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { css, cx } from '@emotion/css';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const iOS6: React.FC<{
|
|
5
|
+
className: string;
|
|
6
|
+
}> = (props) => {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
className={cx(
|
|
10
|
+
'nb-mobile-device-ios6',
|
|
11
|
+
css(`
|
|
12
|
+
display: flex;
|
|
13
|
+
width: 375px;
|
|
14
|
+
height: 667px;
|
|
15
|
+
`),
|
|
16
|
+
props.className,
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
{props.children}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default iOS6;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Device from './iOS6';
|
|
3
|
+
import { css, cx } from '@emotion/css';
|
|
4
|
+
|
|
5
|
+
export const MobileDevice: React.FC = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
className={cx(
|
|
9
|
+
'nb-mobile-device-wrapper',
|
|
10
|
+
css`
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
`,
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
<Device
|
|
20
|
+
className={css`
|
|
21
|
+
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
|
|
22
|
+
`}
|
|
23
|
+
{...props}
|
|
24
|
+
></Device>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SettingsCenterProvider } from '@nocobase/client';
|
|
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';
|
|
7
|
+
|
|
8
|
+
export default React.memo((props) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
|
|
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
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { i18n } from '@nocobase/client';
|
|
2
|
+
import { useTranslation as useT } from 'react-i18next';
|
|
3
|
+
import enUS from './en-US';
|
|
4
|
+
import zhCN from './zh-CN';
|
|
5
|
+
|
|
6
|
+
export const NAMESPACE = 'mobile-client';
|
|
7
|
+
|
|
8
|
+
i18n.addResources('zh-CN', NAMESPACE, zhCN);
|
|
9
|
+
i18n.addResources('en-US', NAMESPACE, enUS);
|
|
10
|
+
|
|
11
|
+
export function lang(key: string) {
|
|
12
|
+
return i18n.t(key, { ns: NAMESPACE });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function generateNTemplate(key: string) {
|
|
16
|
+
return `{{t('${key}', { ns: '${NAMESPACE}', nsMode: 'fallback' })}}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useTranslation() {
|
|
20
|
+
return useT([NAMESPACE, 'client'], {
|
|
21
|
+
nsMode: 'fallback',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const locale = {
|
|
2
|
+
'Mobile Client-side': '移动端',
|
|
3
|
+
'Interface Configuration': '界面配置',
|
|
4
|
+
'App Configuration': 'App配置',
|
|
5
|
+
'Enable TabBar': '启用底部标签栏',
|
|
6
|
+
Untitled: '未设置标题',
|
|
7
|
+
'Edit info': '编辑信息',
|
|
8
|
+
Title: '标题',
|
|
9
|
+
'Display back button': '展示退后按钮',
|
|
10
|
+
'Delete menu': '删除菜单',
|
|
11
|
+
'Edit menu info': '编辑菜单信息',
|
|
12
|
+
Menu: '菜单',
|
|
13
|
+
'Menu name': '菜单名',
|
|
14
|
+
Icon: '图标',
|
|
15
|
+
'Delete menu item?': '删除菜单项',
|
|
16
|
+
'Add menu item': '添加菜单项',
|
|
17
|
+
'Page template': '页面模板',
|
|
18
|
+
'Template mode': '模板模式',
|
|
19
|
+
'Enable Header': '启用头部栏',
|
|
20
|
+
'Enable Tabs': '启用标签栏',
|
|
21
|
+
'Delete tab item?': '是否删除标签项?',
|
|
22
|
+
'Add tab': '添加标签页',
|
|
23
|
+
'App level Configuration': '应用级别配置',
|
|
24
|
+
'Menu configuration': '菜单配置',
|
|
25
|
+
'Page configuration': '页面配置',
|
|
26
|
+
Settings: '设置',
|
|
27
|
+
'Delete settings block': '删除设置区块',
|
|
28
|
+
'Delete menu block': '删除菜单区块',
|
|
29
|
+
'Mobile client access address': '移动端访问地址',
|
|
30
|
+
'The full address is': '完整的地址是',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default locale;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Outlet, useParams } from 'react-router-dom';
|
|
3
|
+
import { ActionContextProvider, AdminProvider, RemoteSchemaComponent, useRoute, useViewport } from '@nocobase/client';
|
|
4
|
+
import { css, cx } from '@emotion/css';
|
|
5
|
+
import { useInterfaceContext } from './InterfaceProvider';
|
|
6
|
+
import { DrawerProps, ModalProps } from 'antd';
|
|
7
|
+
import { MobileCore } from '../core';
|
|
8
|
+
|
|
9
|
+
const commonCSSVariables = css`
|
|
10
|
+
--nb-spacing: 14px;
|
|
11
|
+
`;
|
|
12
|
+
const commonCSSOverride = css``;
|
|
13
|
+
const commonDesignerCSS = css`
|
|
14
|
+
--nb-designer-top: 2px;
|
|
15
|
+
--nb-designer-right: 2px;
|
|
16
|
+
.nb-sortable-designer:hover {
|
|
17
|
+
position: relative;
|
|
18
|
+
> .general-schema-designer {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
.general-schema-designer {
|
|
23
|
+
position: absolute;
|
|
24
|
+
z-index: 999;
|
|
25
|
+
top: 0;
|
|
26
|
+
bottom: 0;
|
|
27
|
+
left: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
display: none;
|
|
30
|
+
border: 0;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
> .general-schema-designer-icons {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: var(--nb-designer-top);
|
|
35
|
+
right: var(--nb-designer-right);
|
|
36
|
+
line-height: 16px;
|
|
37
|
+
pointer-events: all;
|
|
38
|
+
.ant-space-item {
|
|
39
|
+
background-color: #f18b62;
|
|
40
|
+
color: #fff;
|
|
41
|
+
line-height: 16px;
|
|
42
|
+
width: 16px;
|
|
43
|
+
padding-left: 1px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
const drawerProps: DrawerProps = {
|
|
50
|
+
getContainer: '.nb-mobile-application',
|
|
51
|
+
width: '90%',
|
|
52
|
+
style: {
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const modalProps = {
|
|
57
|
+
...drawerProps,
|
|
58
|
+
style: {
|
|
59
|
+
maxWidth: 'calc(100% - 16px)',
|
|
60
|
+
},
|
|
61
|
+
maskStyle: {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
},
|
|
64
|
+
wrapClassName: css`
|
|
65
|
+
position: absolute;
|
|
66
|
+
`,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const MApplication: React.FC = (props) => {
|
|
70
|
+
const route = useRoute();
|
|
71
|
+
const params = useParams<{ name: string }>();
|
|
72
|
+
const interfaceContext = useInterfaceContext();
|
|
73
|
+
const Provider = useMemo(() => {
|
|
74
|
+
return interfaceContext ? React.Fragment : AdminProvider;
|
|
75
|
+
}, [interfaceContext]);
|
|
76
|
+
|
|
77
|
+
useViewport();
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Provider>
|
|
81
|
+
<MobileCore>
|
|
82
|
+
<ActionContextProvider modalProps={modalProps as ModalProps} drawerProps={drawerProps}>
|
|
83
|
+
<div
|
|
84
|
+
className={cx(
|
|
85
|
+
'nb-mobile-application',
|
|
86
|
+
commonDesignerCSS,
|
|
87
|
+
commonCSSVariables,
|
|
88
|
+
commonCSSOverride,
|
|
89
|
+
css`
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
position: relative;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
`,
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
{params.name && !params.name.startsWith('tab_') ? (
|
|
100
|
+
<Outlet />
|
|
101
|
+
) : (
|
|
102
|
+
<RemoteSchemaComponent key={route.uiSchemaUid} uid={route.uiSchemaUid}>
|
|
103
|
+
{props.children}
|
|
104
|
+
</RemoteSchemaComponent>
|
|
105
|
+
)}
|
|
106
|
+
<div id="nb-position-container"></div>
|
|
107
|
+
</div>
|
|
108
|
+
</ActionContextProvider>
|
|
109
|
+
</MobileCore>
|
|
110
|
+
</Provider>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default MApplication;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export const InterfaceContext = React.createContext(null);
|
|
4
|
+
|
|
5
|
+
export const InterfaceProvider = (props) => {
|
|
6
|
+
return <InterfaceContext.Provider value={{ interface: true }}>{props.children}</InterfaceContext.Provider>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const useInterfaceContext = () => {
|
|
10
|
+
return useContext(InterfaceContext);
|
|
11
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RouteSwitch, useRoutes } from '@nocobase/client';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { HashRouter, UNSAFE_LocationContext, UNSAFE_RouteContext } from 'react-router-dom';
|
|
4
|
+
import { InterfaceProvider } from './InterfaceProvider';
|
|
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
|
+
}
|
|
19
|
+
|
|
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
|
+
return (
|
|
40
|
+
<RouteCleaner>
|
|
41
|
+
<HashRouter>
|
|
42
|
+
<InterfaceProvider>
|
|
43
|
+
<RouteSwitch routes={routes}></RouteSwitch>
|
|
44
|
+
</InterfaceProvider>
|
|
45
|
+
</HashRouter>
|
|
46
|
+
</RouteCleaner>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RouteSwitchProvider, useRouteSwitchContext } from '@nocobase/client';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { isJSBridge } from '../core/bridge';
|
|
5
|
+
import MApplication from './Application';
|
|
6
|
+
|
|
7
|
+
export const RouterSwitchProvider = (props) => {
|
|
8
|
+
const { routes, components } = useRouteSwitchContext();
|
|
9
|
+
// redirect to mobile
|
|
10
|
+
const location = useLocation();
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (isJSBridge) {
|
|
14
|
+
if (location.pathname.includes('/admin')) {
|
|
15
|
+
navigate('/mobile');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, [location.pathname, navigate]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<RouteSwitchProvider
|
|
22
|
+
routes={routes}
|
|
23
|
+
components={{
|
|
24
|
+
...components,
|
|
25
|
+
MApplication,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{props.children}
|
|
29
|
+
</RouteSwitchProvider>
|
|
30
|
+
);
|
|
31
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './server';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
2
|
+
import { routes } from './routes';
|
|
3
|
+
|
|
4
|
+
export class MobileClientPlugin extends Plugin {
|
|
5
|
+
afterAdd() {}
|
|
6
|
+
|
|
7
|
+
async load() {}
|
|
8
|
+
|
|
9
|
+
async install() {
|
|
10
|
+
const repository = this.app.db.getRepository('uiRoutes');
|
|
11
|
+
for (const values of routes) {
|
|
12
|
+
await repository.create({
|
|
13
|
+
values,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async afterEnable() {}
|
|
19
|
+
|
|
20
|
+
async afterDisable() {}
|
|
21
|
+
|
|
22
|
+
async remove() {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default MobileClientPlugin;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const routes = [
|
|
2
|
+
{
|
|
3
|
+
type: 'route',
|
|
4
|
+
path: '/mobile/:name(.+)?',
|
|
5
|
+
component: 'MApplication',
|
|
6
|
+
uiSchema: {
|
|
7
|
+
type: 'void',
|
|
8
|
+
'x-component': 'MContainer',
|
|
9
|
+
'x-designer': 'MContainer.Designer',
|
|
10
|
+
'x-component-props': {},
|
|
11
|
+
properties: {
|
|
12
|
+
page: {
|
|
13
|
+
type: 'void',
|
|
14
|
+
'x-component': 'MPage',
|
|
15
|
+
'x-designer': 'MPage.Designer',
|
|
16
|
+
'x-component-props': {},
|
|
17
|
+
properties: {
|
|
18
|
+
grid: {
|
|
19
|
+
type: 'void',
|
|
20
|
+
'x-component': 'Grid',
|
|
21
|
+
'x-initializer': 'MBlockInitializers',
|
|
22
|
+
'x-component-props': {
|
|
23
|
+
showDivider: false,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
routes: [
|
|
31
|
+
{
|
|
32
|
+
type: 'route',
|
|
33
|
+
path: '',
|
|
34
|
+
component: 'RouteSchemaComponent',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
];
|
package/types.d.ts
ADDED
|
File without changes
|