@nocobase/plugin-mobile 1.6.0-beta.16 → 1.6.0-beta.18

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.
@@ -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 {
@@ -11,24 +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-beta.16",
15
- "@nocobase/plugin-acl": "1.6.0-beta.16",
14
+ "@nocobase/client": "1.6.0-beta.18",
15
+ "@nocobase/plugin-acl": "1.6.0-beta.18",
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
21
  "react-router-dom": "6.28.1",
22
- "@nocobase/database": "1.6.0-beta.16",
23
- "@nocobase/server": "1.6.0-beta.16",
24
- "@nocobase/plugin-localization": "1.6.0-beta.16",
25
- "@nocobase/utils": "1.6.0-beta.16",
26
- "@nocobase/test": "1.6.0-beta.16",
22
+ "@nocobase/database": "1.6.0-beta.18",
23
+ "@nocobase/server": "1.6.0-beta.18",
24
+ "@nocobase/plugin-localization": "1.6.0-beta.18",
25
+ "@nocobase/utils": "1.6.0-beta.18",
26
+ "@nocobase/test": "1.6.0-beta.18",
27
27
  "@formily/react": "2.3.0",
28
- "@nocobase/plugin-mobile": "1.6.0-beta.16",
28
+ "@nocobase/plugin-mobile": "1.6.0-beta.18",
29
29
  "@ant-design/icons": "5.6.1",
30
30
  "react-dom": "18.2.0",
31
- "@nocobase/sdk": "1.6.0-beta.16",
31
+ "@nocobase/sdk": "1.6.0-beta.18",
32
32
  "dayjs": "1.11.10",
33
33
  "@formily/antd-v5": "1.1.9"
34
34
  };
@@ -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
+ }
@@ -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
+ }
@@ -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, {
@@ -32,6 +42,7 @@ __export(plugin_exports, {
32
42
  module.exports = __toCommonJS(plugin_exports);
33
43
  var import_server = require("@nocobase/server");
34
44
  var import_utils = require("@nocobase/utils");
45
+ var import_lodash = __toESM(require("lodash"));
35
46
  class PluginMobileServer extends import_server.Plugin {
36
47
  async load() {
37
48
  this.registerActionHandlers();
@@ -83,6 +94,38 @@ class PluginMobileServer extends import_server.Plugin {
83
94
  transaction
84
95
  });
85
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
+ return await repository.create({ values: createModels, transaction });
115
+ }
116
+ if (action === "remove") {
117
+ return await repository.destroy({ filter: where, transaction });
118
+ }
119
+ };
120
+ this.app.db.on("rolesMobileRoutes.afterBulkCreate", async (instances, options) => {
121
+ await processRoleMobileRoutes({ models: instances, action: "create", transaction: options.transaction });
122
+ });
123
+ this.app.db.on("rolesMobileRoutes.afterBulkDestroy", async (options) => {
124
+ const models = await this.app.db.getRepository("rolesMobileRoutes").find({
125
+ where: options.where
126
+ });
127
+ await processRoleMobileRoutes({ models, action: "remove", transaction: options.transaction });
128
+ });
86
129
  }
87
130
  registerActionHandlers() {
88
131
  this.app.resourceManager.registerActionHandler("mobileRoutes:listAccessible", async (ctx, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-mobile",
3
- "version": "1.6.0-beta.16",
3
+ "version": "1.6.0-beta.18",
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",
@@ -33,5 +33,5 @@
33
33
  "react-device-detect": "2.2.3",
34
34
  "react-i18next": "11.x"
35
35
  },
36
- "gitHead": "3171e60836b0ad0ad9ef02ecfbf16250a4afed89"
36
+ "gitHead": "b6981f549765a1f94fe43a18faa0eae9246fdd98"
37
37
  }