crh-jssdk 1.0.55 → 1.0.57
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.
|
@@ -133,7 +133,7 @@ exports.default = {
|
|
|
133
133
|
*/
|
|
134
134
|
goWebview: function (params) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var url, _a, needTitle, isWt, _b, isCfcaMode, gotoUrl, error_3;
|
|
136
|
+
var url, _a, needTitle, isWt, _b, isCfcaMode, gotoUrl, gotoUrl, error_3;
|
|
137
137
|
return __generator(this, function (_c) {
|
|
138
138
|
switch (_c.label) {
|
|
139
139
|
case 0:
|
|
@@ -155,7 +155,11 @@ exports.default = {
|
|
|
155
155
|
case 5:
|
|
156
156
|
console.log('---ios');
|
|
157
157
|
if (!utils_1.ios) return [3 /*break*/, 6];
|
|
158
|
-
|
|
158
|
+
gotoUrl = "client://hxsecurity.frame.router/5032?url=".concat(encodeURIComponent(url), "&rp_flag_push_to_stack_directly=1&isHiddenNavigationBar=1&isHiddenBottomBar=1&isNeedWtLogin=1");
|
|
159
|
+
if (isCfcaMode) {
|
|
160
|
+
gotoUrl += '&isCfcaMode=1';
|
|
161
|
+
}
|
|
162
|
+
window.location.href = gotoUrl;
|
|
159
163
|
return [2 /*return*/];
|
|
160
164
|
case 6:
|
|
161
165
|
gotoUrl = "client.html?action=ymtz^webid=9995^url=".concat(url, "^isHiddenNavigationBar=").concat(needTitle ? 1 : 0, "^isHiddenBottomBar=1^isNeedWtLogin=1");
|
|
@@ -37,24 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var utils_1 = require("../utils");
|
|
40
|
-
/**
|
|
41
|
-
* 规范化 hex 颜色值:转小写、补 # 前缀、3 位补 6 位
|
|
42
|
-
* 非 hex 格式仅转小写后原样返回
|
|
43
|
-
* @param color 颜色值,如 #FF0000、FFF、fff
|
|
44
|
-
* @returns 规范化后的颜色值,如 #ff0000
|
|
45
|
-
*/
|
|
46
|
-
var normalizeColor = function (color) {
|
|
47
|
-
var c = color.trim().toLowerCase();
|
|
48
|
-
// 匹配 #RGB / #RRGGBB 及不带 # 的形式
|
|
49
|
-
if (/^#?[0-9a-f]{3}$/.test(c) || /^#?[0-9a-f]{6}$/.test(c)) {
|
|
50
|
-
var hex = c.startsWith("#") ? c.slice(1) : c;
|
|
51
|
-
if (hex.length === 3) {
|
|
52
|
-
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
53
|
-
}
|
|
54
|
-
return "#" + hex;
|
|
55
|
-
}
|
|
56
|
-
return c;
|
|
57
|
-
};
|
|
58
40
|
// webview类型
|
|
59
41
|
var webviewType = (function () {
|
|
60
42
|
var ua = navigator.userAgent;
|
|
@@ -104,9 +86,12 @@ exports.default = {
|
|
|
104
86
|
// iphone
|
|
105
87
|
window.location.href = "objc://callIOSQuit/";
|
|
106
88
|
}
|
|
107
|
-
else {
|
|
89
|
+
else if (window.jtoJHandle) {
|
|
108
90
|
window.jtoJHandle.closeSJKH();
|
|
109
91
|
}
|
|
92
|
+
else {
|
|
93
|
+
window.HarmonyBridge.callJsHandler('closeSJKH');
|
|
94
|
+
}
|
|
110
95
|
},
|
|
111
96
|
/**
|
|
112
97
|
* 通过pageId打开新的webview打开外部链接
|
|
@@ -147,35 +132,6 @@ exports.default = {
|
|
|
147
132
|
(_b = window.jtoJHandle) === null || _b === void 0 ? void 0 : _b.openNewBusiness(paramsObj);
|
|
148
133
|
}
|
|
149
134
|
},
|
|
150
|
-
/**
|
|
151
|
-
* @param {object} params
|
|
152
|
-
* @param {string} params.color 状态栏背景颜色,如#ff0000
|
|
153
|
-
* @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
|
|
154
|
-
*/
|
|
155
|
-
setStatusBar: function (params) {
|
|
156
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
-
var json;
|
|
158
|
-
return __generator(this, function (_a) {
|
|
159
|
-
// 规范化颜色:大写转小写并补齐(# 前缀、3 位补 6 位)
|
|
160
|
-
if ((params === null || params === void 0 ? void 0 : params.color) && typeof params.color === "string") {
|
|
161
|
-
params.color = normalizeColor(params.color);
|
|
162
|
-
}
|
|
163
|
-
json = JSON.stringify(params);
|
|
164
|
-
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
165
|
-
if (utils_1.ios) {
|
|
166
|
-
actionMap.loadIOSNative("objc://setStatusBarColor/$?".concat(json));
|
|
167
|
-
}
|
|
168
|
-
else if ((0, utils_1.checkIsHarmonyOS)()) {
|
|
169
|
-
window.HarmonyBridge.callJsHandler('setStatusBarColor', json);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
173
|
-
window.jtoJHandle.setStatusBarColor(json);
|
|
174
|
-
}
|
|
175
|
-
return [2 /*return*/];
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
135
|
/**
|
|
180
136
|
* 在app内打开浏览器
|
|
181
137
|
* @param url 浏览器地址
|
|
@@ -190,7 +146,7 @@ exports.default = {
|
|
|
190
146
|
window.jtoJHandle.updateApp('1', url);
|
|
191
147
|
}
|
|
192
148
|
else {
|
|
193
|
-
window.HarmonyBridge.callJsHandler('updateApp', url);
|
|
149
|
+
window.HarmonyBridge.callJsHandler('updateApp', JSON.stringify({ url: url }));
|
|
194
150
|
}
|
|
195
151
|
return [2 /*return*/];
|
|
196
152
|
});
|
|
@@ -180,6 +180,7 @@ exports.default = {
|
|
|
180
180
|
var _this = this;
|
|
181
181
|
console.log("getDeviceInfo----");
|
|
182
182
|
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
183
|
+
var data;
|
|
183
184
|
var _a;
|
|
184
185
|
return __generator(this, function (_b) {
|
|
185
186
|
window.getDeviceInfoCB = function (jsonStr) {
|
|
@@ -192,9 +193,15 @@ exports.default = {
|
|
|
192
193
|
if (utils_1.ios) {
|
|
193
194
|
actionMap.loadIOSNative("objc://getDeviceInfo/?getDeviceInfoCB");
|
|
194
195
|
}
|
|
195
|
-
else {
|
|
196
|
+
else if (window.jtoJHandle) {
|
|
196
197
|
(_a = window.jtoJHandle) === null || _a === void 0 ? void 0 : _a.getDeviceInfo("getDeviceInfoCB");
|
|
197
198
|
}
|
|
199
|
+
else {
|
|
200
|
+
data = {
|
|
201
|
+
callback: "getDeviceInfoCB",
|
|
202
|
+
};
|
|
203
|
+
window.HarmonyBridge.callJsHandler('getDeviceInfo', JSON.stringify(data));
|
|
204
|
+
}
|
|
198
205
|
return [2 /*return*/];
|
|
199
206
|
});
|
|
200
207
|
}); });
|
|
@@ -227,24 +234,29 @@ exports.default = {
|
|
|
227
234
|
*/
|
|
228
235
|
setStatusBar: function (params) {
|
|
229
236
|
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
-
var json;
|
|
237
|
+
var json, jsonHarmony;
|
|
231
238
|
return __generator(this, function (_a) {
|
|
232
239
|
// 规范化颜色:大写转小写并补齐(# 前缀、3 位补 6 位)
|
|
233
240
|
if ((params === null || params === void 0 ? void 0 : params.color) && typeof params.color === "string") {
|
|
234
241
|
params.color = normalizeColor(params.color);
|
|
235
242
|
}
|
|
236
243
|
json = JSON.stringify(params);
|
|
237
|
-
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
238
244
|
if (utils_1.ios) {
|
|
245
|
+
console.log("window.location.href = \"objc://setStatusBarColor/".concat(json, "\""));
|
|
239
246
|
actionMap.loadIOSNative("objc://setStatusBarColor/$?".concat(json));
|
|
240
247
|
}
|
|
241
|
-
else if (
|
|
242
|
-
window.HarmonyBridge.callJsHandler('setStatusBarColor', json);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
248
|
+
else if (window.jtoJHandle) {
|
|
245
249
|
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
246
250
|
window.jtoJHandle.setStatusBarColor(json);
|
|
247
251
|
}
|
|
252
|
+
else {
|
|
253
|
+
jsonHarmony = JSON.stringify({
|
|
254
|
+
statusBarColor: params.color,
|
|
255
|
+
statusBarContentColor: params.wordColorStyle === 0 ? "ffffff" : "000000",
|
|
256
|
+
});
|
|
257
|
+
console.log("window.HarmonyBridge.callJsHandler('setStatusBarColor', ".concat(jsonHarmony, ")"));
|
|
258
|
+
window.HarmonyBridge.callJsHandler('setStatusBarColor', jsonHarmony);
|
|
259
|
+
}
|
|
248
260
|
return [2 /*return*/];
|
|
249
261
|
});
|
|
250
262
|
});
|
|
@@ -50,8 +50,20 @@ exports.default = {
|
|
|
50
50
|
getUser: function () {
|
|
51
51
|
var _this = this;
|
|
52
52
|
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
|
+
var data;
|
|
53
54
|
return __generator(this, function (_a) {
|
|
54
55
|
window.getUserInfoCB = function (username, password, onUse, loginFlag) {
|
|
56
|
+
// 鸿蒙端将整个用户信息作为 JSON 字符串放在 username 参数中返回,需解析还原
|
|
57
|
+
if (typeof username === 'string' && username.startsWith('{')) {
|
|
58
|
+
try {
|
|
59
|
+
var userInfo = JSON.parse(username);
|
|
60
|
+
username = userInfo.username;
|
|
61
|
+
password = userInfo.password;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error('解析鸿蒙用户信息失败:', e);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
55
67
|
if (username !== '' && username !== 'null' && username !== '(null)' && loginFlag !== '1') {
|
|
56
68
|
resolve({
|
|
57
69
|
username: username,
|
|
@@ -73,6 +85,12 @@ exports.default = {
|
|
|
73
85
|
else if (window.jtoJHandle) {
|
|
74
86
|
window.jtoJHandle.getUser("getUserInfoCB");
|
|
75
87
|
}
|
|
88
|
+
else {
|
|
89
|
+
data = {
|
|
90
|
+
callback: "getUserInfoCB",
|
|
91
|
+
};
|
|
92
|
+
window.HarmonyBridge.callJsHandler('getUser', JSON.stringify(data));
|
|
93
|
+
}
|
|
76
94
|
return [2 /*return*/];
|
|
77
95
|
});
|
|
78
96
|
}); });
|
|
@@ -126,6 +144,9 @@ exports.default = {
|
|
|
126
144
|
else if (window.jtoJHandle) {
|
|
127
145
|
window.jtoJHandle.callOtherLogin("userLogin");
|
|
128
146
|
}
|
|
147
|
+
else {
|
|
148
|
+
window.HarmonyBridge.callJsHandler('callOtherLogin');
|
|
149
|
+
}
|
|
129
150
|
return [2 /*return*/];
|
|
130
151
|
});
|
|
131
152
|
}); });
|