@pisell/lowcode-renderer 1.0.49 → 1.0.51
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.
- package/es/Render/index.js +22 -7
- package/lib/Render/index.js +16 -4
- package/package.json +2 -2
package/es/Render/index.js
CHANGED
|
@@ -17,11 +17,18 @@ import { injectComponents } from "@alilc/lowcode-plugin-inject";
|
|
|
17
17
|
import { AssetLoader, buildComponents } from "@alilc/lowcode-utils";
|
|
18
18
|
import { Skeleton } from "antd";
|
|
19
19
|
import { isArray, mergeWith, cloneDeep } from "lodash-es";
|
|
20
|
-
import React, { useEffect, useState } from "react";
|
|
20
|
+
import React, { useEffect, useState, useMemo } from "react";
|
|
21
21
|
import ReactRenderer from "../ReactRenderer";
|
|
22
22
|
import appHelper from "../appHelper";
|
|
23
|
+
import { generateUniqueIdByObj } from "@pisell/utils";
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
var isLoadAssets = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 缓存处理后的data信息 二次访问时
|
|
29
|
+
* 直接从缓存中获取
|
|
30
|
+
*/
|
|
31
|
+
var cacheDataMap = new Map();
|
|
25
32
|
var Render = function Render(props) {
|
|
26
33
|
var packages = props.packages,
|
|
27
34
|
projectSchema = props.projectSchema,
|
|
@@ -30,7 +37,13 @@ var Render = function Render(props) {
|
|
|
30
37
|
locale = props.locale,
|
|
31
38
|
_props$isShowSkeleton = props.isShowSkeleton,
|
|
32
39
|
isShowSkeleton = _props$isShowSkeleton === void 0 ? true : _props$isShowSkeleton;
|
|
33
|
-
var
|
|
40
|
+
var schemaHash = useMemo(function () {
|
|
41
|
+
if (projectSchema) {
|
|
42
|
+
return generateUniqueIdByObj(projectSchema);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}, [projectSchema]);
|
|
46
|
+
var _useState = useState(schemaHash ? cacheDataMap.get(schemaHash) || {} : {}),
|
|
34
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
48
|
data = _useState2[0],
|
|
36
49
|
setData = _useState2[1];
|
|
@@ -52,7 +65,7 @@ var Render = function Render(props) {
|
|
|
52
65
|
}
|
|
53
66
|
function _init() {
|
|
54
67
|
_init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
55
|
-
var componentsMapArray, componentsTree, i18n, projectDataSource, componentsMap, packagesMap, pageSchema, libraryMap, libraryAsset, assetLoader, components;
|
|
68
|
+
var componentsMapArray, componentsTree, i18n, projectDataSource, componentsMap, packagesMap, pageSchema, libraryMap, libraryAsset, assetLoader, components, _data;
|
|
56
69
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
70
|
while (1) switch (_context.prev = _context.next) {
|
|
58
71
|
case 0:
|
|
@@ -105,13 +118,15 @@ var Render = function Render(props) {
|
|
|
105
118
|
return injectComponents(buildComponents(libraryMap, componentsMap));
|
|
106
119
|
case 17:
|
|
107
120
|
components = _context.sent;
|
|
108
|
-
|
|
121
|
+
_data = {
|
|
109
122
|
schema: pageSchema,
|
|
110
123
|
components: components,
|
|
111
124
|
i18n: i18n,
|
|
112
125
|
projectDataSource: projectDataSource
|
|
113
|
-
}
|
|
114
|
-
|
|
126
|
+
};
|
|
127
|
+
cacheDataMap.set(schemaHash, _data);
|
|
128
|
+
setData(_data);
|
|
129
|
+
case 21:
|
|
115
130
|
case "end":
|
|
116
131
|
return _context.stop();
|
|
117
132
|
}
|
|
@@ -129,7 +144,7 @@ var Render = function Render(props) {
|
|
|
129
144
|
if (!schema || !components) {
|
|
130
145
|
init();
|
|
131
146
|
}
|
|
132
|
-
}, [data, projectSchema]);
|
|
147
|
+
}, [data, projectSchema, schemaHash]);
|
|
133
148
|
if (!schema || !components) {
|
|
134
149
|
if (!isShowSkeleton) {
|
|
135
150
|
return null;
|
package/lib/Render/index.js
CHANGED
|
@@ -39,7 +39,9 @@ var import_lodash_es = require("lodash-es");
|
|
|
39
39
|
var import_react = __toESM(require("react"));
|
|
40
40
|
var import_ReactRenderer = __toESM(require("../ReactRenderer"));
|
|
41
41
|
var import_appHelper = __toESM(require("../appHelper"));
|
|
42
|
+
var import_utils = require("@pisell/utils");
|
|
42
43
|
var isLoadAssets = false;
|
|
44
|
+
var cacheDataMap = /* @__PURE__ */ new Map();
|
|
43
45
|
var Render = (props) => {
|
|
44
46
|
const {
|
|
45
47
|
packages,
|
|
@@ -49,7 +51,15 @@ var Render = (props) => {
|
|
|
49
51
|
locale,
|
|
50
52
|
isShowSkeleton = true
|
|
51
53
|
} = props;
|
|
52
|
-
const
|
|
54
|
+
const schemaHash = (0, import_react.useMemo)(() => {
|
|
55
|
+
if (projectSchema) {
|
|
56
|
+
return (0, import_utils.generateUniqueIdByObj)(projectSchema);
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}, [projectSchema]);
|
|
60
|
+
const [data, setData] = (0, import_react.useState)(
|
|
61
|
+
schemaHash ? cacheDataMap.get(schemaHash) || {} : {}
|
|
62
|
+
);
|
|
53
63
|
const { schema, components, i18n = {}, projectDataSource = {} } = data;
|
|
54
64
|
(0, import_react.useEffect)(() => {
|
|
55
65
|
document.body.id = "body";
|
|
@@ -89,12 +99,14 @@ var Render = (props) => {
|
|
|
89
99
|
const components3 = await (0, import_lowcode_plugin_inject.injectComponents)(
|
|
90
100
|
(0, import_lowcode_utils.buildComponents)(libraryMap, componentsMap)
|
|
91
101
|
);
|
|
92
|
-
|
|
102
|
+
const _data = {
|
|
93
103
|
schema: pageSchema,
|
|
94
104
|
components: components3,
|
|
95
105
|
i18n: i18n3,
|
|
96
106
|
projectDataSource: projectDataSource3
|
|
97
|
-
}
|
|
107
|
+
};
|
|
108
|
+
cacheDataMap.set(schemaHash, _data);
|
|
109
|
+
setData(_data);
|
|
98
110
|
}
|
|
99
111
|
const {
|
|
100
112
|
schema: schema2,
|
|
@@ -105,7 +117,7 @@ var Render = (props) => {
|
|
|
105
117
|
if (!schema2 || !components2) {
|
|
106
118
|
init();
|
|
107
119
|
}
|
|
108
|
-
}, [data, projectSchema]);
|
|
120
|
+
}, [data, projectSchema, schemaHash]);
|
|
109
121
|
if (!schema || !components) {
|
|
110
122
|
if (!isShowSkeleton) {
|
|
111
123
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/lowcode-renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.51",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@alifd/next": "^1.25.44",
|
|
19
19
|
"lodash-es": "^4.17.21",
|
|
20
20
|
"dayjs": "^1.11.9",
|
|
21
|
-
"@pisell/utils": "1.0.
|
|
21
|
+
"@pisell/utils": "1.0.25"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=16.9.0",
|