@scgczm/bridge 1.0.0 → 1.1.1
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/README.md +2 -1
- package/dist/cjs/index.d.ts +35 -3
- package/dist/cjs/index.js +59 -34
- package/dist/cjs/utils.d.ts +2 -2
- package/dist/cjs/utils.js +28 -28
- package/dist/esm/index.d.ts +35 -3
- package/dist/esm/index.js +57 -35
- package/dist/esm/utils.d.ts +2 -2
- package/dist/esm/utils.js +28 -28
- package/dist/umd/scgc_bridge.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommonResult } from
|
|
1
|
+
import { ICommonResult } from './utils';
|
|
2
2
|
export interface IGetSlideDataData {
|
|
3
3
|
token: string;
|
|
4
4
|
sessionId: string;
|
|
@@ -6,6 +6,8 @@ export interface IGetSlideDataData {
|
|
|
6
6
|
scene: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
+
* @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除
|
|
10
|
+
*
|
|
9
11
|
* @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
|
|
10
12
|
* @param {IGetSlideDataData} data
|
|
11
13
|
*/
|
|
@@ -144,7 +146,7 @@ export declare const scgcToSubSpecial: (data: IToSubSpecialData) => void;
|
|
|
144
146
|
export interface IMallDetailData {
|
|
145
147
|
json: string;
|
|
146
148
|
url: string;
|
|
147
|
-
ptype:
|
|
149
|
+
ptype: '0';
|
|
148
150
|
isDark: 0 | 1;
|
|
149
151
|
}
|
|
150
152
|
/**
|
|
@@ -207,4 +209,34 @@ export declare const scgcGetAvatar: () => Promise<ICommonResult<string>>;
|
|
|
207
209
|
*/
|
|
208
210
|
export declare const scgcGetNickName: () => Promise<ICommonResult<string>>;
|
|
209
211
|
export declare const scgcGetPhoneNumber: () => Promise<ICommonResult<string>>;
|
|
210
|
-
export
|
|
212
|
+
export interface IGetCaptchaVerifyParamData {
|
|
213
|
+
captchaVerifyParam: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @description 传递验证码参数到app(阿里验证码2.0使用)
|
|
217
|
+
* @param {IGetCaptchaVerifyParamData} data
|
|
218
|
+
* @param {string} data.captchaVerifyParam 验证码参数
|
|
219
|
+
*/
|
|
220
|
+
export declare const scgcGetCaptchaVerifyParam: (data: IGetCaptchaVerifyParamData) => void;
|
|
221
|
+
export { setDevMode, isScgcApp } from './utils';
|
|
222
|
+
export interface IProgramData {
|
|
223
|
+
programId: string;
|
|
224
|
+
groupId: string;
|
|
225
|
+
episodeId: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @description 打开原生综艺页面
|
|
229
|
+
* @param {IProgramData} data
|
|
230
|
+
* @param {string} data.programId 节目Id
|
|
231
|
+
* @param {string} data.groupId 合集Id
|
|
232
|
+
* @param {string} data.episodeId 单集Id
|
|
233
|
+
*/
|
|
234
|
+
export declare const scgctoVarietyshow: (data: IProgramData) => void;
|
|
235
|
+
/**
|
|
236
|
+
* @description 打开原生纪录片页面
|
|
237
|
+
* @param {IProgramData} data
|
|
238
|
+
* @param {string} data.programId 节目Id
|
|
239
|
+
* @param {string} data.groupId 合集Id
|
|
240
|
+
* @param {string} data.episodeId 单集Id
|
|
241
|
+
*/
|
|
242
|
+
export declare const scgctoDocumentshow: (data: IProgramData) => void;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isScgcApp = exports.setDevMode = exports.scgcGetPhoneNumber = exports.scgcGetNickName = exports.scgcGetAvatar = exports.scgcGetUserId = exports.scgcChangeStateBarColor = exports.scgcToAppHome = exports.scgcToKuaipai = exports.scgcToMall = exports.scgcFocusWeb = exports.scgcToMallDetail = exports.scgcToSubSpecial = exports.scgcSetVolume = exports.scgcToTopic = exports.scgcToLive = exports.scgcToSpecial = exports.scgcToDetail = exports.scgcToH5 = exports.scgcShare = exports.scgcSaveimage = exports.scgcOpenwechat = exports.scgcOpenexplorer = exports.scgcClose = exports.scgcScan = exports.scgcLogin = exports.scgcGetSlideData = void 0;
|
|
3
|
+
exports.scgctoDocumentshow = exports.scgctoVarietyshow = exports.isScgcApp = exports.setDevMode = exports.scgcGetCaptchaVerifyParam = exports.scgcGetPhoneNumber = exports.scgcGetNickName = exports.scgcGetAvatar = exports.scgcGetUserId = exports.scgcChangeStateBarColor = exports.scgcToAppHome = exports.scgcToKuaipai = exports.scgcToMall = exports.scgcFocusWeb = exports.scgcToMallDetail = exports.scgcToSubSpecial = exports.scgcSetVolume = exports.scgcToTopic = exports.scgcToLive = exports.scgcToSpecial = exports.scgcToDetail = exports.scgcToH5 = exports.scgcShare = exports.scgcSaveimage = exports.scgcOpenwechat = exports.scgcOpenexplorer = exports.scgcClose = exports.scgcScan = exports.scgcLogin = exports.scgcGetSlideData = void 0;
|
|
4
4
|
/*#__PURE__*/
|
|
5
5
|
var utils_1 = require("./utils");
|
|
6
6
|
(0, utils_1.initAsyncCallbackPool)();
|
|
7
7
|
var commonBridge = (0, utils_1.commonBridgeFun)();
|
|
8
8
|
/**
|
|
9
|
+
* @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除
|
|
10
|
+
*
|
|
9
11
|
* @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
|
|
10
12
|
* @param {IGetSlideDataData} data
|
|
11
13
|
*/
|
|
12
14
|
var scgcGetSlideData = function (data) {
|
|
13
|
-
commonBridge(
|
|
15
|
+
commonBridge('getSlideData', data);
|
|
14
16
|
};
|
|
15
17
|
exports.scgcGetSlideData = scgcGetSlideData;
|
|
16
18
|
/**
|
|
17
19
|
* @description 调用app登录
|
|
18
20
|
*/
|
|
19
21
|
var scgcLogin = function () {
|
|
20
|
-
commonBridge(
|
|
22
|
+
commonBridge('login');
|
|
21
23
|
};
|
|
22
24
|
exports.scgcLogin = scgcLogin;
|
|
23
25
|
/**
|
|
24
26
|
* @description 调用app扫码
|
|
25
27
|
*/
|
|
26
28
|
var scgcScan = function () {
|
|
27
|
-
commonBridge(
|
|
29
|
+
commonBridge('scan');
|
|
28
30
|
};
|
|
29
31
|
exports.scgcScan = scgcScan;
|
|
30
32
|
/**
|
|
31
33
|
* @description 关闭当前webview
|
|
32
34
|
*/
|
|
33
35
|
var scgcClose = function () {
|
|
34
|
-
commonBridge(
|
|
36
|
+
commonBridge('close');
|
|
35
37
|
};
|
|
36
38
|
exports.scgcClose = scgcClose;
|
|
37
39
|
/**
|
|
@@ -40,7 +42,7 @@ exports.scgcClose = scgcClose;
|
|
|
40
42
|
* @param {string} data.path 需要打开的url
|
|
41
43
|
*/
|
|
42
44
|
var scgcOpenexplorer = function (data) {
|
|
43
|
-
commonBridge(
|
|
45
|
+
commonBridge('openexplorer', data);
|
|
44
46
|
};
|
|
45
47
|
exports.scgcOpenexplorer = scgcOpenexplorer;
|
|
46
48
|
/**
|
|
@@ -50,7 +52,7 @@ exports.scgcOpenexplorer = scgcOpenexplorer;
|
|
|
50
52
|
* @param {string} data.path 小程序路径
|
|
51
53
|
*/
|
|
52
54
|
var scgcOpenwechat = function (data) {
|
|
53
|
-
commonBridge(
|
|
55
|
+
commonBridge('openwechat', data);
|
|
54
56
|
};
|
|
55
57
|
exports.scgcOpenwechat = scgcOpenwechat;
|
|
56
58
|
/**
|
|
@@ -59,7 +61,7 @@ exports.scgcOpenwechat = scgcOpenwechat;
|
|
|
59
61
|
* @param {string} data.data base64数据
|
|
60
62
|
*/
|
|
61
63
|
var scgcSaveimage = function (data) {
|
|
62
|
-
commonBridge(
|
|
64
|
+
commonBridge('saveimage', data);
|
|
63
65
|
};
|
|
64
66
|
exports.scgcSaveimage = scgcSaveimage;
|
|
65
67
|
/**
|
|
@@ -72,7 +74,7 @@ exports.scgcSaveimage = scgcSaveimage;
|
|
|
72
74
|
* @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置
|
|
73
75
|
*/
|
|
74
76
|
var scgcShare = function (data) {
|
|
75
|
-
commonBridge(
|
|
77
|
+
commonBridge('share', data);
|
|
76
78
|
};
|
|
77
79
|
exports.scgcShare = scgcShare;
|
|
78
80
|
/**
|
|
@@ -81,7 +83,7 @@ exports.scgcShare = scgcShare;
|
|
|
81
83
|
* @param {string} data.path 需要打开的url
|
|
82
84
|
*/
|
|
83
85
|
var scgcToH5 = function (data) {
|
|
84
|
-
commonBridge(
|
|
86
|
+
commonBridge('toH5', data);
|
|
85
87
|
};
|
|
86
88
|
exports.scgcToH5 = scgcToH5;
|
|
87
89
|
/**
|
|
@@ -91,7 +93,7 @@ exports.scgcToH5 = scgcToH5;
|
|
|
91
93
|
* @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链
|
|
92
94
|
*/
|
|
93
95
|
var scgcToDetail = function (data) {
|
|
94
|
-
commonBridge(
|
|
96
|
+
commonBridge('toDetail', data);
|
|
95
97
|
};
|
|
96
98
|
exports.scgcToDetail = scgcToDetail;
|
|
97
99
|
/**
|
|
@@ -100,7 +102,7 @@ exports.scgcToDetail = scgcToDetail;
|
|
|
100
102
|
* @param {string} data.id 专题id
|
|
101
103
|
*/
|
|
102
104
|
var scgcToSpecial = function (data) {
|
|
103
|
-
commonBridge(
|
|
105
|
+
commonBridge('toSpecial', data);
|
|
104
106
|
};
|
|
105
107
|
exports.scgcToSpecial = scgcToSpecial;
|
|
106
108
|
/**
|
|
@@ -110,7 +112,7 @@ exports.scgcToSpecial = scgcToSpecial;
|
|
|
110
112
|
* @param {string} data.type 直播样式 1 横版 2 竖版
|
|
111
113
|
*/
|
|
112
114
|
var scgcToLive = function (data) {
|
|
113
|
-
commonBridge(
|
|
115
|
+
commonBridge('toLive', data);
|
|
114
116
|
};
|
|
115
117
|
exports.scgcToLive = scgcToLive;
|
|
116
118
|
/**
|
|
@@ -121,7 +123,7 @@ exports.scgcToLive = scgcToLive;
|
|
|
121
123
|
* @param {string} data.id 话题id
|
|
122
124
|
*/
|
|
123
125
|
var scgcToTopic = function (data) {
|
|
124
|
-
commonBridge(
|
|
126
|
+
commonBridge('toTopic', data);
|
|
125
127
|
};
|
|
126
128
|
exports.scgcToTopic = scgcToTopic;
|
|
127
129
|
/**
|
|
@@ -130,7 +132,7 @@ exports.scgcToTopic = scgcToTopic;
|
|
|
130
132
|
* @param {number} data.type 0 调小 1 调大
|
|
131
133
|
*/
|
|
132
134
|
var scgcSetVolume = function (data) {
|
|
133
|
-
commonBridge(
|
|
135
|
+
commonBridge('setVolume', data);
|
|
134
136
|
};
|
|
135
137
|
exports.scgcSetVolume = scgcSetVolume;
|
|
136
138
|
/**
|
|
@@ -140,7 +142,7 @@ exports.scgcSetVolume = scgcSetVolume;
|
|
|
140
142
|
* @param {string} data.id 专题id
|
|
141
143
|
*/
|
|
142
144
|
var scgcToSubSpecial = function (data) {
|
|
143
|
-
commonBridge(
|
|
145
|
+
commonBridge('toSubSpecial', data);
|
|
144
146
|
};
|
|
145
147
|
exports.scgcToSubSpecial = scgcToSubSpecial;
|
|
146
148
|
/**
|
|
@@ -152,7 +154,7 @@ exports.scgcToSubSpecial = scgcToSubSpecial;
|
|
|
152
154
|
* @param {number} data.isDark 0 普通模式 1 黑暗模式
|
|
153
155
|
*/
|
|
154
156
|
var scgcToMallDetail = function (data) {
|
|
155
|
-
commonBridge(
|
|
157
|
+
commonBridge('detailJson', data);
|
|
156
158
|
};
|
|
157
159
|
exports.scgcToMallDetail = scgcToMallDetail;
|
|
158
160
|
/**
|
|
@@ -162,28 +164,28 @@ exports.scgcToMallDetail = scgcToMallDetail;
|
|
|
162
164
|
*
|
|
163
165
|
*/
|
|
164
166
|
var scgcFocusWeb = function (data) {
|
|
165
|
-
commonBridge(
|
|
167
|
+
commonBridge('focusWeb', data);
|
|
166
168
|
};
|
|
167
169
|
exports.scgcFocusWeb = scgcFocusWeb;
|
|
168
170
|
/**
|
|
169
171
|
* @description 跳转至积分商城
|
|
170
172
|
*/
|
|
171
173
|
var scgcToMall = function () {
|
|
172
|
-
commonBridge(
|
|
174
|
+
commonBridge('mall');
|
|
173
175
|
};
|
|
174
176
|
exports.scgcToMall = scgcToMall;
|
|
175
177
|
/**
|
|
176
178
|
* @description 跳转至快拍
|
|
177
179
|
*/
|
|
178
180
|
var scgcToKuaipai = function () {
|
|
179
|
-
commonBridge(
|
|
181
|
+
commonBridge('release');
|
|
180
182
|
};
|
|
181
183
|
exports.scgcToKuaipai = scgcToKuaipai;
|
|
182
184
|
/**
|
|
183
185
|
* @description 跳转至app首页
|
|
184
186
|
*/
|
|
185
187
|
var scgcToAppHome = function () {
|
|
186
|
-
commonBridge(
|
|
188
|
+
commonBridge('mainPage');
|
|
187
189
|
};
|
|
188
190
|
exports.scgcToAppHome = scgcToAppHome;
|
|
189
191
|
/**
|
|
@@ -193,7 +195,7 @@ exports.scgcToAppHome = scgcToAppHome;
|
|
|
193
195
|
*
|
|
194
196
|
*/
|
|
195
197
|
var scgcChangeStateBarColor = function (data) {
|
|
196
|
-
commonBridge(
|
|
198
|
+
commonBridge('changeStatebarColor', data);
|
|
197
199
|
};
|
|
198
200
|
exports.scgcChangeStateBarColor = scgcChangeStateBarColor;
|
|
199
201
|
/**
|
|
@@ -202,7 +204,7 @@ exports.scgcChangeStateBarColor = scgcChangeStateBarColor;
|
|
|
202
204
|
*
|
|
203
205
|
*/
|
|
204
206
|
var scgcGetUserId = function () {
|
|
205
|
-
return commonBridge(
|
|
207
|
+
return commonBridge('getUserId');
|
|
206
208
|
};
|
|
207
209
|
exports.scgcGetUserId = scgcGetUserId;
|
|
208
210
|
/**
|
|
@@ -211,7 +213,7 @@ exports.scgcGetUserId = scgcGetUserId;
|
|
|
211
213
|
*
|
|
212
214
|
*/
|
|
213
215
|
var scgcGetAvatar = function () {
|
|
214
|
-
return commonBridge(
|
|
216
|
+
return commonBridge('getAvatar');
|
|
215
217
|
};
|
|
216
218
|
exports.scgcGetAvatar = scgcGetAvatar;
|
|
217
219
|
/**
|
|
@@ -220,7 +222,7 @@ exports.scgcGetAvatar = scgcGetAvatar;
|
|
|
220
222
|
*
|
|
221
223
|
*/
|
|
222
224
|
var scgcGetNickName = function () {
|
|
223
|
-
return commonBridge(
|
|
225
|
+
return commonBridge('getNickName');
|
|
224
226
|
};
|
|
225
227
|
exports.scgcGetNickName = scgcGetNickName;
|
|
226
228
|
// /**
|
|
@@ -229,17 +231,40 @@ exports.scgcGetNickName = scgcGetNickName;
|
|
|
229
231
|
// *
|
|
230
232
|
// */
|
|
231
233
|
var scgcGetPhoneNumber = function () {
|
|
232
|
-
return commonBridge(
|
|
234
|
+
return commonBridge('getPhoneNumber');
|
|
233
235
|
};
|
|
234
236
|
exports.scgcGetPhoneNumber = scgcGetPhoneNumber;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
/**
|
|
238
|
+
* @description 传递验证码参数到app(阿里验证码2.0使用)
|
|
239
|
+
* @param {IGetCaptchaVerifyParamData} data
|
|
240
|
+
* @param {string} data.captchaVerifyParam 验证码参数
|
|
241
|
+
*/
|
|
242
|
+
var scgcGetCaptchaVerifyParam = function (data) {
|
|
243
|
+
return commonBridge('getCaptchaVerifyParam', data);
|
|
244
|
+
};
|
|
245
|
+
exports.scgcGetCaptchaVerifyParam = scgcGetCaptchaVerifyParam;
|
|
243
246
|
var utils_2 = require("./utils");
|
|
244
247
|
Object.defineProperty(exports, "setDevMode", { enumerable: true, get: function () { return utils_2.setDevMode; } });
|
|
245
248
|
Object.defineProperty(exports, "isScgcApp", { enumerable: true, get: function () { return utils_2.isScgcApp; } });
|
|
249
|
+
/**
|
|
250
|
+
* @description 打开原生综艺页面
|
|
251
|
+
* @param {IProgramData} data
|
|
252
|
+
* @param {string} data.programId 节目Id
|
|
253
|
+
* @param {string} data.groupId 合集Id
|
|
254
|
+
* @param {string} data.episodeId 单集Id
|
|
255
|
+
*/
|
|
256
|
+
var scgctoVarietyshow = function (data) {
|
|
257
|
+
return commonBridge('toVarietyshow', data);
|
|
258
|
+
};
|
|
259
|
+
exports.scgctoVarietyshow = scgctoVarietyshow;
|
|
260
|
+
/**
|
|
261
|
+
* @description 打开原生纪录片页面
|
|
262
|
+
* @param {IProgramData} data
|
|
263
|
+
* @param {string} data.programId 节目Id
|
|
264
|
+
* @param {string} data.groupId 合集Id
|
|
265
|
+
* @param {string} data.episodeId 单集Id
|
|
266
|
+
*/
|
|
267
|
+
var scgctoDocumentshow = function (data) {
|
|
268
|
+
return commonBridge('toDocumentary', data);
|
|
269
|
+
};
|
|
270
|
+
exports.scgctoDocumentshow = scgctoDocumentshow;
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export interface ICommonResult<T> {
|
|
|
2
2
|
success: boolean;
|
|
3
3
|
data: T;
|
|
4
4
|
}
|
|
5
|
-
type TSyncFuns =
|
|
6
|
-
type TAsyncFuns =
|
|
5
|
+
type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam' | 'toVarietyshow' | 'toDocumentary';
|
|
6
|
+
type TAsyncFuns = 'getToken' | 'getUserId' | 'getNickName' | 'getAvatar' | 'getPhoneNumber' | 'getPromise';
|
|
7
7
|
export declare const setDevMode: () => void;
|
|
8
8
|
export declare const initAsyncCallbackPool: () => void;
|
|
9
9
|
declare function androidBridgeFn(fnName: TSyncFuns, data?: Record<string, any>): void;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -40,27 +40,27 @@ exports.isScgcApp = exports.commonBridgeFun = exports.initAsyncCallbackPool = ex
|
|
|
40
40
|
var distinctionPlatform = function () {
|
|
41
41
|
var ua = navigator.userAgent;
|
|
42
42
|
if (/(iPhone|iPad|iPod)/i.test(ua)) {
|
|
43
|
-
return
|
|
43
|
+
return 'ios';
|
|
44
44
|
}
|
|
45
45
|
else if (/Android/i.test(ua)) {
|
|
46
|
-
return
|
|
46
|
+
return 'android';
|
|
47
47
|
}
|
|
48
48
|
else if (/openharmony/i.test(ua)) {
|
|
49
|
-
return
|
|
49
|
+
return 'harmony';
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
return
|
|
52
|
+
return 'unknow';
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
var asyncFunsArr = [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
'getToken',
|
|
57
|
+
'getUserId',
|
|
58
|
+
'getAvatar',
|
|
59
|
+
'getNickName',
|
|
60
|
+
'getPhoneNumber',
|
|
61
|
+
'getPromise', //测试用
|
|
62
62
|
];
|
|
63
|
-
var androidAsyncFunsArr = [
|
|
63
|
+
var androidAsyncFunsArr = ['getPromise'];
|
|
64
64
|
var devMode = false;
|
|
65
65
|
var setDevMode = function () {
|
|
66
66
|
devMode = true;
|
|
@@ -82,22 +82,22 @@ var devFn = function (platform, fnName, data) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
function makeRandomId(fnName) {
|
|
85
|
-
return "".concat(fnName ||
|
|
85
|
+
return "".concat(fnName || 'anonymous', "_").concat(Date.now());
|
|
86
86
|
}
|
|
87
87
|
function registerCallback(fnName, cb) {
|
|
88
88
|
if (!cb) {
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
var callbackId = makeRandomId(fnName);
|
|
92
|
-
if (!window.hasOwnProperty(
|
|
92
|
+
if (!window.hasOwnProperty('bridgeCallbacks')) {
|
|
93
93
|
window.bridgeCallbacks = {};
|
|
94
94
|
}
|
|
95
95
|
window.bridgeCallbacks[callbackId] = function (data) {
|
|
96
96
|
var result;
|
|
97
|
-
if (typeof data ===
|
|
97
|
+
if (typeof data === 'object') {
|
|
98
98
|
result = data;
|
|
99
99
|
}
|
|
100
|
-
else if (typeof data ===
|
|
100
|
+
else if (typeof data === 'string') {
|
|
101
101
|
try {
|
|
102
102
|
result = JSON.parse(data);
|
|
103
103
|
}
|
|
@@ -116,8 +116,8 @@ function androidBridgeFn(fnName, data) {
|
|
|
116
116
|
Method: fnName,
|
|
117
117
|
Data: data,
|
|
118
118
|
};
|
|
119
|
-
devFn(
|
|
120
|
-
if (fnName ==
|
|
119
|
+
devFn('android', fnName, data);
|
|
120
|
+
if (fnName == 'getSlideData') {
|
|
121
121
|
(_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));
|
|
122
122
|
}
|
|
123
123
|
else if (asyncFunsArr.includes(fnName)) {
|
|
@@ -135,10 +135,10 @@ function androidBridgeFn(fnName, data) {
|
|
|
135
135
|
else {
|
|
136
136
|
res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();
|
|
137
137
|
result = void 0;
|
|
138
|
-
if (typeof res ===
|
|
138
|
+
if (typeof res === 'object') {
|
|
139
139
|
result = res;
|
|
140
140
|
}
|
|
141
|
-
else if (typeof res ===
|
|
141
|
+
else if (typeof res === 'string') {
|
|
142
142
|
try {
|
|
143
143
|
result = JSON.parse(res);
|
|
144
144
|
}
|
|
@@ -169,7 +169,7 @@ function androidBridgeFn(fnName, data) {
|
|
|
169
169
|
function iosBridgeFn(fnName, data) {
|
|
170
170
|
var _this = this;
|
|
171
171
|
var _a, _b, _c;
|
|
172
|
-
devFn(
|
|
172
|
+
devFn('ios', fnName, data);
|
|
173
173
|
if (asyncFunsArr.includes(fnName)) {
|
|
174
174
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
175
175
|
var _a, _b, _c;
|
|
@@ -177,7 +177,7 @@ function iosBridgeFn(fnName, data) {
|
|
|
177
177
|
var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
178
178
|
return __generator(this, function (_a) {
|
|
179
179
|
try {
|
|
180
|
-
if ((res === null || res === void 0 ? void 0 : res.success) ==
|
|
180
|
+
if ((res === null || res === void 0 ? void 0 : res.success) == 'true') {
|
|
181
181
|
resolve({
|
|
182
182
|
success: true,
|
|
183
183
|
data: res === null || res === void 0 ? void 0 : res.data,
|
|
@@ -219,7 +219,7 @@ function iosBridgeFn(fnName, data) {
|
|
|
219
219
|
}
|
|
220
220
|
function harmonyBridgeFn(fnName, data) {
|
|
221
221
|
var _a, _b;
|
|
222
|
-
devFn(
|
|
222
|
+
devFn('harmony', fnName, data);
|
|
223
223
|
if (asyncFunsArr.includes(fnName)) {
|
|
224
224
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
225
225
|
var _a;
|
|
@@ -240,11 +240,11 @@ function harmonyBridgeFn(fnName, data) {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
function defaultBridgeFn(fnName, data) {
|
|
243
|
-
console.log(
|
|
243
|
+
console.log('请使用scgc app打开');
|
|
244
244
|
if (asyncFunsArr.includes(fnName)) {
|
|
245
245
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
246
246
|
try {
|
|
247
|
-
resolve(
|
|
247
|
+
resolve('请使用scgc app打开');
|
|
248
248
|
}
|
|
249
249
|
catch (error) {
|
|
250
250
|
reject(error);
|
|
@@ -255,13 +255,13 @@ function defaultBridgeFn(fnName, data) {
|
|
|
255
255
|
}
|
|
256
256
|
var commonBridgeFun = function () {
|
|
257
257
|
var platform = distinctionPlatform();
|
|
258
|
-
if (platform ==
|
|
258
|
+
if (platform == 'android') {
|
|
259
259
|
return androidBridgeFn;
|
|
260
260
|
}
|
|
261
|
-
else if (platform ==
|
|
261
|
+
else if (platform == 'ios') {
|
|
262
262
|
return iosBridgeFn;
|
|
263
263
|
}
|
|
264
|
-
else if (platform ==
|
|
264
|
+
else if (platform == 'harmony') {
|
|
265
265
|
return harmonyBridgeFn;
|
|
266
266
|
}
|
|
267
267
|
else {
|
|
@@ -274,6 +274,6 @@ exports.commonBridgeFun = commonBridgeFun;
|
|
|
274
274
|
* @return {boolean} true 是 false 否
|
|
275
275
|
*/
|
|
276
276
|
var isScgcApp = function () {
|
|
277
|
-
return navigator.userAgent.indexOf(
|
|
277
|
+
return navigator.userAgent.indexOf('SCGC_UA') > -1;
|
|
278
278
|
};
|
|
279
279
|
exports.isScgcApp = isScgcApp;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICommonResult } from
|
|
1
|
+
import { ICommonResult } from './utils';
|
|
2
2
|
export interface IGetSlideDataData {
|
|
3
3
|
token: string;
|
|
4
4
|
sessionId: string;
|
|
@@ -6,6 +6,8 @@ export interface IGetSlideDataData {
|
|
|
6
6
|
scene: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
+
* @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除
|
|
10
|
+
*
|
|
9
11
|
* @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
|
|
10
12
|
* @param {IGetSlideDataData} data
|
|
11
13
|
*/
|
|
@@ -144,7 +146,7 @@ export declare const scgcToSubSpecial: (data: IToSubSpecialData) => void;
|
|
|
144
146
|
export interface IMallDetailData {
|
|
145
147
|
json: string;
|
|
146
148
|
url: string;
|
|
147
|
-
ptype:
|
|
149
|
+
ptype: '0';
|
|
148
150
|
isDark: 0 | 1;
|
|
149
151
|
}
|
|
150
152
|
/**
|
|
@@ -207,4 +209,34 @@ export declare const scgcGetAvatar: () => Promise<ICommonResult<string>>;
|
|
|
207
209
|
*/
|
|
208
210
|
export declare const scgcGetNickName: () => Promise<ICommonResult<string>>;
|
|
209
211
|
export declare const scgcGetPhoneNumber: () => Promise<ICommonResult<string>>;
|
|
210
|
-
export
|
|
212
|
+
export interface IGetCaptchaVerifyParamData {
|
|
213
|
+
captchaVerifyParam: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @description 传递验证码参数到app(阿里验证码2.0使用)
|
|
217
|
+
* @param {IGetCaptchaVerifyParamData} data
|
|
218
|
+
* @param {string} data.captchaVerifyParam 验证码参数
|
|
219
|
+
*/
|
|
220
|
+
export declare const scgcGetCaptchaVerifyParam: (data: IGetCaptchaVerifyParamData) => void;
|
|
221
|
+
export { setDevMode, isScgcApp } from './utils';
|
|
222
|
+
export interface IProgramData {
|
|
223
|
+
programId: string;
|
|
224
|
+
groupId: string;
|
|
225
|
+
episodeId: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @description 打开原生综艺页面
|
|
229
|
+
* @param {IProgramData} data
|
|
230
|
+
* @param {string} data.programId 节目Id
|
|
231
|
+
* @param {string} data.groupId 合集Id
|
|
232
|
+
* @param {string} data.episodeId 单集Id
|
|
233
|
+
*/
|
|
234
|
+
export declare const scgctoVarietyshow: (data: IProgramData) => void;
|
|
235
|
+
/**
|
|
236
|
+
* @description 打开原生纪录片页面
|
|
237
|
+
* @param {IProgramData} data
|
|
238
|
+
* @param {string} data.programId 节目Id
|
|
239
|
+
* @param {string} data.groupId 合集Id
|
|
240
|
+
* @param {string} data.episodeId 单集Id
|
|
241
|
+
*/
|
|
242
|
+
export declare const scgctoDocumentshow: (data: IProgramData) => void;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
/*#__PURE__*/
|
|
2
|
-
import { commonBridgeFun, initAsyncCallbackPool } from
|
|
2
|
+
import { commonBridgeFun, initAsyncCallbackPool } from './utils';
|
|
3
3
|
initAsyncCallbackPool();
|
|
4
4
|
var commonBridge = commonBridgeFun();
|
|
5
5
|
/**
|
|
6
|
+
* @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除
|
|
7
|
+
*
|
|
6
8
|
* @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
|
|
7
9
|
* @param {IGetSlideDataData} data
|
|
8
10
|
*/
|
|
9
11
|
export var scgcGetSlideData = function (data) {
|
|
10
|
-
commonBridge(
|
|
12
|
+
commonBridge('getSlideData', data);
|
|
11
13
|
};
|
|
12
14
|
/**
|
|
13
15
|
* @description 调用app登录
|
|
14
16
|
*/
|
|
15
17
|
export var scgcLogin = function () {
|
|
16
|
-
commonBridge(
|
|
18
|
+
commonBridge('login');
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* @description 调用app扫码
|
|
20
22
|
*/
|
|
21
23
|
export var scgcScan = function () {
|
|
22
|
-
commonBridge(
|
|
24
|
+
commonBridge('scan');
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* @description 关闭当前webview
|
|
26
28
|
*/
|
|
27
29
|
export var scgcClose = function () {
|
|
28
|
-
commonBridge(
|
|
30
|
+
commonBridge('close');
|
|
29
31
|
};
|
|
30
32
|
/**
|
|
31
33
|
* @description 使用系统浏览器打开指定的url
|
|
@@ -33,7 +35,7 @@ export var scgcClose = function () {
|
|
|
33
35
|
* @param {string} data.path 需要打开的url
|
|
34
36
|
*/
|
|
35
37
|
export var scgcOpenexplorer = function (data) {
|
|
36
|
-
commonBridge(
|
|
38
|
+
commonBridge('openexplorer', data);
|
|
37
39
|
};
|
|
38
40
|
/**
|
|
39
41
|
* @description 打开微信小程序
|
|
@@ -42,7 +44,7 @@ export var scgcOpenexplorer = function (data) {
|
|
|
42
44
|
* @param {string} data.path 小程序路径
|
|
43
45
|
*/
|
|
44
46
|
export var scgcOpenwechat = function (data) {
|
|
45
|
-
commonBridge(
|
|
47
|
+
commonBridge('openwechat', data);
|
|
46
48
|
};
|
|
47
49
|
/**
|
|
48
50
|
* @description 保存图片
|
|
@@ -50,7 +52,7 @@ export var scgcOpenwechat = function (data) {
|
|
|
50
52
|
* @param {string} data.data base64数据
|
|
51
53
|
*/
|
|
52
54
|
export var scgcSaveimage = function (data) {
|
|
53
|
-
commonBridge(
|
|
55
|
+
commonBridge('saveimage', data);
|
|
54
56
|
};
|
|
55
57
|
/**
|
|
56
58
|
* @description 配置app分享
|
|
@@ -62,7 +64,7 @@ export var scgcSaveimage = function (data) {
|
|
|
62
64
|
* @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置
|
|
63
65
|
*/
|
|
64
66
|
export var scgcShare = function (data) {
|
|
65
|
-
commonBridge(
|
|
67
|
+
commonBridge('share', data);
|
|
66
68
|
};
|
|
67
69
|
/**
|
|
68
70
|
* @description 打开一个webview
|
|
@@ -70,7 +72,7 @@ export var scgcShare = function (data) {
|
|
|
70
72
|
* @param {string} data.path 需要打开的url
|
|
71
73
|
*/
|
|
72
74
|
export var scgcToH5 = function (data) {
|
|
73
|
-
commonBridge(
|
|
75
|
+
commonBridge('toH5', data);
|
|
74
76
|
};
|
|
75
77
|
/**
|
|
76
78
|
* @description 打开app原生新闻页
|
|
@@ -79,7 +81,7 @@ export var scgcToH5 = function (data) {
|
|
|
79
81
|
* @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链
|
|
80
82
|
*/
|
|
81
83
|
export var scgcToDetail = function (data) {
|
|
82
|
-
commonBridge(
|
|
84
|
+
commonBridge('toDetail', data);
|
|
83
85
|
};
|
|
84
86
|
/**
|
|
85
87
|
* @description 打开app原生专题详情页
|
|
@@ -87,7 +89,7 @@ export var scgcToDetail = function (data) {
|
|
|
87
89
|
* @param {string} data.id 专题id
|
|
88
90
|
*/
|
|
89
91
|
export var scgcToSpecial = function (data) {
|
|
90
|
-
commonBridge(
|
|
92
|
+
commonBridge('toSpecial', data);
|
|
91
93
|
};
|
|
92
94
|
/**
|
|
93
95
|
* @description 打开app原生直播页
|
|
@@ -96,7 +98,7 @@ export var scgcToSpecial = function (data) {
|
|
|
96
98
|
* @param {string} data.type 直播样式 1 横版 2 竖版
|
|
97
99
|
*/
|
|
98
100
|
export var scgcToLive = function (data) {
|
|
99
|
-
commonBridge(
|
|
101
|
+
commonBridge('toLive', data);
|
|
100
102
|
};
|
|
101
103
|
/**
|
|
102
104
|
* @description 打开app话题页
|
|
@@ -106,7 +108,7 @@ export var scgcToLive = function (data) {
|
|
|
106
108
|
* @param {string} data.id 话题id
|
|
107
109
|
*/
|
|
108
110
|
export var scgcToTopic = function (data) {
|
|
109
|
-
commonBridge(
|
|
111
|
+
commonBridge('toTopic', data);
|
|
110
112
|
};
|
|
111
113
|
/**
|
|
112
114
|
* @description 设置app音量
|
|
@@ -114,7 +116,7 @@ export var scgcToTopic = function (data) {
|
|
|
114
116
|
* @param {number} data.type 0 调小 1 调大
|
|
115
117
|
*/
|
|
116
118
|
export var scgcSetVolume = function (data) {
|
|
117
|
-
commonBridge(
|
|
119
|
+
commonBridge('setVolume', data);
|
|
118
120
|
};
|
|
119
121
|
/**
|
|
120
122
|
* @description 打开app原生专题新闻列表页
|
|
@@ -123,7 +125,7 @@ export var scgcSetVolume = function (data) {
|
|
|
123
125
|
* @param {string} data.id 专题id
|
|
124
126
|
*/
|
|
125
127
|
export var scgcToSubSpecial = function (data) {
|
|
126
|
-
commonBridge(
|
|
128
|
+
commonBridge('toSubSpecial', data);
|
|
127
129
|
};
|
|
128
130
|
/**
|
|
129
131
|
* @description 打开积分商城商品详情
|
|
@@ -134,7 +136,7 @@ export var scgcToSubSpecial = function (data) {
|
|
|
134
136
|
* @param {number} data.isDark 0 普通模式 1 黑暗模式
|
|
135
137
|
*/
|
|
136
138
|
export var scgcToMallDetail = function (data) {
|
|
137
|
-
commonBridge(
|
|
139
|
+
commonBridge('detailJson', data);
|
|
138
140
|
};
|
|
139
141
|
/**
|
|
140
142
|
* @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)
|
|
@@ -143,25 +145,25 @@ export var scgcToMallDetail = function (data) {
|
|
|
143
145
|
*
|
|
144
146
|
*/
|
|
145
147
|
export var scgcFocusWeb = function (data) {
|
|
146
|
-
commonBridge(
|
|
148
|
+
commonBridge('focusWeb', data);
|
|
147
149
|
};
|
|
148
150
|
/**
|
|
149
151
|
* @description 跳转至积分商城
|
|
150
152
|
*/
|
|
151
153
|
export var scgcToMall = function () {
|
|
152
|
-
commonBridge(
|
|
154
|
+
commonBridge('mall');
|
|
153
155
|
};
|
|
154
156
|
/**
|
|
155
157
|
* @description 跳转至快拍
|
|
156
158
|
*/
|
|
157
159
|
export var scgcToKuaipai = function () {
|
|
158
|
-
commonBridge(
|
|
160
|
+
commonBridge('release');
|
|
159
161
|
};
|
|
160
162
|
/**
|
|
161
163
|
* @description 跳转至app首页
|
|
162
164
|
*/
|
|
163
165
|
export var scgcToAppHome = function () {
|
|
164
|
-
commonBridge(
|
|
166
|
+
commonBridge('mainPage');
|
|
165
167
|
};
|
|
166
168
|
/**
|
|
167
169
|
* @description 设置app顶部时间栏颜色
|
|
@@ -170,7 +172,7 @@ export var scgcToAppHome = function () {
|
|
|
170
172
|
*
|
|
171
173
|
*/
|
|
172
174
|
export var scgcChangeStateBarColor = function (data) {
|
|
173
|
-
commonBridge(
|
|
175
|
+
commonBridge('changeStatebarColor', data);
|
|
174
176
|
};
|
|
175
177
|
/**
|
|
176
178
|
* @description 获取app 用户id
|
|
@@ -178,7 +180,7 @@ export var scgcChangeStateBarColor = function (data) {
|
|
|
178
180
|
*
|
|
179
181
|
*/
|
|
180
182
|
export var scgcGetUserId = function () {
|
|
181
|
-
return commonBridge(
|
|
183
|
+
return commonBridge('getUserId');
|
|
182
184
|
};
|
|
183
185
|
/**
|
|
184
186
|
* @description 获取app 用户头像
|
|
@@ -186,7 +188,7 @@ export var scgcGetUserId = function () {
|
|
|
186
188
|
*
|
|
187
189
|
*/
|
|
188
190
|
export var scgcGetAvatar = function () {
|
|
189
|
-
return commonBridge(
|
|
191
|
+
return commonBridge('getAvatar');
|
|
190
192
|
};
|
|
191
193
|
/**
|
|
192
194
|
* @description 获取app 用户昵称
|
|
@@ -194,7 +196,7 @@ export var scgcGetAvatar = function () {
|
|
|
194
196
|
*
|
|
195
197
|
*/
|
|
196
198
|
export var scgcGetNickName = function () {
|
|
197
|
-
return commonBridge(
|
|
199
|
+
return commonBridge('getNickName');
|
|
198
200
|
};
|
|
199
201
|
// /**
|
|
200
202
|
// * @description 获取app 用户手机号
|
|
@@ -202,14 +204,34 @@ export var scgcGetNickName = function () {
|
|
|
202
204
|
// *
|
|
203
205
|
// */
|
|
204
206
|
export var scgcGetPhoneNumber = function () {
|
|
205
|
-
return commonBridge(
|
|
207
|
+
return commonBridge('getPhoneNumber');
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* @description 传递验证码参数到app(阿里验证码2.0使用)
|
|
211
|
+
* @param {IGetCaptchaVerifyParamData} data
|
|
212
|
+
* @param {string} data.captchaVerifyParam 验证码参数
|
|
213
|
+
*/
|
|
214
|
+
export var scgcGetCaptchaVerifyParam = function (data) {
|
|
215
|
+
return commonBridge('getCaptchaVerifyParam', data);
|
|
216
|
+
};
|
|
217
|
+
export { setDevMode, isScgcApp } from './utils';
|
|
218
|
+
/**
|
|
219
|
+
* @description 打开原生综艺页面
|
|
220
|
+
* @param {IProgramData} data
|
|
221
|
+
* @param {string} data.programId 节目Id
|
|
222
|
+
* @param {string} data.groupId 合集Id
|
|
223
|
+
* @param {string} data.episodeId 单集Id
|
|
224
|
+
*/
|
|
225
|
+
export var scgctoVarietyshow = function (data) {
|
|
226
|
+
return commonBridge('toVarietyshow', data);
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* @description 打开原生纪录片页面
|
|
230
|
+
* @param {IProgramData} data
|
|
231
|
+
* @param {string} data.programId 节目Id
|
|
232
|
+
* @param {string} data.groupId 合集Id
|
|
233
|
+
* @param {string} data.episodeId 单集Id
|
|
234
|
+
*/
|
|
235
|
+
export var scgctoDocumentshow = function (data) {
|
|
236
|
+
return commonBridge('toDocumentary', data);
|
|
206
237
|
};
|
|
207
|
-
// /**
|
|
208
|
-
// * @description 获取app token --暂不可用
|
|
209
|
-
// * @return {Promise((success:boolean,data:string))} 返回promise,暂时不会有进catch的情况
|
|
210
|
-
// *
|
|
211
|
-
// */
|
|
212
|
-
// export const scgcGetToken = () => {
|
|
213
|
-
// return commonBridge("getToken");
|
|
214
|
-
// };
|
|
215
|
-
export { setDevMode, isScgcApp } from "./utils";
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ export interface ICommonResult<T> {
|
|
|
2
2
|
success: boolean;
|
|
3
3
|
data: T;
|
|
4
4
|
}
|
|
5
|
-
type TSyncFuns =
|
|
6
|
-
type TAsyncFuns =
|
|
5
|
+
type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam' | 'toVarietyshow' | 'toDocumentary';
|
|
6
|
+
type TAsyncFuns = 'getToken' | 'getUserId' | 'getNickName' | 'getAvatar' | 'getPhoneNumber' | 'getPromise';
|
|
7
7
|
export declare const setDevMode: () => void;
|
|
8
8
|
export declare const initAsyncCallbackPool: () => void;
|
|
9
9
|
declare function androidBridgeFn(fnName: TSyncFuns, data?: Record<string, any>): void;
|
package/dist/esm/utils.js
CHANGED
|
@@ -37,27 +37,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
var distinctionPlatform = function () {
|
|
38
38
|
var ua = navigator.userAgent;
|
|
39
39
|
if (/(iPhone|iPad|iPod)/i.test(ua)) {
|
|
40
|
-
return
|
|
40
|
+
return 'ios';
|
|
41
41
|
}
|
|
42
42
|
else if (/Android/i.test(ua)) {
|
|
43
|
-
return
|
|
43
|
+
return 'android';
|
|
44
44
|
}
|
|
45
45
|
else if (/openharmony/i.test(ua)) {
|
|
46
|
-
return
|
|
46
|
+
return 'harmony';
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
return
|
|
49
|
+
return 'unknow';
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
var asyncFunsArr = [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
'getToken',
|
|
54
|
+
'getUserId',
|
|
55
|
+
'getAvatar',
|
|
56
|
+
'getNickName',
|
|
57
|
+
'getPhoneNumber',
|
|
58
|
+
'getPromise', //测试用
|
|
59
59
|
];
|
|
60
|
-
var androidAsyncFunsArr = [
|
|
60
|
+
var androidAsyncFunsArr = ['getPromise'];
|
|
61
61
|
var devMode = false;
|
|
62
62
|
export var setDevMode = function () {
|
|
63
63
|
devMode = true;
|
|
@@ -77,22 +77,22 @@ var devFn = function (platform, fnName, data) {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
function makeRandomId(fnName) {
|
|
80
|
-
return "".concat(fnName ||
|
|
80
|
+
return "".concat(fnName || 'anonymous', "_").concat(Date.now());
|
|
81
81
|
}
|
|
82
82
|
function registerCallback(fnName, cb) {
|
|
83
83
|
if (!cb) {
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
86
|
var callbackId = makeRandomId(fnName);
|
|
87
|
-
if (!window.hasOwnProperty(
|
|
87
|
+
if (!window.hasOwnProperty('bridgeCallbacks')) {
|
|
88
88
|
window.bridgeCallbacks = {};
|
|
89
89
|
}
|
|
90
90
|
window.bridgeCallbacks[callbackId] = function (data) {
|
|
91
91
|
var result;
|
|
92
|
-
if (typeof data ===
|
|
92
|
+
if (typeof data === 'object') {
|
|
93
93
|
result = data;
|
|
94
94
|
}
|
|
95
|
-
else if (typeof data ===
|
|
95
|
+
else if (typeof data === 'string') {
|
|
96
96
|
try {
|
|
97
97
|
result = JSON.parse(data);
|
|
98
98
|
}
|
|
@@ -111,8 +111,8 @@ function androidBridgeFn(fnName, data) {
|
|
|
111
111
|
Method: fnName,
|
|
112
112
|
Data: data,
|
|
113
113
|
};
|
|
114
|
-
devFn(
|
|
115
|
-
if (fnName ==
|
|
114
|
+
devFn('android', fnName, data);
|
|
115
|
+
if (fnName == 'getSlideData') {
|
|
116
116
|
(_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));
|
|
117
117
|
}
|
|
118
118
|
else if (asyncFunsArr.includes(fnName)) {
|
|
@@ -130,10 +130,10 @@ function androidBridgeFn(fnName, data) {
|
|
|
130
130
|
else {
|
|
131
131
|
res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();
|
|
132
132
|
result = void 0;
|
|
133
|
-
if (typeof res ===
|
|
133
|
+
if (typeof res === 'object') {
|
|
134
134
|
result = res;
|
|
135
135
|
}
|
|
136
|
-
else if (typeof res ===
|
|
136
|
+
else if (typeof res === 'string') {
|
|
137
137
|
try {
|
|
138
138
|
result = JSON.parse(res);
|
|
139
139
|
}
|
|
@@ -164,7 +164,7 @@ function androidBridgeFn(fnName, data) {
|
|
|
164
164
|
function iosBridgeFn(fnName, data) {
|
|
165
165
|
var _this = this;
|
|
166
166
|
var _a, _b, _c;
|
|
167
|
-
devFn(
|
|
167
|
+
devFn('ios', fnName, data);
|
|
168
168
|
if (asyncFunsArr.includes(fnName)) {
|
|
169
169
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
170
170
|
var _a, _b, _c;
|
|
@@ -172,7 +172,7 @@ function iosBridgeFn(fnName, data) {
|
|
|
172
172
|
var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
173
|
return __generator(this, function (_a) {
|
|
174
174
|
try {
|
|
175
|
-
if ((res === null || res === void 0 ? void 0 : res.success) ==
|
|
175
|
+
if ((res === null || res === void 0 ? void 0 : res.success) == 'true') {
|
|
176
176
|
resolve({
|
|
177
177
|
success: true,
|
|
178
178
|
data: res === null || res === void 0 ? void 0 : res.data,
|
|
@@ -214,7 +214,7 @@ function iosBridgeFn(fnName, data) {
|
|
|
214
214
|
}
|
|
215
215
|
function harmonyBridgeFn(fnName, data) {
|
|
216
216
|
var _a, _b;
|
|
217
|
-
devFn(
|
|
217
|
+
devFn('harmony', fnName, data);
|
|
218
218
|
if (asyncFunsArr.includes(fnName)) {
|
|
219
219
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
220
220
|
var _a;
|
|
@@ -235,11 +235,11 @@ function harmonyBridgeFn(fnName, data) {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
function defaultBridgeFn(fnName, data) {
|
|
238
|
-
console.log(
|
|
238
|
+
console.log('请使用scgc app打开');
|
|
239
239
|
if (asyncFunsArr.includes(fnName)) {
|
|
240
240
|
var promiseRes = new Promise(function (resolve, reject) {
|
|
241
241
|
try {
|
|
242
|
-
resolve(
|
|
242
|
+
resolve('请使用scgc app打开');
|
|
243
243
|
}
|
|
244
244
|
catch (error) {
|
|
245
245
|
reject(error);
|
|
@@ -250,13 +250,13 @@ function defaultBridgeFn(fnName, data) {
|
|
|
250
250
|
}
|
|
251
251
|
export var commonBridgeFun = function () {
|
|
252
252
|
var platform = distinctionPlatform();
|
|
253
|
-
if (platform ==
|
|
253
|
+
if (platform == 'android') {
|
|
254
254
|
return androidBridgeFn;
|
|
255
255
|
}
|
|
256
|
-
else if (platform ==
|
|
256
|
+
else if (platform == 'ios') {
|
|
257
257
|
return iosBridgeFn;
|
|
258
258
|
}
|
|
259
|
-
else if (platform ==
|
|
259
|
+
else if (platform == 'harmony') {
|
|
260
260
|
return harmonyBridgeFn;
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
@@ -268,5 +268,5 @@ export var commonBridgeFun = function () {
|
|
|
268
268
|
* @return {boolean} true 是 false 否
|
|
269
269
|
*/
|
|
270
270
|
export var isScgcApp = function () {
|
|
271
|
-
return navigator.userAgent.indexOf(
|
|
271
|
+
return navigator.userAgent.indexOf('SCGC_UA') > -1;
|
|
272
272
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.scgcBridge=e():n.scgcBridge=e()}(self,()=>(()=>{"use strict";var __webpack_modules__={"./src/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isScgcApp: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.isScgcApp),\n/* harmony export */ scgcChangeStateBarColor: () => (/* binding */ scgcChangeStateBarColor),\n/* harmony export */ scgcClose: () => (/* binding */ scgcClose),\n/* harmony export */ scgcFocusWeb: () => (/* binding */ scgcFocusWeb),\n/* harmony export */ scgcGetAvatar: () => (/* binding */ scgcGetAvatar),\n/* harmony export */ scgcGetNickName: () => (/* binding */ scgcGetNickName),\n/* harmony export */ scgcGetPhoneNumber: () => (/* binding */ scgcGetPhoneNumber),\n/* harmony export */ scgcGetSlideData: () => (/* binding */ scgcGetSlideData),\n/* harmony export */ scgcGetUserId: () => (/* binding */ scgcGetUserId),\n/* harmony export */ scgcLogin: () => (/* binding */ scgcLogin),\n/* harmony export */ scgcOpenexplorer: () => (/* binding */ scgcOpenexplorer),\n/* harmony export */ scgcOpenwechat: () => (/* binding */ scgcOpenwechat),\n/* harmony export */ scgcSaveimage: () => (/* binding */ scgcSaveimage),\n/* harmony export */ scgcScan: () => (/* binding */ scgcScan),\n/* harmony export */ scgcSetVolume: () => (/* binding */ scgcSetVolume),\n/* harmony export */ scgcShare: () => (/* binding */ scgcShare),\n/* harmony export */ scgcToAppHome: () => (/* binding */ scgcToAppHome),\n/* harmony export */ scgcToDetail: () => (/* binding */ scgcToDetail),\n/* harmony export */ scgcToH5: () => (/* binding */ scgcToH5),\n/* harmony export */ scgcToKuaipai: () => (/* binding */ scgcToKuaipai),\n/* harmony export */ scgcToLive: () => (/* binding */ scgcToLive),\n/* harmony export */ scgcToMall: () => (/* binding */ scgcToMall),\n/* harmony export */ scgcToMallDetail: () => (/* binding */ scgcToMallDetail),\n/* harmony export */ scgcToSpecial: () => (/* binding */ scgcToSpecial),\n/* harmony export */ scgcToSubSpecial: () => (/* binding */ scgcToSubSpecial),\n/* harmony export */ scgcToTopic: () => (/* binding */ scgcToTopic),\n/* harmony export */ setDevMode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.setDevMode)\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ "./src/utils.ts");\n/*#__PURE__*/\n\n(0,_utils__WEBPACK_IMPORTED_MODULE_0__.initAsyncCallbackPool)();\nvar commonBridge = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.commonBridgeFun)();\n/**\n * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)\n * @param {IGetSlideDataData} data\n */\nvar scgcGetSlideData = function (data) {\n commonBridge("getSlideData", data);\n};\n/**\n * @description 调用app登录\n */\nvar scgcLogin = function () {\n commonBridge("login");\n};\n/**\n * @description 调用app扫码\n */\nvar scgcScan = function () {\n commonBridge("scan");\n};\n/**\n * @description 关闭当前webview\n */\nvar scgcClose = function () {\n commonBridge("close");\n};\n/**\n * @description 使用系统浏览器打开指定的url\n * @param {IOpenexplorerData} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcOpenexplorer = function (data) {\n commonBridge("openexplorer", data);\n};\n/**\n * @description 打开微信小程序\n * @param {IOpenwechatData} data\n * @param {string} data.appid 小程序appid,格式为gh开头\n * @param {string} data.path 小程序路径\n */\nvar scgcOpenwechat = function (data) {\n commonBridge("openwechat", data);\n};\n/**\n * @description 保存图片\n * @param {ISaveimageData} data\n * @param {string} data.data base64数据\n */\nvar scgcSaveimage = function (data) {\n commonBridge("saveimage", data);\n};\n/**\n * @description 配置app分享\n * @param {IShareData} data\n * @param {string} data.shareUrl 需要分享的地址\n * @param {string} data.shareImg 分享的封面\n * @param {string} data.shareTitle 分享的标题\n * @param {string} data.shareDesc 分享的说明\n * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置\n */\nvar scgcShare = function (data) {\n commonBridge("share", data);\n};\n/**\n * @description 打开一个webview\n * @param {ItoH5Data} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcToH5 = function (data) {\n commonBridge("toH5", data);\n};\n/**\n * @description 打开app原生新闻页\n * @param {IToDetailData} data\n * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式\n * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链\n */\nvar scgcToDetail = function (data) {\n commonBridge("toDetail", data);\n};\n/**\n * @description 打开app原生专题详情页\n * @param {IToSpecialData} data\n * @param {string} data.id 专题id\n */\nvar scgcToSpecial = function (data) {\n commonBridge("toSpecial", data);\n};\n/**\n * @description 打开app原生直播页\n * @param {IToLiveData} data\n * @param {string} data.id 直播id\n * @param {string} data.type 直播样式 1 横版 2 竖版\n */\nvar scgcToLive = function (data) {\n commonBridge("toLive", data);\n};\n/**\n * @description 打开app话题页\n * @param {IToTopicData} data\n * @param {string} data.name 话题名称\n * @param {string} data.cover 话题封面图(完整的图片地址)\n * @param {string} data.id 话题id\n */\nvar scgcToTopic = function (data) {\n commonBridge("toTopic", data);\n};\n/**\n * @description 设置app音量\n * @param {ISetVolumeData} data\n * @param {number} data.type 0 调小 1 调大\n */\nvar scgcSetVolume = function (data) {\n commonBridge("setVolume", data);\n};\n/**\n * @description 打开app原生专题新闻列表页\n * @param {IToSubSpecialData} data\n * @param {string} data.title 专题标题\n * @param {string} data.id 专题id\n */\nvar scgcToSubSpecial = function (data) {\n commonBridge("toSubSpecial", data);\n};\n/**\n * @description 打开积分商城商品详情\n * @param {IMallDetailData} data\n * @param {string} data.json 商品详情json地址\n * @param {string} data.url 商品详情网页地址\n * @param {string} data.ptype todo 未知\n * @param {number} data.isDark 0 普通模式 1 黑暗模式\n */\nvar scgcToMallDetail = function (data) {\n commonBridge("detailJson", data);\n};\n/**\n * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)\n * @param {IMallDetailData} data\n * @param {boolean} data.focus 是否禁止app滑动\n *\n */\nvar scgcFocusWeb = function (data) {\n commonBridge("focusWeb", data);\n};\n/**\n * @description 跳转至积分商城\n */\nvar scgcToMall = function () {\n commonBridge("mall");\n};\n/**\n * @description 跳转至快拍\n */\nvar scgcToKuaipai = function () {\n commonBridge("release");\n};\n/**\n * @description 跳转至app首页\n */\nvar scgcToAppHome = function () {\n commonBridge("mainPage");\n};\n/**\n * @description 设置app顶部时间栏颜色\n * @param {IChangeStateBarColorData} data\n * @param {number} data.type 1 黑色 2 白色\n *\n */\nvar scgcChangeStateBarColor = function (data) {\n commonBridge("changeStatebarColor", data);\n};\n/**\n * @description 获取app 用户id\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetUserId = function () {\n return commonBridge("getUserId");\n};\n/**\n * @description 获取app 用户头像\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetAvatar = function () {\n return commonBridge("getAvatar");\n};\n/**\n * @description 获取app 用户昵称\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetNickName = function () {\n return commonBridge("getNickName");\n};\n// /**\n// * @description 获取app 用户手机号\n// * @return {Promise((success:boolean,data:string))} 返回promise\n// *\n// */\nvar scgcGetPhoneNumber = function () {\n return commonBridge("getPhoneNumber");\n};\n// /**\n// * @description 获取app token --暂不可用\n// * @return {Promise((success:boolean,data:string))} 返回promise,暂时不会有进catch的情况\n// *\n// */\n// export const scgcGetToken = () => {\n// return commonBridge("getToken");\n// };\n\n\n\n//# sourceURL=webpack://scgcBridge/./src/index.ts?\n}')},"./src/utils.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval('{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ commonBridgeFun: () => (/* binding */ commonBridgeFun),\n/* harmony export */ initAsyncCallbackPool: () => (/* binding */ initAsyncCallbackPool),\n/* harmony export */ isScgcApp: () => (/* binding */ isScgcApp),\n/* harmony export */ setDevMode: () => (/* binding */ setDevMode)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);\n return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError("Generator is already executing.");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar distinctionPlatform = function () {\n var ua = navigator.userAgent;\n if (/(iPhone|iPad|iPod)/i.test(ua)) {\n return "ios";\n }\n else if (/Android/i.test(ua)) {\n return "android";\n }\n else if (/openharmony/i.test(ua)) {\n return "harmony";\n }\n else {\n return "unknow";\n }\n};\nvar asyncFunsArr = [\n "getToken",\n "getUserId",\n "getAvatar",\n "getNickName",\n "getPhoneNumber",\n "getPromise", //测试用\n];\nvar androidAsyncFunsArr = ["getPromise"];\nvar devMode = false;\nvar setDevMode = function () {\n devMode = true;\n};\nvar initAsyncCallbackPool = function () {\n window.bridgeCallbacks = {};\n};\nvar devFn = function (platform, fnName, data) {\n //动态判断是否为devMode,避免初始化commonBridgeFun比调用setDevMode的早的情况下,devMode参数已固定(损失的性能可以接受)\n if (devMode) {\n var devInfo = {\n platform: platform,\n fnName: fnName,\n data: data,\n };\n console.log(devInfo);\n }\n};\nfunction makeRandomId(fnName) {\n return "".concat(fnName || "anonymous", "_").concat(Date.now());\n}\nfunction registerCallback(fnName, cb) {\n if (!cb) {\n return null;\n }\n var callbackId = makeRandomId(fnName);\n if (!window.hasOwnProperty("bridgeCallbacks")) {\n window.bridgeCallbacks = {};\n }\n window.bridgeCallbacks[callbackId] = function (data) {\n var result;\n if (typeof data === "object") {\n result = data;\n }\n else if (typeof data === "string") {\n try {\n result = JSON.parse(data);\n }\n catch (e) {\n result = data;\n }\n }\n cb(result);\n };\n return "bridgeCallbacks.".concat(callbackId);\n}\nfunction androidBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b;\n var androidParams = {\n Method: fnName,\n Data: data,\n };\n devFn("android", fnName, data);\n if (fnName == "getSlideData") {\n (_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));\n }\n else if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {\n var res, result;\n var _a, _b;\n return __generator(this, function (_c) {\n try {\n //安卓使用了异步返回\n if (androidAsyncFunsArr.includes(fnName)) {\n (_a = window === null || window === void 0 ? void 0 : window.newBridge) === null || _a === void 0 ? void 0 : _a[fnName](JSON.stringify({\n callback: registerCallback(fnName, resolve),\n }));\n }\n else {\n res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();\n result = void 0;\n if (typeof res === "object") {\n result = res;\n }\n else if (typeof res === "string") {\n try {\n result = JSON.parse(res);\n }\n catch (e) {\n result = { success: false, data: res };\n }\n }\n if ((result === null || result === void 0 ? void 0 : result.success) == true) {\n resolve(result);\n }\n else {\n reject(result);\n }\n }\n }\n catch (error) {\n reject(error);\n }\n return [2 /*return*/];\n });\n }); });\n return promiseRes;\n }\n else {\n (_b = window === null || window === void 0 ? void 0 : window.bridge) === null || _b === void 0 ? void 0 : _b.callRouter(JSON.stringify(androidParams), function () { });\n }\n}\nfunction iosBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b, _c;\n devFn("ios", fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a, _b, _c;\n try {\n var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n try {\n if ((res === null || res === void 0 ? void 0 : res.success) == "true") {\n resolve({\n success: true,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n else {\n reject({\n success: false,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n return [2 /*return*/];\n });\n }); };\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage({\n data: {},\n callback: registerCallback(fnName, _cb),\n });\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n });\n return promiseRes;\n }\n else {\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage(data);\n }\n}\nfunction harmonyBridgeFn(fnName, data) {\n var _a, _b;\n devFn("harmony", fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a;\n try {\n (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]({\n data: data,\n callback: registerCallback(fnName, resolve),\n });\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n else {\n (_b = (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, data);\n }\n}\nfunction defaultBridgeFn(fnName, data) {\n console.log("请使用scgc app打开");\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n try {\n resolve("请使用scgc app打开");\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n}\nvar commonBridgeFun = function () {\n var platform = distinctionPlatform();\n if (platform == "android") {\n return androidBridgeFn;\n }\n else if (platform == "ios") {\n return iosBridgeFn;\n }\n else if (platform == "harmony") {\n return harmonyBridgeFn;\n }\n else {\n return defaultBridgeFn;\n }\n};\n/**\n * @description 是否为app环境\n * @return {boolean} true 是 false 否\n */\nvar isScgcApp = function () {\n return navigator.userAgent.indexOf("SCGC_UA") > -1;\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/utils.ts?\n}')}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var a=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(n,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),__webpack_require__.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__("./src/index.ts");return __webpack_exports__})());
|
|
1
|
+
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.scgcBridge=e():n.scgcBridge=e()}(self,()=>(()=>{"use strict";var __webpack_modules__={"./src/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isScgcApp: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.isScgcApp),\n/* harmony export */ scgcChangeStateBarColor: () => (/* binding */ scgcChangeStateBarColor),\n/* harmony export */ scgcClose: () => (/* binding */ scgcClose),\n/* harmony export */ scgcFocusWeb: () => (/* binding */ scgcFocusWeb),\n/* harmony export */ scgcGetAvatar: () => (/* binding */ scgcGetAvatar),\n/* harmony export */ scgcGetCaptchaVerifyParam: () => (/* binding */ scgcGetCaptchaVerifyParam),\n/* harmony export */ scgcGetNickName: () => (/* binding */ scgcGetNickName),\n/* harmony export */ scgcGetPhoneNumber: () => (/* binding */ scgcGetPhoneNumber),\n/* harmony export */ scgcGetSlideData: () => (/* binding */ scgcGetSlideData),\n/* harmony export */ scgcGetUserId: () => (/* binding */ scgcGetUserId),\n/* harmony export */ scgcLogin: () => (/* binding */ scgcLogin),\n/* harmony export */ scgcOpenexplorer: () => (/* binding */ scgcOpenexplorer),\n/* harmony export */ scgcOpenwechat: () => (/* binding */ scgcOpenwechat),\n/* harmony export */ scgcSaveimage: () => (/* binding */ scgcSaveimage),\n/* harmony export */ scgcScan: () => (/* binding */ scgcScan),\n/* harmony export */ scgcSetVolume: () => (/* binding */ scgcSetVolume),\n/* harmony export */ scgcShare: () => (/* binding */ scgcShare),\n/* harmony export */ scgcToAppHome: () => (/* binding */ scgcToAppHome),\n/* harmony export */ scgcToDetail: () => (/* binding */ scgcToDetail),\n/* harmony export */ scgcToH5: () => (/* binding */ scgcToH5),\n/* harmony export */ scgcToKuaipai: () => (/* binding */ scgcToKuaipai),\n/* harmony export */ scgcToLive: () => (/* binding */ scgcToLive),\n/* harmony export */ scgcToMall: () => (/* binding */ scgcToMall),\n/* harmony export */ scgcToMallDetail: () => (/* binding */ scgcToMallDetail),\n/* harmony export */ scgcToSpecial: () => (/* binding */ scgcToSpecial),\n/* harmony export */ scgcToSubSpecial: () => (/* binding */ scgcToSubSpecial),\n/* harmony export */ scgcToTopic: () => (/* binding */ scgcToTopic),\n/* harmony export */ scgctoDocumentshow: () => (/* binding */ scgctoDocumentshow),\n/* harmony export */ scgctoVarietyshow: () => (/* binding */ scgctoVarietyshow),\n/* harmony export */ setDevMode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.setDevMode)\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.ts\");\n/*#__PURE__*/\n\n(0,_utils__WEBPACK_IMPORTED_MODULE_0__.initAsyncCallbackPool)();\nvar commonBridge = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.commonBridgeFun)();\n/**\n * @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除\n *\n * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)\n * @param {IGetSlideDataData} data\n */\nvar scgcGetSlideData = function (data) {\n commonBridge('getSlideData', data);\n};\n/**\n * @description 调用app登录\n */\nvar scgcLogin = function () {\n commonBridge('login');\n};\n/**\n * @description 调用app扫码\n */\nvar scgcScan = function () {\n commonBridge('scan');\n};\n/**\n * @description 关闭当前webview\n */\nvar scgcClose = function () {\n commonBridge('close');\n};\n/**\n * @description 使用系统浏览器打开指定的url\n * @param {IOpenexplorerData} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcOpenexplorer = function (data) {\n commonBridge('openexplorer', data);\n};\n/**\n * @description 打开微信小程序\n * @param {IOpenwechatData} data\n * @param {string} data.appid 小程序appid,格式为gh开头\n * @param {string} data.path 小程序路径\n */\nvar scgcOpenwechat = function (data) {\n commonBridge('openwechat', data);\n};\n/**\n * @description 保存图片\n * @param {ISaveimageData} data\n * @param {string} data.data base64数据\n */\nvar scgcSaveimage = function (data) {\n commonBridge('saveimage', data);\n};\n/**\n * @description 配置app分享\n * @param {IShareData} data\n * @param {string} data.shareUrl 需要分享的地址\n * @param {string} data.shareImg 分享的封面\n * @param {string} data.shareTitle 分享的标题\n * @param {string} data.shareDesc 分享的说明\n * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置\n */\nvar scgcShare = function (data) {\n commonBridge('share', data);\n};\n/**\n * @description 打开一个webview\n * @param {ItoH5Data} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcToH5 = function (data) {\n commonBridge('toH5', data);\n};\n/**\n * @description 打开app原生新闻页\n * @param {IToDetailData} data\n * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式\n * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链\n */\nvar scgcToDetail = function (data) {\n commonBridge('toDetail', data);\n};\n/**\n * @description 打开app原生专题详情页\n * @param {IToSpecialData} data\n * @param {string} data.id 专题id\n */\nvar scgcToSpecial = function (data) {\n commonBridge('toSpecial', data);\n};\n/**\n * @description 打开app原生直播页\n * @param {IToLiveData} data\n * @param {string} data.id 直播id\n * @param {string} data.type 直播样式 1 横版 2 竖版\n */\nvar scgcToLive = function (data) {\n commonBridge('toLive', data);\n};\n/**\n * @description 打开app话题页\n * @param {IToTopicData} data\n * @param {string} data.name 话题名称\n * @param {string} data.cover 话题封面图(完整的图片地址)\n * @param {string} data.id 话题id\n */\nvar scgcToTopic = function (data) {\n commonBridge('toTopic', data);\n};\n/**\n * @description 设置app音量\n * @param {ISetVolumeData} data\n * @param {number} data.type 0 调小 1 调大\n */\nvar scgcSetVolume = function (data) {\n commonBridge('setVolume', data);\n};\n/**\n * @description 打开app原生专题新闻列表页\n * @param {IToSubSpecialData} data\n * @param {string} data.title 专题标题\n * @param {string} data.id 专题id\n */\nvar scgcToSubSpecial = function (data) {\n commonBridge('toSubSpecial', data);\n};\n/**\n * @description 打开积分商城商品详情\n * @param {IMallDetailData} data\n * @param {string} data.json 商品详情json地址\n * @param {string} data.url 商品详情网页地址\n * @param {string} data.ptype todo 未知\n * @param {number} data.isDark 0 普通模式 1 黑暗模式\n */\nvar scgcToMallDetail = function (data) {\n commonBridge('detailJson', data);\n};\n/**\n * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)\n * @param {IMallDetailData} data\n * @param {boolean} data.focus 是否禁止app滑动\n *\n */\nvar scgcFocusWeb = function (data) {\n commonBridge('focusWeb', data);\n};\n/**\n * @description 跳转至积分商城\n */\nvar scgcToMall = function () {\n commonBridge('mall');\n};\n/**\n * @description 跳转至快拍\n */\nvar scgcToKuaipai = function () {\n commonBridge('release');\n};\n/**\n * @description 跳转至app首页\n */\nvar scgcToAppHome = function () {\n commonBridge('mainPage');\n};\n/**\n * @description 设置app顶部时间栏颜色\n * @param {IChangeStateBarColorData} data\n * @param {number} data.type 1 黑色 2 白色\n *\n */\nvar scgcChangeStateBarColor = function (data) {\n commonBridge('changeStatebarColor', data);\n};\n/**\n * @description 获取app 用户id\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetUserId = function () {\n return commonBridge('getUserId');\n};\n/**\n * @description 获取app 用户头像\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetAvatar = function () {\n return commonBridge('getAvatar');\n};\n/**\n * @description 获取app 用户昵称\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetNickName = function () {\n return commonBridge('getNickName');\n};\n// /**\n// * @description 获取app 用户手机号\n// * @return {Promise((success:boolean,data:string))} 返回promise\n// *\n// */\nvar scgcGetPhoneNumber = function () {\n return commonBridge('getPhoneNumber');\n};\n/**\n * @description 传递验证码参数到app(阿里验证码2.0使用)\n * @param {IGetCaptchaVerifyParamData} data\n * @param {string} data.captchaVerifyParam 验证码参数\n */\nvar scgcGetCaptchaVerifyParam = function (data) {\n return commonBridge('getCaptchaVerifyParam', data);\n};\n\n/**\n * @description 打开原生综艺页面\n * @param {IProgramData} data\n * @param {string} data.programId 节目Id\n * @param {string} data.groupId 合集Id\n * @param {string} data.episodeId 单集Id\n */\nvar scgctoVarietyshow = function (data) {\n return commonBridge('toVarietyshow', data);\n};\n/**\n * @description 打开原生纪录片页面\n * @param {IProgramData} data\n * @param {string} data.programId 节目Id\n * @param {string} data.groupId 合集Id\n * @param {string} data.episodeId 单集Id\n */\nvar scgctoDocumentshow = function (data) {\n return commonBridge('toDocumentary', data);\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/index.ts?\n}")},"./src/utils.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ commonBridgeFun: () => (/* binding */ commonBridgeFun),\n/* harmony export */ initAsyncCallbackPool: () => (/* binding */ initAsyncCallbackPool),\n/* harmony export */ isScgcApp: () => (/* binding */ isScgcApp),\n/* harmony export */ setDevMode: () => (/* binding */ setDevMode)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar distinctionPlatform = function () {\n var ua = navigator.userAgent;\n if (/(iPhone|iPad|iPod)/i.test(ua)) {\n return 'ios';\n }\n else if (/Android/i.test(ua)) {\n return 'android';\n }\n else if (/openharmony/i.test(ua)) {\n return 'harmony';\n }\n else {\n return 'unknow';\n }\n};\nvar asyncFunsArr = [\n 'getToken',\n 'getUserId',\n 'getAvatar',\n 'getNickName',\n 'getPhoneNumber',\n 'getPromise', //测试用\n];\nvar androidAsyncFunsArr = ['getPromise'];\nvar devMode = false;\nvar setDevMode = function () {\n devMode = true;\n};\nvar initAsyncCallbackPool = function () {\n window.bridgeCallbacks = {};\n};\nvar devFn = function (platform, fnName, data) {\n //动态判断是否为devMode,避免初始化commonBridgeFun比调用setDevMode的早的情况下,devMode参数已固定(损失的性能可以接受)\n if (devMode) {\n var devInfo = {\n platform: platform,\n fnName: fnName,\n data: data,\n };\n console.log(devInfo);\n }\n};\nfunction makeRandomId(fnName) {\n return \"\".concat(fnName || 'anonymous', \"_\").concat(Date.now());\n}\nfunction registerCallback(fnName, cb) {\n if (!cb) {\n return null;\n }\n var callbackId = makeRandomId(fnName);\n if (!window.hasOwnProperty('bridgeCallbacks')) {\n window.bridgeCallbacks = {};\n }\n window.bridgeCallbacks[callbackId] = function (data) {\n var result;\n if (typeof data === 'object') {\n result = data;\n }\n else if (typeof data === 'string') {\n try {\n result = JSON.parse(data);\n }\n catch (e) {\n result = data;\n }\n }\n cb(result);\n };\n return \"bridgeCallbacks.\".concat(callbackId);\n}\nfunction androidBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b;\n var androidParams = {\n Method: fnName,\n Data: data,\n };\n devFn('android', fnName, data);\n if (fnName == 'getSlideData') {\n (_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));\n }\n else if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {\n var res, result;\n var _a, _b;\n return __generator(this, function (_c) {\n try {\n //安卓使用了异步返回\n if (androidAsyncFunsArr.includes(fnName)) {\n (_a = window === null || window === void 0 ? void 0 : window.newBridge) === null || _a === void 0 ? void 0 : _a[fnName](JSON.stringify({\n callback: registerCallback(fnName, resolve),\n }));\n }\n else {\n res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();\n result = void 0;\n if (typeof res === 'object') {\n result = res;\n }\n else if (typeof res === 'string') {\n try {\n result = JSON.parse(res);\n }\n catch (e) {\n result = { success: false, data: res };\n }\n }\n if ((result === null || result === void 0 ? void 0 : result.success) == true) {\n resolve(result);\n }\n else {\n reject(result);\n }\n }\n }\n catch (error) {\n reject(error);\n }\n return [2 /*return*/];\n });\n }); });\n return promiseRes;\n }\n else {\n (_b = window === null || window === void 0 ? void 0 : window.bridge) === null || _b === void 0 ? void 0 : _b.callRouter(JSON.stringify(androidParams), function () { });\n }\n}\nfunction iosBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b, _c;\n devFn('ios', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a, _b, _c;\n try {\n var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n try {\n if ((res === null || res === void 0 ? void 0 : res.success) == 'true') {\n resolve({\n success: true,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n else {\n reject({\n success: false,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n return [2 /*return*/];\n });\n }); };\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage({\n data: {},\n callback: registerCallback(fnName, _cb),\n });\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n });\n return promiseRes;\n }\n else {\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage(data);\n }\n}\nfunction harmonyBridgeFn(fnName, data) {\n var _a, _b;\n devFn('harmony', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a;\n try {\n (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]({\n data: data,\n callback: registerCallback(fnName, resolve),\n });\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n else {\n (_b = (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, data);\n }\n}\nfunction defaultBridgeFn(fnName, data) {\n console.log('请使用scgc app打开');\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n try {\n resolve('请使用scgc app打开');\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n}\nvar commonBridgeFun = function () {\n var platform = distinctionPlatform();\n if (platform == 'android') {\n return androidBridgeFn;\n }\n else if (platform == 'ios') {\n return iosBridgeFn;\n }\n else if (platform == 'harmony') {\n return harmonyBridgeFn;\n }\n else {\n return defaultBridgeFn;\n }\n};\n/**\n * @description 是否为app环境\n * @return {boolean} true 是 false 否\n */\nvar isScgcApp = function () {\n return navigator.userAgent.indexOf('SCGC_UA') > -1;\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/utils.ts?\n}")}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var a=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(n,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),__webpack_require__.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__("./src/index.ts");return __webpack_exports__})());
|