@steedos/service-plugin-amis 2.2.17 → 2.2.20
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.
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
; (function () {
|
|
8
|
+
|
|
8
9
|
try {
|
|
9
10
|
let amisStyle = document.createElement("link");
|
|
10
11
|
amisStyle.setAttribute("rel", "stylesheet");
|
|
@@ -13,48 +14,62 @@
|
|
|
13
14
|
document.getElementsByTagName("head")[0].appendChild(amisStyle);
|
|
14
15
|
} catch (error) {
|
|
15
16
|
console.error(error)
|
|
16
|
-
}
|
|
17
|
+
};
|
|
18
|
+
|
|
17
19
|
import('/amis/sdk/sdk.noreact.js').then(() => {
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
Promise.all([
|
|
22
|
+
waitForThing(window, 'assetsLoaded'),
|
|
23
|
+
waitForThing(window, 'React'),
|
|
24
|
+
waitForThing(window, 'Builder'),
|
|
25
|
+
waitForThing(window, 'amisRequire'),
|
|
26
|
+
]).then(()=>{
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
window.SAmisReners = [];
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
const amisComps = lodash.filter(Builder.registry['meta-components'], function(item){ return item.componentName && item.amis?.render});
|
|
31
|
+
|
|
32
|
+
let amisLib = amisRequire('amis');
|
|
33
|
+
|
|
34
|
+
lodash.each(amisComps,(comp)=>{
|
|
35
|
+
const Component = Builder.components.find(item => item.name === comp.componentName);
|
|
36
|
+
if (Component && !SAmisReners.includes(comp.amis?.render.type)){
|
|
37
|
+
try {
|
|
38
|
+
SAmisReners.push(comp.amis?.render.type);
|
|
39
|
+
amisLib.Renderer(
|
|
40
|
+
{
|
|
41
|
+
type: comp.amis?.render.type,
|
|
42
|
+
weight: comp.amis?.render.weight
|
|
43
|
+
}
|
|
44
|
+
)(Component.class);
|
|
45
|
+
} catch(e){console.log(e)}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
// Register amis render
|
|
50
|
+
var Amis = function (props) {
|
|
51
|
+
var schema = props.schema, data = props.data;
|
|
52
|
+
return React.createElement(React.Fragment, null,
|
|
53
|
+
React.createElement("div", { id: "amis-root" }),
|
|
54
|
+
// amisRequire('amis').render(schema, data, {theme: 'cxd'}))
|
|
55
|
+
function () {
|
|
56
|
+
setTimeout(function () {
|
|
57
|
+
amisRequire('amis/embed').embed('#amis-root', schema, {
|
|
58
|
+
data
|
|
59
|
+
})
|
|
60
|
+
}, 100)
|
|
61
|
+
}()
|
|
62
|
+
);
|
|
63
|
+
};
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{ name: 'data', type: 'object' },
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
})
|
|
57
|
-
})
|
|
65
|
+
Builder.registerComponent(Amis, {
|
|
66
|
+
name: 'Amis',
|
|
67
|
+
inputs: [
|
|
68
|
+
{ name: 'schema', type: 'object' },
|
|
69
|
+
{ name: 'data', type: 'object' },
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
});
|
|
58
73
|
});
|
|
59
74
|
|
|
60
75
|
})();
|
|
@@ -4,29 +4,10 @@
|
|
|
4
4
|
* @Description: 基于steedos builder 实现 Amis组件的动态注册
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
window.SAmisReners = [];
|
|
8
7
|
|
|
9
8
|
window.addEventListener('message', function (event) {
|
|
10
9
|
const { data } = event;
|
|
11
|
-
if (data.type === 'builder.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
lodash.each(amisComps,(comp)=>{
|
|
16
|
-
const Component = Builder.components.find(item => item.name === comp.componentName);
|
|
17
|
-
if (Component && !SAmisReners.includes(comp.amis?.render.type)){
|
|
18
|
-
try {
|
|
19
|
-
SAmisReners.push(comp.amis?.render.type);
|
|
20
|
-
amisLib.Renderer(
|
|
21
|
-
{
|
|
22
|
-
type: comp.amis?.render.type,
|
|
23
|
-
weight: comp.amis?.render.weight
|
|
24
|
-
}
|
|
25
|
-
)(Component.class);
|
|
26
|
-
} catch(e){console.log(e)}
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
window.amisComponentsLoaded = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
10
|
+
if (data.type === 'builder.assetsLoaded') {
|
|
11
|
+
window.assetsLoaded = true;
|
|
12
|
+
}
|
|
13
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-plugin-amis",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {},
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "a0462d803860690b47487ece88a0bbb380ba0f17"
|
|
12
12
|
}
|