@tachybase/module-app-info 0.23.48 → 0.23.58

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.
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.48",
3
- "@tachybase/server": "0.23.48",
4
- "@tachybase/database": "0.23.48"
2
+ "@tachybase/client": "0.23.58",
3
+ "@tachybase/server": "0.23.58",
4
+ "@tachybase/database": "0.23.58"
5
5
  };
@@ -2,6 +2,7 @@ import { InstallOptions, Plugin } from '@tachybase/server';
2
2
  export declare class SystemSettingsPlugin extends Plugin {
3
3
  getInitAppLang(options: any): any;
4
4
  install(options?: InstallOptions): Promise<void>;
5
+ getSystemSettingsInstance(): Promise<any>;
5
6
  beforeLoad(): void;
6
7
  load(): Promise<void>;
7
8
  }
@@ -43,6 +43,17 @@ class SystemSettingsPlugin extends import_server.Plugin {
43
43
  }
44
44
  });
45
45
  }
46
+ async getSystemSettingsInstance() {
47
+ const repository = this.db.getRepository("systemSettings");
48
+ const instance = await repository.findOne({
49
+ filterByTk: 1,
50
+ appends: ["logo"]
51
+ });
52
+ const json = instance.toJSON();
53
+ json.raw_title = json.title;
54
+ json.title = this.app.environment.renderJsonTemplate(instance.title);
55
+ return json;
56
+ }
46
57
  beforeLoad() {
47
58
  const cmd = this.app.findCommand("install");
48
59
  if (cmd) {
@@ -50,7 +61,7 @@ class SystemSettingsPlugin extends import_server.Plugin {
50
61
  }
51
62
  this.app.acl.registerSnippet({
52
63
  name: `pm.${this.name}.system-settings`,
53
- actions: ["systemSettings:update"]
64
+ actions: ["systemSettings:put"]
54
65
  });
55
66
  }
56
67
  async load() {
@@ -59,6 +70,32 @@ class SystemSettingsPlugin extends import_server.Plugin {
59
70
  "id.$ne": 1
60
71
  };
61
72
  });
73
+ this.app.resourcer.define({
74
+ name: "systemSettings",
75
+ actions: {
76
+ get: async (ctx, next) => {
77
+ try {
78
+ ctx.body = await this.getSystemSettingsInstance();
79
+ } catch (error) {
80
+ throw error;
81
+ }
82
+ await next();
83
+ },
84
+ put: async (ctx, next) => {
85
+ const repository = this.db.getRepository("systemSettings");
86
+ const values = ctx.action.params.values;
87
+ await repository.update({
88
+ filterByTk: 1,
89
+ values: {
90
+ ...values,
91
+ title: values.raw_title
92
+ }
93
+ });
94
+ ctx.body = await this.getSystemSettingsInstance();
95
+ await next();
96
+ }
97
+ }
98
+ });
62
99
  this.app.acl.allow("systemSettings", "get", "public");
63
100
  }
64
101
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-app-info",
3
3
  "displayName": "System settings",
4
- "version": "0.23.48",
4
+ "version": "0.23.58",
5
5
  "description": "Used to adjust the system title, logo, language, etc.",
6
6
  "keywords": [
7
7
  "System management"
@@ -11,10 +11,10 @@
11
11
  "dependencies": {},
12
12
  "devDependencies": {},
13
13
  "peerDependencies": {
14
- "@tachybase/client": "0.23.48",
15
- "@tachybase/database": "0.23.48",
16
- "@tachybase/server": "0.23.48",
17
- "@tachybase/test": "0.23.48"
14
+ "@tachybase/client": "0.23.58",
15
+ "@tachybase/database": "0.23.58",
16
+ "@tachybase/test": "0.23.58",
17
+ "@tachybase/server": "0.23.58"
18
18
  },
19
19
  "description.zh-CN": "用于调整系统的标题、LOGO、语言等。",
20
20
  "displayName.zh-CN": "应用配置",