@nocobase/plugin-mobile 1.6.0-alpha.3 → 1.6.0-alpha.31
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/LICENSE.txt +11 -9
- package/dist/client/constants.d.ts +0 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale.d.ts +2 -0
- package/dist/client/mobile/MobileAppContext.d.ts +2 -0
- package/dist/client/mobile-blocks/settings-block/MobileSettings.d.ts +1 -0
- package/dist/client/mobile-providers/context/MobileRoutes.d.ts +3 -0
- package/dist/client/pages/dynamic-page/components/MobileDatePicker.d.ts +8 -1
- package/dist/client/pages/dynamic-page/header/navigation-bar/actions/MobileNavigationActionBar.d.ts +3 -1
- package/dist/client/pages/dynamic-page/header/tabs/settings.d.ts +1 -1
- package/dist/externalVersion.js +12 -10
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/it-IT.json +29 -0
- package/dist/locale/ja-JP.json +3 -2
- package/dist/locale/zh-CN.json +3 -1
- package/dist/server/collections/mobileRoutes.js +38 -6
- package/dist/server/migrations/202503091240-fix-roles-mobile-routes.d.ts +13 -0
- package/dist/server/migrations/202503091240-fix-roles-mobile-routes.js +87 -0
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +96 -0
- package/package.json +5 -4
package/dist/client/locale.d.ts
CHANGED
|
@@ -8,3 +8,5 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function usePluginTranslation(): import("react-i18next").UseTranslationResponse<string[], undefined>;
|
|
10
10
|
export declare function generatePluginTranslationTemplate(key: string): string;
|
|
11
|
+
export declare const ROUTE_NAMESPACE = "lm-mobile-routes";
|
|
12
|
+
export declare function useRouteTranslation(): import("react-i18next").UseTranslationResponse<"lm-mobile-routes", undefined>;
|
|
@@ -10,6 +10,8 @@ import React, { FC } from 'react';
|
|
|
10
10
|
interface MobileAppContextProps {
|
|
11
11
|
showTabBar?: boolean;
|
|
12
12
|
setShowTabBar?: (showTabBar: boolean) => void;
|
|
13
|
+
showBackButton?: boolean;
|
|
14
|
+
setShowBackButton?: (showBackButton: boolean) => void;
|
|
13
15
|
}
|
|
14
16
|
export declare const MobileAppContext: React.Context<MobileAppContextProps>;
|
|
15
17
|
export interface MobileAppProviderProps {
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
+
export declare function UserCenter(): React.JSX.Element;
|
|
10
11
|
export declare const InternalSettings: () => React.JSX.Element;
|
|
11
12
|
export declare const MobileSettings: () => React.JSX.Element;
|
|
@@ -18,6 +18,9 @@ export interface MobileRouteItem {
|
|
|
18
18
|
icon?: string;
|
|
19
19
|
parentId?: number;
|
|
20
20
|
children?: MobileRouteItem[];
|
|
21
|
+
hideInMenu?: boolean;
|
|
22
|
+
enableTabs?: boolean;
|
|
23
|
+
hidden?: boolean;
|
|
21
24
|
}
|
|
22
25
|
export declare const MobileRoutesContext: React.Context<MobileRoutesContextValue>;
|
|
23
26
|
export interface MobileRoutesContextValue {
|
|
@@ -8,4 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
10
|
declare const MobileDateTimePicker: React.ForwardRefExoticComponent<Omit<Partial<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
11
|
-
|
|
11
|
+
declare const MobileRangePicker: (props: any) => React.JSX.Element;
|
|
12
|
+
declare const MobileDateFilterWithPicker: (props: any) => React.JSX.Element;
|
|
13
|
+
type ComposedMobileTimePicker = React.FC<any> & {
|
|
14
|
+
RangePicker?: React.FC<any>;
|
|
15
|
+
ReadPretty?: React.FC<any>;
|
|
16
|
+
};
|
|
17
|
+
declare const MobileTimePicker: ComposedMobileTimePicker;
|
|
18
|
+
export { MobileDateTimePicker, MobileRangePicker, MobileDateFilterWithPicker, MobileTimePicker };
|
package/dist/client/pages/dynamic-page/header/navigation-bar/actions/MobileNavigationActionBar.d.ts
CHANGED
|
@@ -25,4 +25,6 @@ export declare const ActionBarProvider: React.FC<ActionBarContextValue>;
|
|
|
25
25
|
export declare const useActionBarContext: () => ActionBarContextValue;
|
|
26
26
|
export declare const MobileNavigationActionBar: React.FunctionComponent<Omit<{
|
|
27
27
|
children?: React.ReactNode;
|
|
28
|
-
}, string | number | symbol> & Omit<any, "ref"
|
|
28
|
+
}, string | number | symbol> & Omit<any, "ref"> & {
|
|
29
|
+
children?: any;
|
|
30
|
+
}>;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import { FC } from 'react';
|
|
10
9
|
import { SchemaSettings } from '@nocobase/client';
|
|
10
|
+
import { FC } from 'react';
|
|
11
11
|
import { MobileRouteItem } from '../../../../mobile-providers';
|
|
12
12
|
export declare const mobilePageTabsSettings: SchemaSettings<{}>;
|
|
13
13
|
interface MobilePageTabsSettingsProps {
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,22 +11,24 @@ module.exports = {
|
|
|
11
11
|
"@emotion/css": "11.13.4",
|
|
12
12
|
"@formily/core": "2.3.0",
|
|
13
13
|
"@formily/shared": "2.3.2",
|
|
14
|
-
"@nocobase/client": "1.6.0-alpha.
|
|
15
|
-
"@nocobase/plugin-acl": "1.6.0-alpha.
|
|
14
|
+
"@nocobase/client": "1.6.0-alpha.31",
|
|
15
|
+
"@nocobase/plugin-acl": "1.6.0-alpha.31",
|
|
16
16
|
"ahooks": "3.7.8",
|
|
17
17
|
"antd": "5.12.8",
|
|
18
18
|
"lodash": "4.17.21",
|
|
19
19
|
"react": "18.2.0",
|
|
20
20
|
"react-i18next": "11.18.6",
|
|
21
|
-
"react-router-dom": "6.
|
|
22
|
-
"@nocobase/database": "1.6.0-alpha.
|
|
23
|
-
"@nocobase/
|
|
24
|
-
"@nocobase/
|
|
25
|
-
"@nocobase/utils": "1.6.0-alpha.
|
|
21
|
+
"react-router-dom": "6.28.1",
|
|
22
|
+
"@nocobase/database": "1.6.0-alpha.31",
|
|
23
|
+
"@nocobase/plugin-localization": "1.6.0-alpha.31",
|
|
24
|
+
"@nocobase/server": "1.6.0-alpha.31",
|
|
25
|
+
"@nocobase/utils": "1.6.0-alpha.31",
|
|
26
|
+
"@nocobase/test": "1.6.0-alpha.31",
|
|
26
27
|
"@formily/react": "2.3.0",
|
|
27
|
-
"@nocobase/plugin-mobile": "1.6.0-alpha.
|
|
28
|
-
"@ant-design/icons": "5.
|
|
28
|
+
"@nocobase/plugin-mobile": "1.6.0-alpha.31",
|
|
29
|
+
"@ant-design/icons": "5.6.1",
|
|
29
30
|
"react-dom": "18.2.0",
|
|
30
|
-
"@nocobase/sdk": "1.6.0-alpha.
|
|
31
|
+
"@nocobase/sdk": "1.6.0-alpha.31",
|
|
32
|
+
"dayjs": "1.11.10",
|
|
31
33
|
"@formily/antd-v5": "1.1.9"
|
|
32
34
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"Other desktop blocks": "Other desktop blocks",
|
|
24
24
|
"Settings": "Settings",
|
|
25
25
|
"Mobile menu": "Mobile menu",
|
|
26
|
+
"Mobile routes": "Mobile routes",
|
|
26
27
|
"No accessible pages found": "No accessible pages found",
|
|
27
28
|
"This might be due to permission configuration issues": "This might be due to permission configuration issues",
|
|
28
29
|
"Select time":"Select time"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"App settings": "Impostazioni app",
|
|
3
|
+
"Page settings": "Impostazioni pagina",
|
|
4
|
+
"Info": "Info",
|
|
5
|
+
"Back": "Indietro",
|
|
6
|
+
"Link": "Collegamento",
|
|
7
|
+
"Remove": "Rimuovi",
|
|
8
|
+
"Add page": "Aggiungi pagina",
|
|
9
|
+
"Title": "Titolo",
|
|
10
|
+
"Icon": "Icona",
|
|
11
|
+
"Selected icon": "Icona selezionata",
|
|
12
|
+
"Add link": "Aggiungi collegamento",
|
|
13
|
+
"Display tab bar": "Mostra barra tab",
|
|
14
|
+
"Display page header": "Mostra intestazione pagina",
|
|
15
|
+
"Display navigation bar": "Mostra barra di navigazione",
|
|
16
|
+
"Display page title": "Mostra titolo pagina",
|
|
17
|
+
"Display tabs": "Mostra tab",
|
|
18
|
+
"Add tab": "Aggiungi tab",
|
|
19
|
+
"Mobile": "Mobile",
|
|
20
|
+
"Title field is required": "Il campo titolo è obbligatorio",
|
|
21
|
+
"Icon field is required": "Il campo icona è obbligatorio",
|
|
22
|
+
"Desktop data blocks": "Blocchi dati desktop",
|
|
23
|
+
"Other desktop blocks": "Altri blocchi desktop",
|
|
24
|
+
"Settings": "Impostazioni",
|
|
25
|
+
"Mobile menu": "Menu mobile",
|
|
26
|
+
"No accessible pages found": "Nessuna pagina accessibile trovata",
|
|
27
|
+
"This might be due to permission configuration issues": "Questo potrebbe essere dovuto a problemi di configurazione dei permessi",
|
|
28
|
+
"Select time":"Seleziona orario"
|
|
29
|
+
}
|
package/dist/locale/ja-JP.json
CHANGED
package/dist/locale/zh-CN.json
CHANGED
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
"Other desktop blocks": "其他桌面端区块",
|
|
25
25
|
"Settings": "设置",
|
|
26
26
|
"Mobile menu": "移动端菜单",
|
|
27
|
+
"Mobile routes": "移动端路由",
|
|
27
28
|
"No accessible pages found": "没有找到你可以访问的页面",
|
|
28
29
|
"This might be due to permission configuration issues": "这可能是权限配置的问题",
|
|
29
30
|
"Select time": "选择时间",
|
|
30
31
|
"Clear": "清空",
|
|
31
32
|
"Confirm": "确认",
|
|
32
|
-
"Cancel": "取消"
|
|
33
|
+
"Cancel": "取消",
|
|
34
|
+
"Display < back button": "显示 < 返回按钮"
|
|
33
35
|
}
|
|
@@ -33,6 +33,7 @@ var import_database = require("@nocobase/database");
|
|
|
33
33
|
var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
34
34
|
name: "mobileRoutes",
|
|
35
35
|
dumpRules: "required",
|
|
36
|
+
migrationRules: ["overwrite", "schema-only"],
|
|
36
37
|
title: "mobileRoutes",
|
|
37
38
|
inherit: false,
|
|
38
39
|
hidden: false,
|
|
@@ -225,7 +226,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
225
226
|
uiSchema: {
|
|
226
227
|
type: "string",
|
|
227
228
|
"x-component": "Input",
|
|
228
|
-
title: "
|
|
229
|
+
title: '{{t("Title")}}'
|
|
229
230
|
}
|
|
230
231
|
},
|
|
231
232
|
{
|
|
@@ -240,7 +241,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
240
241
|
uiSchema: {
|
|
241
242
|
type: "string",
|
|
242
243
|
"x-component": "Input",
|
|
243
|
-
title: "
|
|
244
|
+
title: '{{t("Icon")}}'
|
|
244
245
|
}
|
|
245
246
|
},
|
|
246
247
|
{
|
|
@@ -255,7 +256,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
255
256
|
uiSchema: {
|
|
256
257
|
type: "string",
|
|
257
258
|
"x-component": "Input",
|
|
258
|
-
title: "
|
|
259
|
+
title: '{{t("Schema UID")}}'
|
|
259
260
|
}
|
|
260
261
|
},
|
|
261
262
|
{
|
|
@@ -270,7 +271,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
270
271
|
uiSchema: {
|
|
271
272
|
type: "string",
|
|
272
273
|
"x-component": "Input",
|
|
273
|
-
title: "
|
|
274
|
+
title: '{{t("Type")}}'
|
|
274
275
|
}
|
|
275
276
|
},
|
|
276
277
|
{
|
|
@@ -292,7 +293,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
292
293
|
}
|
|
293
294
|
},
|
|
294
295
|
default: null,
|
|
295
|
-
title: "
|
|
296
|
+
title: '{{t("Options")}}'
|
|
296
297
|
}
|
|
297
298
|
},
|
|
298
299
|
{
|
|
@@ -304,6 +305,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
304
305
|
collectionName: "mobileRoutes",
|
|
305
306
|
parentKey: null,
|
|
306
307
|
reverseKey: null,
|
|
308
|
+
scopeKey: "parentId",
|
|
307
309
|
uiSchema: {
|
|
308
310
|
type: "number",
|
|
309
311
|
"x-component": "InputNumber",
|
|
@@ -312,7 +314,7 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
312
314
|
step: "1"
|
|
313
315
|
},
|
|
314
316
|
"x-validator": "integer",
|
|
315
|
-
title: "
|
|
317
|
+
title: '{{t("Sort")}}'
|
|
316
318
|
}
|
|
317
319
|
},
|
|
318
320
|
{
|
|
@@ -321,6 +323,36 @@ var mobileRoutes_default = (0, import_database.defineCollection)({
|
|
|
321
323
|
through: "rolesMobileRoutes",
|
|
322
324
|
target: "roles",
|
|
323
325
|
onDelete: "CASCADE"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
type: "boolean",
|
|
329
|
+
name: "hideInMenu",
|
|
330
|
+
interface: "checkbox",
|
|
331
|
+
uiSchema: {
|
|
332
|
+
type: "boolean",
|
|
333
|
+
"x-component": "Checkbox",
|
|
334
|
+
title: '{{t("Hide in menu")}}'
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
type: "boolean",
|
|
339
|
+
name: "enableTabs",
|
|
340
|
+
interface: "checkbox",
|
|
341
|
+
uiSchema: {
|
|
342
|
+
type: "boolean",
|
|
343
|
+
"x-component": "Checkbox",
|
|
344
|
+
title: '{{t("Enable tabs")}}'
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
type: "boolean",
|
|
349
|
+
name: "hidden",
|
|
350
|
+
interface: "checkbox",
|
|
351
|
+
uiSchema: {
|
|
352
|
+
type: "boolean",
|
|
353
|
+
"x-component": "Checkbox",
|
|
354
|
+
title: '{{t("Hidden")}}'
|
|
355
|
+
}
|
|
324
356
|
}
|
|
325
357
|
],
|
|
326
358
|
category: [],
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var fix_roles_mobile_routes_exports = {};
|
|
38
|
+
__export(fix_roles_mobile_routes_exports, {
|
|
39
|
+
default: () => fix_roles_mobile_routes_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(fix_roles_mobile_routes_exports);
|
|
42
|
+
var import_server = require("@nocobase/server");
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
class fix_roles_mobile_routes_default extends import_server.Migration {
|
|
45
|
+
appVersion = "<1.6.0";
|
|
46
|
+
async up() {
|
|
47
|
+
const rolesMobileRoutesRepo = this.db.getRepository("rolesMobileRoutes");
|
|
48
|
+
const count = await rolesMobileRoutesRepo.count();
|
|
49
|
+
if (!count) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const mobileRoutesRepo = this.db.getRepository("mobileRoutes");
|
|
53
|
+
try {
|
|
54
|
+
await this.db.sequelize.transaction(async (transaction) => {
|
|
55
|
+
const rolesMobileRoutes = await rolesMobileRoutesRepo.find({ transaction });
|
|
56
|
+
const rolesMobileRouteIds = rolesMobileRoutes.map((x) => x.get("mobileRouteId"));
|
|
57
|
+
const mobileRoutes = await mobileRoutesRepo.find({
|
|
58
|
+
filter: { $or: [{ id: rolesMobileRouteIds }, { parentId: rolesMobileRouteIds }] },
|
|
59
|
+
transaction
|
|
60
|
+
});
|
|
61
|
+
const records = findMissingRoutes(rolesMobileRoutes, mobileRoutes);
|
|
62
|
+
await rolesMobileRoutesRepo.createMany({ records, transaction });
|
|
63
|
+
});
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error("Migration failed:", error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function findMissingRoutes(rolesMobileRoutes, mobileRoutes) {
|
|
71
|
+
const routeMap = import_lodash.default.keyBy(mobileRoutes, "id");
|
|
72
|
+
const group = (id, roleName) => `${id}_${roleName}`;
|
|
73
|
+
const existingMap = new Set(rolesMobileRoutes.map((x) => group(x.mobileRouteId, x.roleName)));
|
|
74
|
+
const missingRoutes = [];
|
|
75
|
+
rolesMobileRoutes.forEach((route) => {
|
|
76
|
+
const parentRoute = routeMap[route.mobileRouteId];
|
|
77
|
+
mobileRoutes.forEach((child) => {
|
|
78
|
+
if (child.hidden && child.parentId === parentRoute.id) {
|
|
79
|
+
const key = group(child.id, route.roleName);
|
|
80
|
+
if (!existingMap.has(key)) {
|
|
81
|
+
missingRoutes.push({ mobileRouteId: child.id, roleName: route.roleName });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
return missingRoutes;
|
|
87
|
+
}
|
package/dist/server/plugin.d.ts
CHANGED
package/dist/server/plugin.js
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var plugin_exports = {};
|
|
28
38
|
__export(plugin_exports, {
|
|
@@ -31,11 +41,28 @@ __export(plugin_exports, {
|
|
|
31
41
|
});
|
|
32
42
|
module.exports = __toCommonJS(plugin_exports);
|
|
33
43
|
var import_server = require("@nocobase/server");
|
|
44
|
+
var import_utils = require("@nocobase/utils");
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
34
46
|
class PluginMobileServer extends import_server.Plugin {
|
|
35
47
|
async load() {
|
|
36
48
|
this.registerActionHandlers();
|
|
37
49
|
this.bindNewMenuToRoles();
|
|
38
50
|
this.setACL();
|
|
51
|
+
this.registerLocalizationSource();
|
|
52
|
+
this.app.db.on("mobileRoutes.afterUpdate", async (instance, { transaction }) => {
|
|
53
|
+
if (instance.changed("enableTabs")) {
|
|
54
|
+
const repository = this.app.db.getRepository("mobileRoutes");
|
|
55
|
+
await repository.update({
|
|
56
|
+
filter: {
|
|
57
|
+
parentId: instance.id
|
|
58
|
+
},
|
|
59
|
+
values: {
|
|
60
|
+
hidden: !instance.enableTabs
|
|
61
|
+
},
|
|
62
|
+
transaction
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
39
66
|
}
|
|
40
67
|
setACL() {
|
|
41
68
|
this.app.acl.registerSnippet({
|
|
@@ -67,6 +94,45 @@ class PluginMobileServer extends import_server.Plugin {
|
|
|
67
94
|
transaction
|
|
68
95
|
});
|
|
69
96
|
});
|
|
97
|
+
const processRoleMobileRoutes = async (params) => {
|
|
98
|
+
const { models, action, transaction } = params;
|
|
99
|
+
if (!models.length) return;
|
|
100
|
+
const parentIds = models.map((x) => x.mobileRouteId);
|
|
101
|
+
const tabs = await this.app.db.getRepository("mobileRoutes").find({
|
|
102
|
+
where: { parentId: parentIds, hidden: true },
|
|
103
|
+
transaction
|
|
104
|
+
});
|
|
105
|
+
if (!tabs.length) return;
|
|
106
|
+
const repository = this.app.db.getRepository("rolesMobileRoutes");
|
|
107
|
+
const roleName = models[0].get("roleName");
|
|
108
|
+
const tabIds = tabs.map((x) => x.get("id"));
|
|
109
|
+
const where = { mobileRouteId: tabIds, roleName };
|
|
110
|
+
if (action === "create") {
|
|
111
|
+
const exists = await repository.find({ where });
|
|
112
|
+
const modelsByRouteId = import_lodash.default.keyBy(exists, (x) => x.get("mobileRouteId"));
|
|
113
|
+
const createModels = tabs.map((x) => !modelsByRouteId[x.get("id")] && { mobileRouteId: x.get("id"), roleName }).filter(Boolean);
|
|
114
|
+
for (const values of createModels) {
|
|
115
|
+
await repository.firstOrCreate({
|
|
116
|
+
values,
|
|
117
|
+
filterKeys: ["mobileRouteId", "roleName"],
|
|
118
|
+
transaction
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (action === "remove") {
|
|
124
|
+
return await repository.destroy({ filter: where, transaction });
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
this.app.db.on("rolesMobileRoutes.afterBulkCreate", async (instances, options) => {
|
|
128
|
+
await processRoleMobileRoutes({ models: instances, action: "create", transaction: options.transaction });
|
|
129
|
+
});
|
|
130
|
+
this.app.db.on("rolesMobileRoutes.afterBulkDestroy", async (options) => {
|
|
131
|
+
const models = await this.app.db.getRepository("rolesMobileRoutes").find({
|
|
132
|
+
where: options.where
|
|
133
|
+
});
|
|
134
|
+
await processRoleMobileRoutes({ models, action: "remove", transaction: options.transaction });
|
|
135
|
+
});
|
|
70
136
|
}
|
|
71
137
|
registerActionHandlers() {
|
|
72
138
|
this.app.resourceManager.registerActionHandler("mobileRoutes:listAccessible", async (ctx, next) => {
|
|
@@ -94,6 +160,36 @@ class PluginMobileServer extends import_server.Plugin {
|
|
|
94
160
|
await next();
|
|
95
161
|
});
|
|
96
162
|
}
|
|
163
|
+
registerLocalizationSource() {
|
|
164
|
+
const localizationPlugin = this.app.pm.get("localization");
|
|
165
|
+
if (!localizationPlugin) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
localizationPlugin.sourceManager.registerSource("mobile-routes", {
|
|
169
|
+
title: (0, import_utils.tval)("Mobile routes"),
|
|
170
|
+
sync: async (ctx) => {
|
|
171
|
+
const mobileRoutes = await ctx.db.getRepository("mobileRoutes").find({
|
|
172
|
+
raw: true
|
|
173
|
+
});
|
|
174
|
+
const resources = {};
|
|
175
|
+
mobileRoutes.forEach((route) => {
|
|
176
|
+
if (route.title) {
|
|
177
|
+
resources[route.title] = "";
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
"lm-mobile-routes": resources
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
namespace: "lm-mobile-routes",
|
|
185
|
+
collections: [
|
|
186
|
+
{
|
|
187
|
+
collection: "mobileRoutes",
|
|
188
|
+
fields: ["title"]
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
}
|
|
97
193
|
}
|
|
98
194
|
var plugin_default = PluginMobileServer;
|
|
99
195
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-mobile",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.31",
|
|
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",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@nocobase/client": "1.x",
|
|
14
14
|
"@nocobase/plugin-acl": "1.x",
|
|
15
|
+
"@nocobase/plugin-localization": "1.x",
|
|
15
16
|
"@nocobase/server": "1.x",
|
|
16
17
|
"@nocobase/test": "1.x"
|
|
17
18
|
},
|
|
@@ -22,8 +23,8 @@
|
|
|
22
23
|
"@formily/core": "2.x",
|
|
23
24
|
"@formily/react": "2.x",
|
|
24
25
|
"@formily/shared": "2.x",
|
|
25
|
-
"@types/react": "
|
|
26
|
-
"@types/react-dom": "
|
|
26
|
+
"@types/react": "18.x",
|
|
27
|
+
"@types/react-dom": "18.x",
|
|
27
28
|
"ahooks": "3.x",
|
|
28
29
|
"antd": "5.x",
|
|
29
30
|
"antd-mobile": "^5.38",
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"react-device-detect": "2.2.3",
|
|
33
34
|
"react-i18next": "11.x"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "2f118f0a0691dd51c437f208b1166258a615b6a8"
|
|
36
37
|
}
|