crh-jssdk 1.0.49 → 1.0.52
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.
|
@@ -37,6 +37,24 @@ 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
|
+
};
|
|
40
58
|
// webview类型
|
|
41
59
|
var webviewType = (function () {
|
|
42
60
|
var ua = navigator.userAgent;
|
|
@@ -93,23 +111,21 @@ exports.default = {
|
|
|
93
111
|
/**
|
|
94
112
|
* 通过pageId打开新的webview打开外部链接
|
|
95
113
|
*/
|
|
96
|
-
goWebview: function (
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
indexUrl:
|
|
100
|
-
|
|
101
|
-
cookieDomain: "",
|
|
102
|
-
closeBusiness: "closeCallBack",
|
|
103
|
-
module: "",
|
|
104
|
-
identifier: "zt",
|
|
114
|
+
goWebview: function (p) {
|
|
115
|
+
var params = {
|
|
116
|
+
statusBarColor: '#ff6800',
|
|
117
|
+
indexUrl: p.url,
|
|
118
|
+
isNeedTitle: p.needTitle || '0',
|
|
105
119
|
};
|
|
106
|
-
|
|
107
|
-
if (utils_1.ios) {
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
console.log('2222+___==============', params, utils_1.ios);
|
|
121
|
+
if (utils_1.ios) { // iphone
|
|
122
|
+
actionMap.loadIOSNative("objc://openOwnPage/$?".concat(JSON.stringify(params)));
|
|
123
|
+
}
|
|
124
|
+
else if ((0, utils_1.checkIsHarmonyOS)()) {
|
|
125
|
+
window.HarmonyBridge.callJsHandler('openOwnPage', JSON.stringify(params));
|
|
110
126
|
}
|
|
111
127
|
else {
|
|
112
|
-
window.jtoJHandle.
|
|
128
|
+
window.jtoJHandle.openOwnPage(JSON.stringify(params));
|
|
113
129
|
}
|
|
114
130
|
},
|
|
115
131
|
/**
|
|
@@ -138,12 +154,23 @@ exports.default = {
|
|
|
138
154
|
*/
|
|
139
155
|
setStatusBar: function (params) {
|
|
140
156
|
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
var json;
|
|
141
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, ")"));
|
|
142
165
|
if (utils_1.ios) {
|
|
143
|
-
actionMap.loadIOSNative("objc://
|
|
166
|
+
actionMap.loadIOSNative("objc://setStatusBarColor/$?".concat(json));
|
|
144
167
|
}
|
|
145
|
-
else if (
|
|
146
|
-
window.
|
|
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);
|
|
147
174
|
}
|
|
148
175
|
return [2 /*return*/];
|
|
149
176
|
});
|
|
@@ -160,7 +187,10 @@ exports.default = {
|
|
|
160
187
|
window.location.href = "objc://updateApp/$?" + url;
|
|
161
188
|
}
|
|
162
189
|
else if (window.jtoJHandle) {
|
|
163
|
-
window.jtoJHandle.updateApp('
|
|
190
|
+
window.jtoJHandle.updateApp('1', url);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
window.HarmonyBridge.callJsHandler('updateApp', url);
|
|
164
194
|
}
|
|
165
195
|
return [2 /*return*/];
|
|
166
196
|
});
|
|
@@ -156,6 +156,24 @@ var actionMap = {
|
|
|
156
156
|
iFrame = null;
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
|
+
/**
|
|
160
|
+
* 规范化 hex 颜色值:转小写、补 # 前缀、3 位补 6 位
|
|
161
|
+
* 非 hex 格式仅转小写后原样返回
|
|
162
|
+
* @param color 颜色值,如 #FF0000、FFF、fff
|
|
163
|
+
* @returns 规范化后的颜色值,如 #ff0000
|
|
164
|
+
*/
|
|
165
|
+
var normalizeColor = function (color) {
|
|
166
|
+
var c = color.trim().toLowerCase();
|
|
167
|
+
// 匹配 #RGB / #RRGGBB 及不带 # 的形式
|
|
168
|
+
if (/^#?[0-9a-f]{3}$/.test(c) || /^#?[0-9a-f]{6}$/.test(c)) {
|
|
169
|
+
var hex = c.startsWith("#") ? c.slice(1) : c;
|
|
170
|
+
if (hex.length === 3) {
|
|
171
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
172
|
+
}
|
|
173
|
+
return "#" + hex;
|
|
174
|
+
}
|
|
175
|
+
return c;
|
|
176
|
+
};
|
|
159
177
|
exports.default = {
|
|
160
178
|
// 获取客户端用户和设备信息
|
|
161
179
|
getDeviceInfo: function () {
|
|
@@ -203,19 +221,29 @@ exports.default = {
|
|
|
203
221
|
}
|
|
204
222
|
},
|
|
205
223
|
/**
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
*/
|
|
224
|
+
* @param {object} params
|
|
225
|
+
* @param {string} params.color 状态栏背景颜色,如#ff0000
|
|
226
|
+
* @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
|
|
227
|
+
*/
|
|
211
228
|
setStatusBar: function (params) {
|
|
212
229
|
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
+
var json;
|
|
213
231
|
return __generator(this, function (_a) {
|
|
232
|
+
// 规范化颜色:大写转小写并补齐(# 前缀、3 位补 6 位)
|
|
233
|
+
if ((params === null || params === void 0 ? void 0 : params.color) && typeof params.color === "string") {
|
|
234
|
+
params.color = normalizeColor(params.color);
|
|
235
|
+
}
|
|
236
|
+
json = JSON.stringify(params);
|
|
237
|
+
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
214
238
|
if (utils_1.ios) {
|
|
215
|
-
actionMap.loadIOSNative("objc://
|
|
239
|
+
actionMap.loadIOSNative("objc://setStatusBarColor/$?".concat(json));
|
|
216
240
|
}
|
|
217
|
-
else if (
|
|
218
|
-
window.
|
|
241
|
+
else if ((0, utils_1.checkIsHarmonyOS)()) {
|
|
242
|
+
window.HarmonyBridge.callJsHandler('setStatusBarColor', json);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
console.log("window.jtoJHandle.setStatusBarColor(".concat(json, ")"));
|
|
246
|
+
window.jtoJHandle.setStatusBarColor(json);
|
|
219
247
|
}
|
|
220
248
|
return [2 /*return*/];
|
|
221
249
|
});
|