@steedos/service-pages 2.5.12-beta.3 → 2.5.12-beta.5

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.
@@ -35,9 +35,6 @@ router.get('/api/pageDesign', core.requireAuthentication, async function (req, r
35
35
  const steedosBuilderUrl = process.env.STEEDOS_BUILDER_URL || 'https://builder.steedos.cn';
36
36
  const builderHost = `${steedosBuilderUrl}/amis?${assetUrl}retUrl=${retUrl}&locale=${locale}&pageType=${page.type}`;
37
37
 
38
- // let data = fs.readFileSync(__dirname+'/design.html', 'utf8');
39
- // res.send(data.replace('SteedosBuilderHost',steedosBuilderHost).replace('DataContext', JSON.stringify(dataContext)));
40
-
41
38
  const filename = __dirname+'/page_design.ejs'
42
39
  const data = {
43
40
  builderHost,
@@ -205,14 +205,27 @@ module.exports = {
205
205
  }
206
206
  return result;
207
207
  }
208
- }
208
+ },
209
+ addAssetUrl: {
210
+ handler: async function (ctx) {
211
+ const { url } = ctx.params;
212
+ return broker.broadcast("page.addAssetUrl", {
213
+ url
214
+ });
215
+ }
216
+ }
209
217
  },
210
218
 
211
219
  /**
212
220
  * Events
213
221
  */
214
222
  events: {
215
-
223
+ 'page.addAssetUrl': function (ctx) {
224
+ const { url } = ctx.params;
225
+ const urls = process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS.split(',');
226
+ urls.push(url);
227
+ process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS = _.compact(_.uniq(urls)).join(',');
228
+ }
216
229
  },
217
230
 
218
231
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-pages",
3
- "version": "2.5.12-beta.3",
3
+ "version": "2.5.12-beta.5",
4
4
  "main": "package.service.js",
5
5
  "scripts": {},
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "gitHead": "599ba38400e814a6433b3621e3f42bfab6e6015d",
11
+ "gitHead": "2630e6d45fdb76224f6c33904a5d0fb42771e147",
12
12
  "dependencies": {
13
13
  "ejs": "^3.1.8"
14
14
  }
@@ -1,117 +0,0 @@
1
- <html>
2
-
3
- <head>
4
- <script src="https://builder.steedos.cn/js/axios/axios.min.js"></script>
5
- <script src="https://builder.steedos.cn/js/builder-fiddle/builder-fiddle.umd.js"></script>
6
- </head>
7
-
8
- <body style="margin: 0;padding: 0;">
9
-
10
- <builder-fiddle host="SteedosBuilderHost"></builder-fiddle>
11
-
12
- <script>
13
- let comp = document.querySelector('builder-fiddle')
14
- var params = new URLSearchParams(location.search);
15
- var pageId = params.get("pageId");
16
- // /pageVersion/:pageId/latest
17
- const dataContext = DataContext;
18
- axios.get(`/service/api/page/pageVersion/${params.get("pageId")}/latest`).then(function (response) {
19
- let result = response.data;
20
-
21
- let schema = result?.schema;
22
- let objectName = result?.object_name;
23
- let pageType = result?.type;
24
- if (typeof schema === "string") {
25
- schema = JSON.parse(schema)
26
- }
27
- if(!schema){
28
- schema = {
29
- "type": "page",
30
- "body": [],
31
- "regions": [
32
- "body"
33
- ]
34
- };
35
- }
36
-
37
- if(!schema.data){
38
- schema.data = {}
39
- }
40
-
41
- if(!schema.data.context){
42
- schema.data.context = {}
43
- }
44
-
45
- schema.data.objectName = objectName;
46
-
47
- schema.data.context.rootUrl = dataContext.rootUrl;
48
- schema.data.context.tenantId = dataContext.tenantId;
49
- schema.data.context.userId = dataContext.userId;
50
- schema.data.context.authToken = dataContext.authToken;
51
-
52
- if(objectName && pageType === 'record'){
53
- axios.get(`/api/v4/${objectName}?$orderby=created desc&$top=1`).then(function (response) {
54
- const value = response.data?.value;
55
- if(value.length > 0){
56
- schema.data.recordId = value[0]._id;
57
- }
58
- const data = {
59
- AmisSchema: schema
60
- };
61
- console.log("record data", data)
62
- comp.data = data;
63
- });
64
- }else{
65
- const data = {
66
- AmisSchema: schema
67
- };
68
- console.log("record data", data)
69
- comp.data = data;
70
- }
71
-
72
-
73
- }).catch(function (error) {
74
- // handle error
75
- console.log(error);
76
- }).then(function () {
77
- // always executed
78
- });
79
-
80
- const onWindowMessage = function (event) {
81
- const { data } = event;
82
- if (data) {
83
- if (data.type === 'builder.saveContent') {
84
- axios.put(`/service/api/page/pageVersion/${params.get("pageId")}`, {
85
- schema: JSON.stringify(data.data.AmisSchema, null, 4) //直接存储json格式会导致react form异常。
86
- }).then(function (response) {
87
- window.postMessage(
88
- {
89
- type: 'builder.contentSaved',
90
- },
91
- '*'
92
- );
93
-
94
- try {
95
- //保存时, 刷新父页面
96
- if(window.opener){
97
- window.opener.postMessage(Object.assign({type: "record.edited"}, {objectName: 'pages'}, {record: {}}), "*")
98
- }
99
- } catch (error) {
100
- console.error(error)
101
- }
102
- }).catch(function (error) {
103
- // handle error
104
- console.log(error);
105
- }).then(function () {
106
- // always executed
107
- })
108
- }
109
- }
110
- }
111
-
112
- window.addEventListener('message', onWindowMessage);
113
-
114
- </script>
115
- </body>
116
-
117
- </html>