@nocobase/plugin-mobile 1.3.38-beta → 1.4.0-alpha
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/dist/client/MenuPermissions.d.ts +15 -0
- package/dist/client/ShowTipWhenNoPages.d.ts +10 -0
- package/dist/client/adaptor-of-desktop/mobile-action-page/blockInitializers.d.ts +11 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +25 -13
- package/dist/client/mobile-layout/mobile-tab-bar/styles.d.ts +1 -0
- package/dist/client/mobile-providers/context/MobileRoutes.d.ts +12 -4
- package/dist/externalVersion.js +16 -13
- package/dist/locale/en-US.json +4 -1
- package/dist/locale/zh-CN.json +4 -1
- package/dist/server/collections/extendRoleField.d.ts +14 -0
- package/dist/server/collections/extendRoleField.js +48 -0
- package/dist/server/collections/mobileRoutes.js +7 -0
- package/dist/server/migrations/202409131546-set-mobileMenuUiSchemas.d.ts +14 -0
- package/dist/server/migrations/202409131546-set-mobileMenuUiSchemas.js +64 -0
- package/dist/server/plugin.d.ts +6 -0
- package/dist/server/plugin.js +55 -4
- package/package.json +10 -3
- /package/dist/locale/{ja_JP.json → ja-JP.json} +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { APIClient } from '@nocobase/client';
|
|
10
|
-
import React from 'react';
|
|
10
|
+
import React, { FC } from 'react';
|
|
11
11
|
import type { IResource } from '@nocobase/sdk';
|
|
12
12
|
export interface MobileRouteItem {
|
|
13
13
|
id: number;
|
|
@@ -30,6 +30,14 @@ export interface MobileRoutesContextValue {
|
|
|
30
30
|
api: APIClient;
|
|
31
31
|
}
|
|
32
32
|
export declare const useMobileRoutes: () => MobileRoutesContextValue;
|
|
33
|
-
export declare const MobileRoutesProvider:
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
export declare const MobileRoutesProvider: FC<{
|
|
34
|
+
/**
|
|
35
|
+
* list: return all route data, and only administrators can access;
|
|
36
|
+
* listAccessible: return the route data that the current user can access;
|
|
37
|
+
*
|
|
38
|
+
* @default 'listAccessible'
|
|
39
|
+
*/
|
|
40
|
+
action?: 'list' | 'listAccessible';
|
|
41
|
+
refreshRef?: any;
|
|
42
|
+
manual?: boolean;
|
|
43
|
+
}>;
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,23 +8,26 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@
|
|
11
|
+
"@emotion/css": "11.13.4",
|
|
12
|
+
"@formily/core": "2.3.0",
|
|
13
|
+
"@formily/shared": "2.3.0",
|
|
14
|
+
"@nocobase/client": "1.4.0-alpha",
|
|
15
|
+
"@nocobase/plugin-acl": "1.4.0-alpha",
|
|
16
|
+
"ahooks": "3.7.8",
|
|
17
|
+
"antd": "5.12.8",
|
|
18
|
+
"lodash": "4.17.21",
|
|
12
19
|
"react": "18.2.0",
|
|
13
|
-
"react-router-dom": "6.21.0",
|
|
14
20
|
"react-i18next": "11.18.6",
|
|
15
|
-
"
|
|
16
|
-
"@nocobase/
|
|
17
|
-
"@nocobase/
|
|
21
|
+
"react-router-dom": "6.21.0",
|
|
22
|
+
"@nocobase/database": "1.4.0-alpha",
|
|
23
|
+
"@nocobase/server": "1.4.0-alpha",
|
|
24
|
+
"@nocobase/test": "1.4.0-alpha",
|
|
25
|
+
"@nocobase/utils": "1.4.0-alpha",
|
|
18
26
|
"@formily/react": "2.3.0",
|
|
19
|
-
"
|
|
20
|
-
"@nocobase/plugin-mobile": "1.3.38-beta",
|
|
27
|
+
"@nocobase/plugin-mobile": "1.4.0-alpha",
|
|
21
28
|
"@ant-design/icons": "5.2.6",
|
|
22
|
-
"@nocobase/database": "1.3.38-beta",
|
|
23
|
-
"lodash": "4.17.21",
|
|
24
29
|
"react-dom": "18.2.0",
|
|
25
30
|
"antd-style": "3.4.5",
|
|
26
|
-
"@nocobase/sdk": "1.
|
|
27
|
-
"@formily/antd-v5": "1.1.9"
|
|
28
|
-
"@formily/shared": "2.3.0",
|
|
29
|
-
"@emotion/css": "11.13.0"
|
|
31
|
+
"@nocobase/sdk": "1.4.0-alpha",
|
|
32
|
+
"@formily/antd-v5": "1.1.9"
|
|
30
33
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -21,5 +21,8 @@
|
|
|
21
21
|
"Icon field is required": "Icon field is required",
|
|
22
22
|
"Desktop data blocks": "Desktop data blocks",
|
|
23
23
|
"Other desktop blocks": "Other desktop blocks",
|
|
24
|
-
"Settings": "Settings"
|
|
24
|
+
"Settings": "Settings",
|
|
25
|
+
"Mobile menu": "Mobile menu",
|
|
26
|
+
"No accessible pages found": "No accessible pages found",
|
|
27
|
+
"This might be due to permission configuration issues": "This might be due to permission configuration issues"
|
|
25
28
|
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -22,5 +22,8 @@
|
|
|
22
22
|
"Icon field is required": "图标必填",
|
|
23
23
|
"Desktop data blocks": "桌面端数据区块",
|
|
24
24
|
"Other desktop blocks": "其他桌面端区块",
|
|
25
|
-
"Settings": "设置"
|
|
25
|
+
"Settings": "设置",
|
|
26
|
+
"Mobile menu": "移动端菜单",
|
|
27
|
+
"No accessible pages found": "没有找到你可以访问的页面",
|
|
28
|
+
"This might be due to permission configuration issues": "这可能是权限配置的问题"
|
|
26
29
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: {
|
|
10
|
+
collectionOptions: import("@nocobase/database").CollectionOptions;
|
|
11
|
+
mergeOptions: import("deepmerge").Options;
|
|
12
|
+
extend: boolean;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var extendRoleField_exports = {};
|
|
28
|
+
__export(extendRoleField_exports, {
|
|
29
|
+
default: () => extendRoleField_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(extendRoleField_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
var extendRoleField_default = (0, import_database.extendCollection)({
|
|
34
|
+
name: "roles",
|
|
35
|
+
fields: [
|
|
36
|
+
{
|
|
37
|
+
type: "belongsToMany",
|
|
38
|
+
name: "mobileRoutes",
|
|
39
|
+
target: "mobileRoutes",
|
|
40
|
+
through: "rolesMobileRoutes",
|
|
41
|
+
onDelete: "CASCADE"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "boolean",
|
|
45
|
+
name: "allowNewMobileMenu"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
});
|
|
@@ -314,6 +314,13 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
314
314
|
"x-validator": "integer",
|
|
315
315
|
title: "sort"
|
|
316
316
|
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
type: "belongsToMany",
|
|
320
|
+
name: "roles",
|
|
321
|
+
through: "rolesMobileRoutes",
|
|
322
|
+
target: "roles",
|
|
323
|
+
onDelete: "CASCADE"
|
|
317
324
|
}
|
|
318
325
|
],
|
|
319
326
|
category: [],
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
appVersion: string;
|
|
12
|
+
up(): Promise<void>;
|
|
13
|
+
down(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var set_mobileMenuUiSchemas_exports = {};
|
|
28
|
+
__export(set_mobileMenuUiSchemas_exports, {
|
|
29
|
+
default: () => set_mobileMenuUiSchemas_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(set_mobileMenuUiSchemas_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
/* istanbul ignore file -- @preserve */
|
|
34
|
+
class set_mobileMenuUiSchemas_default extends import_server.Migration {
|
|
35
|
+
appVersion = "<1.4.0-beta";
|
|
36
|
+
async up() {
|
|
37
|
+
await this.db.sequelize.transaction(async (transaction) => {
|
|
38
|
+
const mobileRoutes = await this.db.getRepository("mobileRoutes").find({
|
|
39
|
+
sort: "sort",
|
|
40
|
+
transaction
|
|
41
|
+
});
|
|
42
|
+
const roles = await this.db.getRepository("roles").find({
|
|
43
|
+
filter: {
|
|
44
|
+
"allowNewMobileMenu.$isFalsy": true
|
|
45
|
+
},
|
|
46
|
+
transaction
|
|
47
|
+
});
|
|
48
|
+
const mobileRouteIds = mobileRoutes.map((item) => item.get("id"));
|
|
49
|
+
for (const role of roles) {
|
|
50
|
+
if (role.allowNewMobileMenu === false) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
role.allowNewMobileMenu = true;
|
|
54
|
+
await role.save({ transaction });
|
|
55
|
+
await this.db.getRepository("roles.mobileRoutes", role.get("name")).add({
|
|
56
|
+
tk: mobileRouteIds,
|
|
57
|
+
transaction
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async down() {
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -9,5 +9,11 @@
|
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
10
|
export declare class PluginMobileServer extends Plugin {
|
|
11
11
|
load(): Promise<void>;
|
|
12
|
+
setACL(): void;
|
|
13
|
+
/**
|
|
14
|
+
* used to implement: roles with permission (allowNewMobileMenu is true) can directly access the newly created menu
|
|
15
|
+
*/
|
|
16
|
+
bindNewMenuToRoles(): void;
|
|
17
|
+
registerActionHandlers(): void;
|
|
12
18
|
}
|
|
13
19
|
export default PluginMobileServer;
|
package/dist/server/plugin.js
CHANGED
|
@@ -33,15 +33,66 @@ module.exports = __toCommonJS(plugin_exports);
|
|
|
33
33
|
var import_server = require("@nocobase/server");
|
|
34
34
|
class PluginMobileServer extends import_server.Plugin {
|
|
35
35
|
async load() {
|
|
36
|
+
this.registerActionHandlers();
|
|
37
|
+
this.bindNewMenuToRoles();
|
|
38
|
+
this.setACL();
|
|
39
|
+
}
|
|
40
|
+
setACL() {
|
|
36
41
|
this.app.acl.registerSnippet({
|
|
37
|
-
name: `ui
|
|
42
|
+
name: `ui.mobile`,
|
|
38
43
|
actions: ["mobileRoutes:create", "mobileRoutes:update", "mobileRoutes:destroy"]
|
|
39
44
|
});
|
|
40
45
|
this.app.acl.registerSnippet({
|
|
41
|
-
name: `pm
|
|
42
|
-
actions: ["mobileRoutes:list"]
|
|
46
|
+
name: `pm.mobile`,
|
|
47
|
+
actions: ["mobileRoutes:list", "roles.mobileRoutes:*"]
|
|
48
|
+
});
|
|
49
|
+
this.app.acl.allow("mobileRoutes", "listAccessible", "loggedIn");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* used to implement: roles with permission (allowNewMobileMenu is true) can directly access the newly created menu
|
|
53
|
+
*/
|
|
54
|
+
bindNewMenuToRoles() {
|
|
55
|
+
this.app.db.on("roles.beforeCreate", async (instance) => {
|
|
56
|
+
instance.set("allowNewMobileMenu", ["admin", "member"].includes(instance.name));
|
|
57
|
+
});
|
|
58
|
+
this.app.db.on("mobileRoutes.afterCreate", async (instance, { transaction }) => {
|
|
59
|
+
const addNewMenuRoles = await this.app.db.getRepository("roles").find({
|
|
60
|
+
filter: {
|
|
61
|
+
allowNewMobileMenu: true
|
|
62
|
+
},
|
|
63
|
+
transaction
|
|
64
|
+
});
|
|
65
|
+
await this.app.db.getRepository("mobileRoutes.roles", instance.id).add({
|
|
66
|
+
tk: addNewMenuRoles.map((role) => role.name),
|
|
67
|
+
transaction
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
registerActionHandlers() {
|
|
72
|
+
this.app.resourceManager.registerActionHandler("mobileRoutes:listAccessible", async (ctx, next) => {
|
|
73
|
+
const mobileRoutesRepository = ctx.db.getRepository("mobileRoutes");
|
|
74
|
+
const rolesRepository = ctx.db.getRepository("roles");
|
|
75
|
+
if (ctx.state.currentRole === "root") {
|
|
76
|
+
ctx.body = await mobileRoutesRepository.find({
|
|
77
|
+
tree: true,
|
|
78
|
+
...ctx.query
|
|
79
|
+
});
|
|
80
|
+
return await next();
|
|
81
|
+
}
|
|
82
|
+
const role = await rolesRepository.findOne({
|
|
83
|
+
filterByTk: ctx.state.currentRole,
|
|
84
|
+
appends: ["mobileRoutes"]
|
|
85
|
+
});
|
|
86
|
+
const mobileRoutesId = role.get("mobileRoutes").map((item) => item.id);
|
|
87
|
+
ctx.body = await mobileRoutesRepository.find({
|
|
88
|
+
tree: true,
|
|
89
|
+
...ctx.query,
|
|
90
|
+
filter: {
|
|
91
|
+
id: mobileRoutesId
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
await next();
|
|
43
95
|
});
|
|
44
|
-
this.app.acl.allow("mobileRoutes", "list", "loggedIn");
|
|
45
96
|
}
|
|
46
97
|
}
|
|
47
98
|
var plugin_default = PluginMobileServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/mobile",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/mobile",
|
|
@@ -11,19 +11,26 @@
|
|
|
11
11
|
"description.zh-CN": "提供移动端页面配置的能力。",
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@nocobase/client": "1.x",
|
|
14
|
+
"@nocobase/plugin-acl": "1.x",
|
|
14
15
|
"@nocobase/server": "1.x",
|
|
15
16
|
"@nocobase/test": "1.x"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@ant-design/icons": "5.x",
|
|
20
|
+
"@emotion/css": "11.x",
|
|
19
21
|
"@formily/antd-v5": "1.x",
|
|
22
|
+
"@formily/core": "2.x",
|
|
20
23
|
"@formily/react": "2.x",
|
|
21
24
|
"@formily/shared": "2.x",
|
|
22
25
|
"@types/react": "17.x",
|
|
23
26
|
"@types/react-dom": "17.x",
|
|
27
|
+
"ahooks": "3.x",
|
|
28
|
+
"antd": "5.x",
|
|
24
29
|
"antd-mobile": "^5.36.1",
|
|
30
|
+
"lodash": "4.x",
|
|
25
31
|
"re-resizable": "6.6.0",
|
|
26
|
-
"react-device-detect": "2.2.3"
|
|
32
|
+
"react-device-detect": "2.2.3",
|
|
33
|
+
"react-i18next": "11.x"
|
|
27
34
|
},
|
|
28
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "f097a2bddec152522b5645bd5d451f4c866d2060"
|
|
29
36
|
}
|
|
File without changes
|