@xuda.io/xuda-widget-plugin-xuda-drive 1.0.3 → 1.0.5
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/package.json +1 -1
- package/runtime.mjs +6 -21
package/package.json
CHANGED
package/runtime.mjs
CHANGED
|
@@ -557,38 +557,21 @@ export async function viewer(fields, e) {
|
|
|
557
557
|
|
|
558
558
|
e.$containerP.html(html);
|
|
559
559
|
|
|
560
|
-
const fetchWithTimeout = (url, options = {}, timeout = 600000) => {
|
|
561
|
-
// 100 seconds
|
|
562
|
-
const controller = new AbortController();
|
|
563
|
-
const { signal } = controller;
|
|
564
|
-
|
|
565
|
-
const timeoutPromise = new Promise((_, reject) =>
|
|
566
|
-
setTimeout(() => {
|
|
567
|
-
controller.abort();
|
|
568
|
-
reject(new Error("Request timed out"));
|
|
569
|
-
}, timeout)
|
|
570
|
-
);
|
|
571
|
-
|
|
572
|
-
const fetchPromise = fetch(url, { ...options, signal });
|
|
573
|
-
|
|
574
|
-
return Promise.race([fetchPromise, timeoutPromise]);
|
|
575
|
-
};
|
|
576
|
-
|
|
577
560
|
let opt = {};
|
|
578
561
|
|
|
579
562
|
try {
|
|
580
563
|
let domain =
|
|
581
564
|
e._session.engine_mode === "live_preview" ? `dev.xuda.io` : `xuda.io`;
|
|
582
565
|
|
|
583
|
-
const response = await
|
|
566
|
+
const response = await fetch(
|
|
584
567
|
`https://${domain}/cpi/search_drive_files_workspace`,
|
|
585
568
|
{
|
|
586
569
|
method: "POST",
|
|
587
570
|
headers: {
|
|
588
571
|
Accept: "application/json",
|
|
589
572
|
"Content-Type": "application/json",
|
|
590
|
-
"xu-gtp-token":
|
|
591
|
-
"xu-app-token":
|
|
573
|
+
"xu-gtp-token": e._session.gtp_token,
|
|
574
|
+
"xu-app-token": e._session.app_token,
|
|
592
575
|
},
|
|
593
576
|
body: JSON.stringify(opt),
|
|
594
577
|
}
|
|
@@ -599,5 +582,7 @@ export async function viewer(fields, e) {
|
|
|
599
582
|
}
|
|
600
583
|
const json = await response.json();
|
|
601
584
|
return json;
|
|
602
|
-
} catch (err) {
|
|
585
|
+
} catch (err) {
|
|
586
|
+
console.error(err);
|
|
587
|
+
}
|
|
603
588
|
}
|