@cqsjjb/jjb-cloud-component 0.0.1 → 0.0.2
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/cloud-component.d.ts
CHANGED
package/cloud-component.js
CHANGED
|
@@ -17,6 +17,8 @@ export default function CloudComponent(props) {
|
|
|
17
17
|
const [ Component, setComponent ] = React.useState(null);
|
|
18
18
|
const {
|
|
19
19
|
from,
|
|
20
|
+
cache,
|
|
21
|
+
headers,
|
|
20
22
|
initialize,
|
|
21
23
|
componentKey,
|
|
22
24
|
componentProps,
|
|
@@ -33,7 +35,11 @@ export default function CloudComponent(props) {
|
|
|
33
35
|
const {
|
|
34
36
|
module,
|
|
35
37
|
styleId: _styleId
|
|
36
|
-
} = await ImportCloudComponent({
|
|
38
|
+
} = await ImportCloudComponent({
|
|
39
|
+
from,
|
|
40
|
+
cache,
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
37
43
|
|
|
38
44
|
styleId = _styleId;
|
|
39
45
|
|
|
@@ -82,7 +82,7 @@ function checkDependencies(lib, dependencies, isProxy) {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* @description 手动加载模块
|
|
85
|
-
* @param options {{ from: string, lib: string }}
|
|
85
|
+
* @param options {{ from: string, lib: string, cache: string, headers: {} }}
|
|
86
86
|
* @example
|
|
87
87
|
* Import({
|
|
88
88
|
* from: 'https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js'
|
|
@@ -95,11 +95,17 @@ export default function ImportCloudComponent(options) {
|
|
|
95
95
|
const lib = options.lib || '__coreLib';
|
|
96
96
|
const from = options.from;
|
|
97
97
|
|
|
98
|
+
const cache = options.cache || 'force-cache';
|
|
99
|
+
const headers = tools.toObject(options.headers);
|
|
100
|
+
|
|
98
101
|
if (!from) {
|
|
99
102
|
throw Error(print('云组件资源访问地址不能为空!'));
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
return fetch(
|
|
105
|
+
return fetch(from, {
|
|
106
|
+
cache,
|
|
107
|
+
headers
|
|
108
|
+
})
|
|
103
109
|
.then(response => response.text())
|
|
104
110
|
.then(response => {
|
|
105
111
|
const {
|