@steedos/service-pages 2.5.12-beta.3 → 2.5.12-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.
|
@@ -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,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "2.5.12-beta.
|
|
3
|
+
"version": "2.5.12-beta.4",
|
|
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": "
|
|
11
|
+
"gitHead": "77e1a00c5c9460e6b71199e6cc33d899a407a781",
|
|
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>
|