@nocobase/plugin-system-settings 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.
@@ -8,8 +8,8 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.6.0-beta.2",
12
- "@nocobase/plugin-file-manager": "1.6.0-beta.2",
13
- "@nocobase/server": "1.6.0-beta.2",
14
- "@nocobase/database": "1.6.0-beta.2"
11
+ "@nocobase/client": "1.6.0-beta.4",
12
+ "@nocobase/plugin-file-manager": "1.6.0-beta.4",
13
+ "@nocobase/server": "1.6.0-beta.4",
14
+ "@nocobase/database": "1.6.0-beta.4"
15
15
  };
@@ -33,6 +33,7 @@ var import_database = require("@nocobase/database");
33
33
  var systemSettings_default = (0, import_database.defineCollection)({
34
34
  dumpRules: "required",
35
35
  name: "systemSettings",
36
+ migrationRules: ["overwrite", "skip"],
36
37
  fields: [
37
38
  {
38
39
  type: "string",
@@ -10,6 +10,7 @@ import { InstallOptions, Plugin } from '@nocobase/server';
10
10
  export declare class PluginSystemSettingsServer extends Plugin {
11
11
  getInitAppLang(options: any): any;
12
12
  install(options?: InstallOptions): Promise<void>;
13
+ getSystemSettingsInstance(): Promise<any>;
13
14
  beforeLoad(): void;
14
15
  load(): Promise<void>;
15
16
  }
@@ -63,6 +63,17 @@ class PluginSystemSettingsServer extends import_server.Plugin {
63
63
  }
64
64
  });
65
65
  }
66
+ async getSystemSettingsInstance() {
67
+ const repository = this.db.getRepository("systemSettings");
68
+ const instance = await repository.findOne({
69
+ filterByTk: 1,
70
+ appends: ["logo"]
71
+ });
72
+ const json = instance.toJSON();
73
+ json.raw_title = json.title;
74
+ json.title = this.app.environment.renderJsonTemplate(instance.title);
75
+ return json;
76
+ }
66
77
  beforeLoad() {
67
78
  const cmd = this.app.findCommand("install");
68
79
  if (cmd) {
@@ -70,16 +81,41 @@ class PluginSystemSettingsServer extends import_server.Plugin {
70
81
  }
71
82
  this.app.acl.registerSnippet({
72
83
  name: `pm.${this.name}.system-settings`,
73
- actions: ["systemSettings:update"]
84
+ actions: ["systemSettings:put"]
74
85
  });
75
86
  }
76
87
  async load() {
77
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
78
88
  this.app.acl.addFixedParams("systemSettings", "destroy", () => {
79
89
  return {
80
90
  "id.$ne": 1
81
91
  };
82
92
  });
93
+ this.app.resourceManager.define({
94
+ name: "systemSettings",
95
+ actions: {
96
+ get: async (ctx, next) => {
97
+ try {
98
+ ctx.body = await this.getSystemSettingsInstance();
99
+ } catch (error) {
100
+ throw error;
101
+ }
102
+ await next();
103
+ },
104
+ put: async (ctx, next) => {
105
+ const repository = this.db.getRepository("systemSettings");
106
+ const values = ctx.action.params.values;
107
+ await repository.update({
108
+ filterByTk: 1,
109
+ values: {
110
+ ...values,
111
+ title: values.raw_title
112
+ }
113
+ });
114
+ ctx.body = await this.getSystemSettingsInstance();
115
+ await next();
116
+ }
117
+ }
118
+ });
83
119
  this.app.acl.allow("systemSettings", "get", "public");
84
120
  }
85
121
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "系统设置",
5
5
  "description": "Used to adjust the system title, logo, language, etc.",
6
6
  "description.zh-CN": "用于调整系统的标题、LOGO、语言等。",
7
- "version": "1.6.0-beta.2",
7
+ "version": "1.6.0-beta.4",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/system-settings",
@@ -15,7 +15,7 @@
15
15
  "@nocobase/server": "1.x",
16
16
  "@nocobase/test": "1.x"
17
17
  },
18
- "gitHead": "476ab2f424d86f585c8fba1459568c8aec49a5c6",
18
+ "gitHead": "4419f433716dadf34886b261d9abe20e74551044",
19
19
  "keywords": [
20
20
  "System management"
21
21
  ]