@gct-paas/api 0.1.6-dev.1 → 0.1.6-dev.3
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NativeHTTP } from "../utils/index.mjs";
|
|
2
2
|
import { HttpUtil } from "./http.util.mjs";
|
|
3
3
|
export function installHttpUtil() {
|
|
4
|
-
if (window.
|
|
4
|
+
if (window.__GCT_ANDROID__ !== true) {
|
|
5
5
|
console.debug("\u5F53\u524D\u73AF\u5883\u975E Android\uFF0C\u5DF2\u8DF3\u8FC7 HTTP \u5DE5\u5177\u7C7B\u5B89\u88C5");
|
|
6
6
|
return;
|
|
7
7
|
}
|
package/es/types/index.d.ts
CHANGED
|
@@ -28,6 +28,14 @@ declare global {
|
|
|
28
28
|
* @interface IObject
|
|
29
29
|
*/
|
|
30
30
|
type IObject = Record<string | symbol, any>;
|
|
31
|
+
interface Window {
|
|
32
|
+
/**
|
|
33
|
+
* 安卓混合开发模式标识,由原生层注入,值为 true 时表示在安卓混合开发模式下运行
|
|
34
|
+
*
|
|
35
|
+
* @type {boolean}
|
|
36
|
+
*/
|
|
37
|
+
__GCT_ANDROID__?: boolean;
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
/**
|
|
33
41
|
* 查询分页对象
|
|
@@ -2,16 +2,24 @@ import dsBridge from "dsbridge";
|
|
|
2
2
|
import qs from "qs";
|
|
3
3
|
export const NativeHTTP = {
|
|
4
4
|
request(querydata) {
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const {
|
|
6
|
+
method,
|
|
7
|
+
url,
|
|
8
|
+
timeout,
|
|
9
|
+
params,
|
|
10
|
+
headers,
|
|
11
|
+
data,
|
|
12
|
+
baseURL = ""
|
|
13
|
+
} = querydata;
|
|
14
|
+
const pathParam = "?" + qs.stringify(params);
|
|
15
|
+
const allUrl = (baseURL + url).replace(/([^:])\/\//g, "$1/") + pathParam;
|
|
16
|
+
console.info(allUrl + ">>HTTP", querydata);
|
|
9
17
|
const startTime = performance.now();
|
|
10
18
|
return new Promise((resolve, reject) => {
|
|
11
19
|
dsBridge.call(
|
|
12
20
|
"HTTP." + method,
|
|
13
21
|
{
|
|
14
|
-
url:
|
|
22
|
+
url: allUrl,
|
|
15
23
|
timeout,
|
|
16
24
|
headers,
|
|
17
25
|
data: data && typeof data === "string" ? JSON.parse(data) : data
|
|
@@ -19,7 +27,7 @@ export const NativeHTTP = {
|
|
|
19
27
|
function(res) {
|
|
20
28
|
const nativeData = JSON.parse(res);
|
|
21
29
|
console.info(
|
|
22
|
-
|
|
30
|
+
`${allUrl} >> HTTP.response - \u8017\u65F6\uFF1A${performance.now() - startTime}`,
|
|
23
31
|
nativeData
|
|
24
32
|
);
|
|
25
33
|
if (nativeData.code === 0 && nativeData.http_code === 200) {
|