hzerojs-plugin-yqcloud-jssdk 1.0.7 → 1.0.9
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/lib/index.js +24 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -71,14 +71,31 @@ var src_default = (props) => {
|
|
|
71
71
|
console.log("悬浮窗收起了");
|
|
72
72
|
}
|
|
73
73
|
}, [isVisible]);
|
|
74
|
+
async function yqRequest(url, method, data) {
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
const xhr = new XMLHttpRequest();
|
|
77
|
+
xhr.withCredentials = false;
|
|
78
|
+
xhr.addEventListener("readystatechange", function() {
|
|
79
|
+
if (xhr.readyState === 4) {
|
|
80
|
+
try {
|
|
81
|
+
const res = JSON.parse(xhr.responseText);
|
|
82
|
+
resolve(res);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
resolve(xhr.responseText);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
xhr.open(
|
|
89
|
+
method,
|
|
90
|
+
url
|
|
91
|
+
);
|
|
92
|
+
xhr.setRequestHeader("Accept", "application/json, text/plain, */*");
|
|
93
|
+
xhr.send(data);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
74
96
|
(0, import_react.useEffect)(() => {
|
|
75
97
|
const url = `${apiHost}/iam/yqc/open_apps/quick/${token}`;
|
|
76
|
-
(
|
|
77
|
-
headers: {
|
|
78
|
-
"H-Request-Id": null,
|
|
79
|
-
"H-Menu-Id": null
|
|
80
|
-
}
|
|
81
|
-
}).then(function(jsonData) {
|
|
98
|
+
yqRequest(url, "GET").then(function(jsonData) {
|
|
82
99
|
try {
|
|
83
100
|
if (jsonData && jsonData.failed) {
|
|
84
101
|
console.log("【YQCloud】:", jsonData.message);
|
|
@@ -95,7 +112,7 @@ var src_default = (props) => {
|
|
|
95
112
|
const openModal = async (openFunction) => {
|
|
96
113
|
const secret = await import_axios.default.get(tokenPath || "/iam/v1/zknow/encrypt/quick");
|
|
97
114
|
const authUrl = `${apiHost}/oauth/public/quick_authentication?token=${token}`;
|
|
98
|
-
const res = await
|
|
115
|
+
const res = await yqRequest(authUrl, "POST", {
|
|
99
116
|
secret
|
|
100
117
|
// code,
|
|
101
118
|
});
|