@nocobase/plugin-client 1.6.0-beta.2 → 1.6.0-beta.4
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/DesktopRoutesManager.d.ts +10 -0
- package/dist/client/MobileRoutesManager.d.ts +10 -0
- package/dist/client/index.js +1 -1
- package/dist/client/locale/index.d.ts +12 -0
- package/dist/client/routesTableSchema.d.ts +1242 -0
- package/dist/client/useTableBlockProps.d.ts +23 -0
- package/dist/client/utils.d.ts +10 -0
- package/dist/collections/desktopRoutes.d.ts +10 -0
- package/dist/collections/desktopRoutes.js +419 -0
- package/dist/collections/mobileRoutes.d.ts +10 -0
- package/dist/collections/mobileRoutes.js +368 -0
- package/dist/externalVersion.js +11 -4
- package/dist/locale/en-US.js +26 -1
- package/dist/locale/es-ES.js +22 -1
- package/dist/locale/fr-FR.js +22 -1
- package/dist/locale/ja-JP.js +22 -1
- package/dist/locale/ko-KR.js +22 -1
- package/dist/locale/pt-BR.js +22 -1
- package/dist/locale/ru-RU.js +22 -1
- package/dist/locale/tr-TR.js +22 -1
- package/dist/locale/uk-UA.js +22 -1
- package/dist/locale/zh-CN.js +31 -2
- package/dist/locale/zh-TW.js +23 -1
- package/dist/node_modules/cronstrue/package.json +1 -1
- package/dist/server/collections/desktopRoutes.d.ts +10 -0
- package/dist/server/collections/desktopRoutes.js +44 -0
- package/dist/server/collections/extendRoleField.d.ts +14 -0
- package/dist/server/collections/extendRoleField.js +44 -0
- package/dist/server/migrations/2024122912211-transform-menu-schema-to-routes.d.ts +18 -0
- package/dist/server/migrations/2024122912211-transform-menu-schema-to-routes.js +193 -0
- package/dist/server/migrations/202502071837-fix-permissions.d.ts +17 -0
- package/dist/server/migrations/202502071837-fix-permissions.js +85 -0
- package/dist/server/server.d.ts +7 -0
- package/dist/server/server.js +118 -5
- package/package.json +3 -2
package/dist/server/server.js
CHANGED
|
@@ -41,11 +41,12 @@ __export(server_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(server_exports);
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
|
+
var process = __toESM(require("node:process"));
|
|
44
45
|
var import_path = require("path");
|
|
45
46
|
var import_antd = require("./antd");
|
|
46
47
|
var import_cron = require("./cron");
|
|
47
48
|
var import_cronstrue = require("./cronstrue");
|
|
48
|
-
var
|
|
49
|
+
var import_utils = require("@nocobase/utils");
|
|
49
50
|
async function getLang(ctx) {
|
|
50
51
|
const SystemSetting = ctx.db.getRepository("systemSettings");
|
|
51
52
|
const systemSetting = await SystemSetting.findOne();
|
|
@@ -96,17 +97,17 @@ class PluginClientServer extends import_server.Plugin {
|
|
|
96
97
|
this.app.acl.allow("app", "getInfo");
|
|
97
98
|
this.app.acl.registerSnippet({
|
|
98
99
|
name: "app",
|
|
99
|
-
actions: ["app:restart", "app:clearCache"]
|
|
100
|
+
actions: ["app:restart", "app:refresh", "app:clearCache"]
|
|
100
101
|
});
|
|
101
102
|
const dialect = this.app.db.sequelize.getDialect();
|
|
102
|
-
this.app.
|
|
103
|
+
this.app.resourceManager.define({
|
|
103
104
|
name: "app",
|
|
104
105
|
actions: {
|
|
105
106
|
async getInfo(ctx, next) {
|
|
106
107
|
var _a, _b;
|
|
107
108
|
const SystemSetting = ctx.db.getRepository("systemSettings");
|
|
108
109
|
const systemSetting = await SystemSetting.findOne();
|
|
109
|
-
const enabledLanguages = systemSetting.get("enabledLanguages") || [];
|
|
110
|
+
const enabledLanguages = (systemSetting == null ? void 0 : systemSetting.get("enabledLanguages")) || [];
|
|
110
111
|
const currentUser = ctx.state.currentUser;
|
|
111
112
|
let lang = (enabledLanguages == null ? void 0 : enabledLanguages[0]) || process.env.APP_LANG || "en-US";
|
|
112
113
|
if (enabledLanguages.includes(currentUser == null ? void 0 : currentUser.appLang)) {
|
|
@@ -149,10 +150,122 @@ class PluginClientServer extends import_server.Plugin {
|
|
|
149
150
|
async restart(ctx, next) {
|
|
150
151
|
ctx.app.runAsCLI(["restart"], { from: "user" });
|
|
151
152
|
await next();
|
|
153
|
+
},
|
|
154
|
+
async refresh(ctx, next) {
|
|
155
|
+
ctx.app.runCommand("refresh");
|
|
156
|
+
await next();
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
});
|
|
155
|
-
this.app.auditManager.registerActions(["app:restart", "app:clearCache"]);
|
|
160
|
+
this.app.auditManager.registerActions(["app:restart", "app:refresh", "app:clearCache"]);
|
|
161
|
+
this.registerActionHandlers();
|
|
162
|
+
this.bindNewMenuToRoles();
|
|
163
|
+
this.setACL();
|
|
164
|
+
this.registerLocalizationSource();
|
|
165
|
+
this.app.db.on("desktopRoutes.afterUpdate", async (instance, { transaction }) => {
|
|
166
|
+
if (instance.changed("enableTabs")) {
|
|
167
|
+
const repository = this.app.db.getRepository("desktopRoutes");
|
|
168
|
+
await repository.update({
|
|
169
|
+
filter: {
|
|
170
|
+
parentId: instance.id
|
|
171
|
+
},
|
|
172
|
+
values: {
|
|
173
|
+
hidden: !instance.enableTabs
|
|
174
|
+
},
|
|
175
|
+
transaction
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
setACL() {
|
|
181
|
+
this.app.acl.registerSnippet({
|
|
182
|
+
name: `ui.desktopRoutes`,
|
|
183
|
+
actions: ["desktopRoutes:create", "desktopRoutes:update", "desktopRoutes:move", "desktopRoutes:destroy"]
|
|
184
|
+
});
|
|
185
|
+
this.app.acl.registerSnippet({
|
|
186
|
+
name: `pm.desktopRoutes`,
|
|
187
|
+
actions: ["desktopRoutes:list", "roles.desktopRoutes:*"]
|
|
188
|
+
});
|
|
189
|
+
this.app.acl.allow("desktopRoutes", "listAccessible", "loggedIn");
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* used to implement: roles with permission (allowNewMenu is true) can directly access the newly created menu
|
|
193
|
+
*/
|
|
194
|
+
bindNewMenuToRoles() {
|
|
195
|
+
this.app.db.on("roles.beforeCreate", async (instance) => {
|
|
196
|
+
instance.set(
|
|
197
|
+
"allowNewMenu",
|
|
198
|
+
instance.allowNewMenu === void 0 ? ["admin", "member"].includes(instance.name) : !!instance.allowNewMenu
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
this.app.db.on("desktopRoutes.afterCreate", async (instance, { transaction }) => {
|
|
202
|
+
const addNewMenuRoles = await this.app.db.getRepository("roles").find({
|
|
203
|
+
filter: {
|
|
204
|
+
allowNewMenu: true
|
|
205
|
+
},
|
|
206
|
+
transaction
|
|
207
|
+
});
|
|
208
|
+
await this.app.db.getRepository("desktopRoutes.roles", instance.id).add({
|
|
209
|
+
tk: addNewMenuRoles.map((role) => role.name),
|
|
210
|
+
transaction
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
registerActionHandlers() {
|
|
215
|
+
this.app.resourceManager.registerActionHandler("desktopRoutes:listAccessible", async (ctx, next) => {
|
|
216
|
+
const desktopRoutesRepository = ctx.db.getRepository("desktopRoutes");
|
|
217
|
+
const rolesRepository = ctx.db.getRepository("roles");
|
|
218
|
+
if (ctx.state.currentRole === "root") {
|
|
219
|
+
ctx.body = await desktopRoutesRepository.find({
|
|
220
|
+
tree: true,
|
|
221
|
+
...ctx.query
|
|
222
|
+
});
|
|
223
|
+
return await next();
|
|
224
|
+
}
|
|
225
|
+
const role = await rolesRepository.findOne({
|
|
226
|
+
filterByTk: ctx.state.currentRole,
|
|
227
|
+
appends: ["desktopRoutes"]
|
|
228
|
+
});
|
|
229
|
+
const desktopRoutesId = role.get("desktopRoutes").filter((item) => !item.hidden).map((item) => item.id);
|
|
230
|
+
ctx.body = await desktopRoutesRepository.find({
|
|
231
|
+
tree: true,
|
|
232
|
+
...ctx.query,
|
|
233
|
+
filter: {
|
|
234
|
+
id: desktopRoutesId
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
await next();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
registerLocalizationSource() {
|
|
241
|
+
const localizationPlugin = this.app.pm.get("localization");
|
|
242
|
+
if (!localizationPlugin) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
localizationPlugin.sourceManager.registerSource("desktop-routes", {
|
|
246
|
+
title: (0, import_utils.tval)("Desktop routes"),
|
|
247
|
+
sync: async (ctx) => {
|
|
248
|
+
const desktopRoutes = await ctx.db.getRepository("desktopRoutes").find({
|
|
249
|
+
raw: true
|
|
250
|
+
});
|
|
251
|
+
const resources = {};
|
|
252
|
+
desktopRoutes.forEach((route) => {
|
|
253
|
+
if (route.title) {
|
|
254
|
+
resources[route.title] = "";
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
"lm-desktop-routes": resources
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
namespace: "lm-desktop-routes",
|
|
262
|
+
collections: [
|
|
263
|
+
{
|
|
264
|
+
collection: "desktopRoutes",
|
|
265
|
+
fields: ["title"]
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
});
|
|
156
269
|
}
|
|
157
270
|
}
|
|
158
271
|
var server_default = PluginClientServer;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "WEB 客户端",
|
|
5
5
|
"description": "Provides a client interface for the NocoBase server",
|
|
6
6
|
"description.zh-CN": "为 NocoBase 服务端提供客户端界面",
|
|
7
|
-
"version": "1.6.0-beta.
|
|
7
|
+
"version": "1.6.0-beta.4",
|
|
8
8
|
"main": "./dist/server/index.js",
|
|
9
9
|
"license": "AGPL-3.0",
|
|
10
10
|
"devDependencies": {
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@nocobase/client": "1.x",
|
|
18
18
|
"@nocobase/database": "1.x",
|
|
19
|
+
"@nocobase/plugin-localization": "1.x",
|
|
19
20
|
"@nocobase/server": "1.x",
|
|
20
21
|
"@nocobase/test": "1.x",
|
|
21
22
|
"@nocobase/utils": "1.x"
|
|
22
23
|
},
|
|
23
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "4419f433716dadf34886b261d9abe20e74551044"
|
|
24
25
|
}
|