@steedos/service-pages 2.6.2-beta.5 → 2.6.2-beta.7
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.
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 孙浩林 6194896+sunhaolin@users.noreply.github.com
|
|
3
|
+
* @Date: 2023-12-10 11:09:40
|
|
4
|
+
* @LastEditors: 孙浩林 6194896+sunhaolin@users.noreply.github.com
|
|
5
|
+
* @LastEditTime: 2023-12-10 13:25:51
|
|
6
|
+
* @FilePath: /steedos-platform-2.3/services/service-pages/main/default/routes/page_render.router.js
|
|
7
|
+
* @Description: 支持使用schemaApi动态渲染页面,支持匿名访问。
|
|
8
|
+
*/
|
|
9
|
+
const express = require('express');
|
|
10
|
+
const router = express.Router();
|
|
11
|
+
const ejs = require('ejs');
|
|
12
|
+
|
|
13
|
+
router.get('/api/page/render', async function (req, res) {
|
|
14
|
+
try {
|
|
15
|
+
res.set('Content-Type', 'text/html');
|
|
16
|
+
const { schemaApi } = req.query;
|
|
17
|
+
const pageSchema = {
|
|
18
|
+
"type": "page",
|
|
19
|
+
"body": {
|
|
20
|
+
"type": "service",
|
|
21
|
+
"schemaApi": schemaApi
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let assetUrls = req.query.assetUrls;
|
|
26
|
+
|
|
27
|
+
let locale = "zh-CN";
|
|
28
|
+
if (req.query.locale == "en-us") {
|
|
29
|
+
locale = "en-US";
|
|
30
|
+
} else if (req.query.locale == "zh-cn") {
|
|
31
|
+
locale = "zh-CN";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const filename = __dirname + '/page_view.ejs';
|
|
35
|
+
const data = {
|
|
36
|
+
Title: 'page.label',
|
|
37
|
+
pageApiName: 'page.name',
|
|
38
|
+
STEEDOS_UNPKG_URL: process.env.STEEDOS_UNPKG_URL,
|
|
39
|
+
STEEDOS_AMIS_URL: process.env.STEEDOS_AMIS_URL,
|
|
40
|
+
STEEDOS_PUBLIC_PAGE_ASSETURLS: assetUrls || process.env.STEEDOS_PUBLIC_PAGE_ASSETURLS,
|
|
41
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
42
|
+
ROOT_URL: __meteor_runtime_config__.ROOT_URL,
|
|
43
|
+
STEEDOS_VERSION: process.env.STEEDOS_VERSION,
|
|
44
|
+
STEEDOS_AMIS_VERSION: process.env.STEEDOS_AMIS_VERSION,
|
|
45
|
+
STEEDOS_PUBLIC_SCRIPT_VCONSOLE: process.env.STEEDOS_PUBLIC_SCRIPT_VCONSOLE,
|
|
46
|
+
STEEDOS_PUBLIC_SCRIPT_PLUGINS: process.env.STEEDOS_PUBLIC_SCRIPT_PLUGINS,
|
|
47
|
+
STEEDOS_PUBLIC_STYLE_PLUGINS: process.env.STEEDOS_PUBLIC_STYLE_PLUGINS,
|
|
48
|
+
STEEDOS_LOCALE: locale,
|
|
49
|
+
USER_CONTEXT: {
|
|
50
|
+
user: {},
|
|
51
|
+
userId: "",
|
|
52
|
+
spaceId: ""
|
|
53
|
+
},
|
|
54
|
+
pageSchema: pageSchema,
|
|
55
|
+
__meteor_runtime_config__: __meteor_runtime_config__
|
|
56
|
+
}
|
|
57
|
+
const options = {}
|
|
58
|
+
ejs.renderFile(filename, data, options, function (err, str) {
|
|
59
|
+
// str => Rendered HTML string
|
|
60
|
+
if (err) {
|
|
61
|
+
console.log(`err`, err)
|
|
62
|
+
}
|
|
63
|
+
res.send(str);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
} catch (error) {
|
|
67
|
+
res.status(500).send({ message: error.message });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
});
|
|
71
|
+
exports.default = router;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-pages",
|
|
3
|
-
"version": "2.6.2-beta.
|
|
3
|
+
"version": "2.6.2-beta.7",
|
|
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": "7efe905d52798207bdf2c92a5f3cf385e58aae3e",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"ejs": "^3.1.8"
|
|
14
14
|
}
|