@ray-js/api 1.4.0-alpha.1 → 1.4.0-alpha.10
Sign up to get free protection for your applications and to get access to all the features.
- package/@types/P2PKit.d.ts +402 -0
- package/@types/all-kits.d.ts +1 -0
- package/lib/BaseKit-3.3.10.js +85 -83
- package/lib/BizKit-3.2.7.js +48 -47
- package/lib/DeviceKit-3.3.1.js +194 -193
- package/lib/HomeKit-3.1.4.js +2 -1
- package/lib/MapKit-3.0.7.js +4 -2
- package/lib/MiniKit-3.1.0.js +65 -64
- package/lib/P2PKit-2.0.3.d.ts +27 -0
- package/lib/P2PKit-2.0.3.js +79 -0
- package/lib/PlayNetKit-1.1.3.js +2 -1
- package/lib/all-kits.d.ts +1 -0
- package/lib/all-kits.js +1 -0
- package/lib/cloud/alarm.js +4 -7
- package/lib/cloud/core.js +2 -3
- package/lib/cloud/device.js +20 -31
- package/lib/cloud/interface.d.ts +7 -7
- package/lib/cloud/linkage.js +43 -41
- package/lib/cloud/statistic.js +21 -33
- package/lib/cloud/timer.js +31 -48
- package/lib/constants.js +1 -1
- package/lib/core/promisify/index.js +5 -9
- package/lib/getBoundingClientRect/index.js +16 -17
- package/lib/getBoundingClientRect/index.thing.js +16 -17
- package/lib/getBoundingClientRect/index.wechat.js +16 -17
- package/lib/getCdnUrl/index.d.ts +1 -0
- package/lib/getCdnUrl/index.js +4 -0
- package/lib/getCdnUrl/index.thing.d.ts +3 -1
- package/lib/getCdnUrl/index.thing.js +54 -19
- package/lib/getCdnUrl/index.wechat.d.ts +1 -0
- package/lib/getCdnUrl/index.wechat.js +4 -0
- package/lib/getElementById/index.js +1 -3
- package/lib/getElementById/index.thing.js +2 -4
- package/lib/getElementById/index.wechat.js +2 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -3
- package/lib/lifecycles/offAppEvent/index.js +2 -2
- package/lib/lifecycles/offAppHide/index.js +2 -2
- package/lib/lifecycles/offAppShow/index.js +2 -2
- package/lib/lifecycles/offError/index.js +2 -2
- package/lib/lifecycles/offThemeChange/index.js +2 -2
- package/lib/lifecycles/offWindowResize/index.js +2 -2
- package/lib/lifecycles/onAppEvent/index.js +2 -2
- package/lib/lifecycles/onAppHide/index.js +2 -2
- package/lib/lifecycles/onAppShow/index.js +2 -2
- package/lib/lifecycles/onError/index.js +2 -2
- package/lib/lifecycles/onPageNotFound/index.js +2 -2
- package/lib/lifecycles/onThemeChange/index.js +2 -2
- package/lib/lifecycles/onWindowResize/index.js +2 -2
- package/lib/navigateBack/index.js +3 -6
- package/lib/navigateTo/index.js +2 -5
- package/lib/onNavigationBarBack/index.js +1 -2
- package/lib/onNavigationBarBack/index.wechat.js +1 -2
- package/lib/panel/devInfo/index.js +84 -121
- package/lib/panel/i18n/index.d.ts +1 -1
- package/lib/panel/i18n/index.js +180 -262
- package/lib/panel/i18n/index.wechat.d.ts +1 -1
- package/lib/panel/i18n/index.wechat.js +184 -267
- package/lib/panel/normalizeNetwork.d.ts +2 -2
- package/lib/panel/normalizeNetwork.js +2 -7
- package/lib/panel/publishDps.d.ts +1 -1
- package/lib/panel/publishDps.js +13 -18
- package/lib/panel/types/devInfo.d.ts +3 -3
- package/lib/panel/types/utilities.d.ts +8 -8
- package/lib/panel/utils.js +1 -3
- package/lib/reLaunch/index.js +2 -5
- package/lib/redirectTo/index.js +2 -6
- package/lib/requestCloud/index.js +2 -2
- package/lib/requestCloud/index.wechat.js +0 -1
- package/lib/setNavigationBarBack/index.js +1 -2
- package/lib/setNavigationBarBack/index.wechat.js +1 -2
- package/lib/setNavigationBarColor/index.js +3 -6
- package/lib/setNavigationBarTitle/index.js +5 -6
- package/lib/switchTab/index.js +2 -5
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +5 -14
- package/lib/utils.wechat.d.ts +1 -1
- package/lib/utils.wechat.js +9 -21
- package/lib/viewAPI.js +13 -12
- package/package.json +25 -25
- package/LICENSE.md +0 -9
package/lib/panel/i18n/index.js
CHANGED
@@ -1,289 +1,207 @@
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
4
|
-
import "core-js/modules/es.object.keys.js";
|
5
|
-
import "core-js/modules/es.object.assign.js";
|
6
|
-
import "core-js/modules/es.array.map.js";
|
7
|
-
import "core-js/modules/es.regexp.exec.js";
|
8
|
-
import "core-js/modules/es.regexp.test.js";
|
9
|
-
import "core-js/modules/es.array.last-index-of.js";
|
10
1
|
import "core-js/modules/es.string.replace.js";
|
11
|
-
import "core-js/modules/es.regexp.constructor.js";
|
12
|
-
import "core-js/modules/es.regexp.dot-all.js";
|
13
|
-
import "core-js/modules/es.regexp.sticky.js";
|
14
|
-
import "core-js/modules/es.regexp.to-string.js";
|
15
|
-
import "core-js/modules/es.array.concat.js";
|
16
|
-
import "core-js/modules/es.parse-float.js";
|
17
2
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
18
3
|
import { getBitValue } from '../utils';
|
19
|
-
|
20
|
-
|
21
|
-
function I18N(props) {
|
22
|
-
_classCallCheck(this, I18N);
|
23
|
-
|
4
|
+
export default class I18N {
|
5
|
+
constructor(props) {
|
24
6
|
this.strings = this.mergeLanguage(props, {});
|
25
7
|
this.defaultLang = this.strings.en ? 'en' : Object.keys(this.strings)[0];
|
26
8
|
this.setLanguage(this.defaultLang);
|
27
|
-
|
9
|
+
const langKey = getSystemInfoSync().language;
|
28
10
|
this.setLanguage(langKey);
|
29
11
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
// @ts-ignore
|
46
|
-
success: function success(data) {
|
47
|
-
if (data) {
|
48
|
-
_this.strings = _this.mergeLanguage(_this.strings, data);
|
49
|
-
|
50
|
-
_this.buildLanguage(_this.__language);
|
51
|
-
}
|
12
|
+
forceUpdateNetworkLang(productId) {
|
13
|
+
requestCloud({
|
14
|
+
api: "".concat(THING, ".m.i18n.get"),
|
15
|
+
version: '1.0',
|
16
|
+
data: {
|
17
|
+
productId,
|
18
|
+
moduleName: 'h5',
|
19
|
+
endId: 2,
|
20
|
+
osId: 0
|
21
|
+
},
|
22
|
+
// @ts-ignore
|
23
|
+
success: data => {
|
24
|
+
if (data) {
|
25
|
+
this.strings = this.mergeLanguage(this.strings, data);
|
26
|
+
this.buildLanguage(this.__language);
|
52
27
|
}
|
53
|
-
});
|
54
|
-
}
|
55
|
-
}, {
|
56
|
-
key: "mergeLanguage",
|
57
|
-
value: function mergeLanguage(L1, L2) {
|
58
|
-
if (typeof L1 === 'undefined' && typeof L2 === 'undefined') return {};
|
59
|
-
if (typeof L1 === 'undefined') return L2;
|
60
|
-
if (typeof L2 === 'undefined') return L1;
|
61
|
-
var L0 = Object.assign({}, L1);
|
62
|
-
Object.keys(L2).map(function (k) {
|
63
|
-
if (typeof L0[k] !== 'undefined') {
|
64
|
-
Object.assign(L0[k], L2[k]);
|
65
|
-
} else {
|
66
|
-
L0[k] = Object.assign({}, L2[k]);
|
67
|
-
}
|
68
|
-
|
69
|
-
return null;
|
70
|
-
});
|
71
|
-
return L0;
|
72
|
-
}
|
73
|
-
}, {
|
74
|
-
key: "isZh",
|
75
|
-
value: function isZh(language) {
|
76
|
-
/**
|
77
|
-
* ios 的中文简体固定为 zh-Hans,
|
78
|
-
* 但安卓的中文简体可能有一大堆排列组件 = =,如 zh_CN、zh_cn、zh_Hans_CH、zh_hans_cn 等等;
|
79
|
-
*/
|
80
|
-
|
81
|
-
/**
|
82
|
-
* 如果匹配到位中文简体地区,
|
83
|
-
* 则将中文 zh 相关的 values 都写入到 this.strings 下,保证兜底本地 zh 相关的能取到,
|
84
|
-
* 再将当前地区 key 相关的 values 都写入到 this.strings 下,优先级最高;
|
85
|
-
*/
|
86
|
-
if (typeof language === 'string' && /^zh-hans$|^zh_hans$|^zh_cn$|^zh-cn$|^zh_hans_\w+|^zh-hans-\w+/.test(language.toLowerCase())) {
|
87
|
-
return true;
|
88
28
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if (
|
98
|
-
|
99
|
-
this.buildLanguage(language);
|
29
|
+
});
|
30
|
+
}
|
31
|
+
mergeLanguage(L1, L2) {
|
32
|
+
if (typeof L1 === 'undefined' && typeof L2 === 'undefined') return {};
|
33
|
+
if (typeof L1 === 'undefined') return L2;
|
34
|
+
if (typeof L2 === 'undefined') return L1;
|
35
|
+
const L0 = Object.assign({}, L1);
|
36
|
+
Object.keys(L2).map(k => {
|
37
|
+
if (typeof L0[k] !== 'undefined') {
|
38
|
+
Object.assign(L0[k], L2[k]);
|
100
39
|
} else {
|
101
|
-
|
102
|
-
}
|
103
|
-
}
|
104
|
-
}, {
|
105
|
-
key: "buildLanguage",
|
106
|
-
value: function buildLanguage(language) {
|
107
|
-
var _this2 = this;
|
108
|
-
|
109
|
-
if (this.strings[language]) {
|
110
|
-
var localizedStrings = this.strings[language];
|
111
|
-
Object.keys(localizedStrings).map(function (key) {
|
112
|
-
// eslint-disable-next-line no-prototype-builtins
|
113
|
-
if (localizedStrings.hasOwnProperty(key)) {
|
114
|
-
_this2[key] = localizedStrings[key];
|
115
|
-
}
|
116
|
-
|
117
|
-
return null;
|
118
|
-
});
|
119
|
-
}
|
120
|
-
}
|
121
|
-
}, {
|
122
|
-
key: "_getBestMatchingLanguage",
|
123
|
-
value: function _getBestMatchingLanguage(language, props) {
|
124
|
-
if (props[language]) return language;
|
125
|
-
var idx = language.lastIndexOf('-');
|
126
|
-
|
127
|
-
if (idx >= 0) {
|
128
|
-
var lang = language.substring(0, idx);
|
129
|
-
return this._getBestMatchingLanguage(lang, props);
|
130
|
-
}
|
131
|
-
|
132
|
-
var underlineIdx = language.lastIndexOf('_');
|
133
|
-
|
134
|
-
if (underlineIdx >= 0) {
|
135
|
-
var _lang = language.substring(0, underlineIdx);
|
136
|
-
|
137
|
-
return this._getBestMatchingLanguage(_lang, props);
|
138
|
-
}
|
139
|
-
|
140
|
-
return this.defaultLang;
|
141
|
-
} // Format the passed string replacing the numbered placeholders
|
142
|
-
// i.e. I'd like some {0} and {1}, or just {0}
|
143
|
-
// Use example:
|
144
|
-
// strings.formatString(strings.question, strings.bread, strings.butter)
|
145
|
-
|
146
|
-
}, {
|
147
|
-
key: "formatString",
|
148
|
-
value: function formatString(str) {
|
149
|
-
var res = str;
|
150
|
-
|
151
|
-
for (var i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
152
|
-
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
40
|
+
L0[k] = Object.assign({}, L2[k]);
|
153
41
|
}
|
42
|
+
return null;
|
43
|
+
});
|
44
|
+
return L0;
|
45
|
+
}
|
46
|
+
isZh(language) {
|
47
|
+
/**
|
48
|
+
* ios 的中文简体固定为 zh-Hans,
|
49
|
+
* 但安卓的中文简体可能有一大堆排列组件 = =,如 zh_CN、zh_cn、zh_Hans_CH、zh_hans_cn 等等;
|
50
|
+
*/
|
154
51
|
|
155
|
-
|
52
|
+
/**
|
53
|
+
* 如果匹配到位中文简体地区,
|
54
|
+
* 则将中文 zh 相关的 values 都写入到 this.strings 下,保证兜底本地 zh 相关的能取到,
|
55
|
+
* 再将当前地区 key 相关的 values 都写入到 this.strings 下,优先级最高;
|
56
|
+
*/
|
57
|
+
if (typeof language === 'string' && /^zh-hans$|^zh_hans$|^zh_cn$|^zh-cn$|^zh_hans_\w+|^zh-hans-\w+/.test(language.toLowerCase())) {
|
58
|
+
return true;
|
156
59
|
}
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
return res;
|
60
|
+
return false;
|
61
|
+
}
|
62
|
+
setLanguage(language) {
|
63
|
+
this.__language = language;
|
64
|
+
if (this.isZh(language)) {
|
65
|
+
this.buildLanguage('zh');
|
66
|
+
this.buildLanguage(language);
|
67
|
+
} else {
|
68
|
+
this.buildLanguage(this.__language);
|
167
69
|
}
|
168
|
-
}
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
70
|
+
}
|
71
|
+
buildLanguage(language) {
|
72
|
+
if (this.strings[language]) {
|
73
|
+
const localizedStrings = this.strings[language];
|
74
|
+
Object.keys(localizedStrings).map(key => {
|
75
|
+
// eslint-disable-next-line no-prototype-builtins
|
76
|
+
if (localizedStrings.hasOwnProperty(key)) {
|
77
|
+
this[key] = localizedStrings[key];
|
78
|
+
}
|
79
|
+
return null;
|
80
|
+
});
|
175
81
|
}
|
176
|
-
}
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
} else if (typeof value === 'boolean') {
|
184
|
-
var valStr = value ? 'on' : 'off';
|
185
|
-
key = "dp_".concat(code, "_").concat(valStr).toLowerCase();
|
186
|
-
} else {
|
187
|
-
key = "dp_".concat(code, "_").concat(value).toLowerCase();
|
188
|
-
}
|
189
|
-
|
190
|
-
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
82
|
+
}
|
83
|
+
_getBestMatchingLanguage(language, props) {
|
84
|
+
if (props[language]) return language;
|
85
|
+
const idx = language.lastIndexOf('-');
|
86
|
+
if (idx >= 0) {
|
87
|
+
const lang = language.substring(0, idx);
|
88
|
+
return this._getBestMatchingLanguage(lang, props);
|
191
89
|
}
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
90
|
+
const underlineIdx = language.lastIndexOf('_');
|
91
|
+
if (underlineIdx >= 0) {
|
92
|
+
const lang = language.substring(0, underlineIdx);
|
93
|
+
return this._getBestMatchingLanguage(lang, props);
|
197
94
|
}
|
198
|
-
|
199
|
-
|
200
|
-
value: function getDpsLang(key) {
|
201
|
-
var _this3 = this;
|
202
|
-
|
203
|
-
var strs = {};
|
204
|
-
|
205
|
-
if (_typeof(key) === 'object') {
|
206
|
-
if (typeof key.strKey === 'string') {
|
207
|
-
strs = I18n.t(key.strKey) !== key.strKey ? I18n.t(key.strKey) : typeof this[key.strKey] !== 'undefined' ? this[key.strKey] : I18n.t(key.strKey);
|
208
|
-
} else {
|
209
|
-
Object.keys(key).map(function (i) {
|
210
|
-
strs[key[i]] = I18n.t(key[i]) !== key[i] ? I18n.t(key[i]) : typeof _this3[key[i]] !== 'undefined' ? _this3[key[i]] : I18n.t(key[i]);
|
211
|
-
return null;
|
212
|
-
});
|
213
|
-
}
|
214
|
-
} else {
|
215
|
-
strs = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
216
|
-
}
|
95
|
+
return this.defaultLang;
|
96
|
+
}
|
217
97
|
|
218
|
-
|
98
|
+
// Format the passed string replacing the numbered placeholders
|
99
|
+
// i.e. I'd like some {0} and {1}, or just {0}
|
100
|
+
// Use example:
|
101
|
+
// strings.formatString(strings.question, strings.bread, strings.butter)
|
102
|
+
formatString(str) {
|
103
|
+
let res = str;
|
104
|
+
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
105
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
219
106
|
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
107
|
+
return res;
|
108
|
+
}
|
109
|
+
formatValue(key) {
|
110
|
+
let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
111
|
+
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
112
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
224
113
|
}
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
});
|
243
|
-
return result;
|
114
|
+
return res;
|
115
|
+
}
|
116
|
+
_replaceAll(find, replace, str) {
|
117
|
+
// eslint-disable-next-line no-useless-escape, no-param-reassign
|
118
|
+
find = find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
119
|
+
if (!str) return '';
|
120
|
+
return str.replace(new RegExp(find, 'g'), replace);
|
121
|
+
}
|
122
|
+
getDpLang(code, value) {
|
123
|
+
let key;
|
124
|
+
if (typeof value === 'undefined') {
|
125
|
+
key = "dp_".concat(code).toLowerCase();
|
126
|
+
} else if (typeof value === 'boolean') {
|
127
|
+
const valStr = value ? 'on' : 'off';
|
128
|
+
key = "dp_".concat(code, "_").concat(valStr).toLowerCase();
|
129
|
+
} else {
|
130
|
+
key = "dp_".concat(code, "_").concat(value).toLowerCase();
|
244
131
|
}
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
key
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
132
|
+
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
133
|
+
}
|
134
|
+
getDpName(code, defaultName) {
|
135
|
+
const key = "dp_".concat(code).toLowerCase();
|
136
|
+
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
137
|
+
}
|
138
|
+
getDpsLang(key) {
|
139
|
+
let strs = {};
|
140
|
+
if (typeof key === 'object') {
|
141
|
+
if (typeof key.strKey === 'string') {
|
142
|
+
strs = I18n.t(key.strKey) !== key.strKey ? I18n.t(key.strKey) : typeof this[key.strKey] !== 'undefined' ? this[key.strKey] : I18n.t(key.strKey);
|
143
|
+
} else {
|
144
|
+
Object.keys(key).map(i => {
|
145
|
+
strs[key[i]] = I18n.t(key[i]) !== key[i] ? I18n.t(key[i]) : typeof this[key[i]] !== 'undefined' ? this[key[i]] : I18n.t(key[i]);
|
146
|
+
return null;
|
147
|
+
});
|
148
|
+
}
|
149
|
+
} else {
|
150
|
+
strs = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
263
151
|
}
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
var label = schema.label;
|
270
|
-
var labels = [];
|
152
|
+
return strs;
|
153
|
+
}
|
154
|
+
getLang(key, defaultString) {
|
155
|
+
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : typeof defaultString !== 'undefined' ? defaultString : I18n.t(key);
|
156
|
+
}
|
271
157
|
|
272
|
-
|
273
|
-
|
274
|
-
|
158
|
+
/**
|
159
|
+
* 获取picker标题
|
160
|
+
* @param {*} dpCode
|
161
|
+
*/
|
162
|
+
getRangeStrings(dpCode, schema) {
|
163
|
+
const result = {};
|
164
|
+
if (typeof schema === 'undefined') return result;
|
165
|
+
const lists = schema.range;
|
166
|
+
lists.map(v => {
|
167
|
+
const key = "dp_".concat(dpCode, "_").concat(v).toLowerCase();
|
168
|
+
result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
169
|
+
return null;
|
170
|
+
});
|
171
|
+
return result;
|
172
|
+
}
|
275
173
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
174
|
+
/**
|
175
|
+
* 开关倒计时转换为文案 time => 设备将在xxx后 关闭/开启
|
176
|
+
* 精确到分钟
|
177
|
+
* @param {*} t 倒计时剩余(秒)
|
178
|
+
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
179
|
+
*/
|
180
|
+
parseCountdown(t, power) {
|
181
|
+
const h = parseFloat("".concat(t / 3600));
|
182
|
+
const m = parseFloat("".concat(t / 60 - h * 60));
|
183
|
+
const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
184
|
+
const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
185
|
+
const time = h >= 1.0 ? "".concat(Math.round(h)).concat(tHour) : "".concat(Math.round(m)).concat(tMinute);
|
186
|
+
const key = "countdown_".concat(power ? 'on' : 'off');
|
187
|
+
const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
188
|
+
return this.formatString(str, time);
|
189
|
+
}
|
190
|
+
getFaultStrings(schema, faultCode, faultValue) {
|
191
|
+
let onlyPrior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
192
|
+
if (!faultValue) return '';
|
193
|
+
const {
|
194
|
+
label
|
195
|
+
} = schema;
|
196
|
+
const labels = [];
|
197
|
+
for (let i = 0; i < label.length; i++) {
|
198
|
+
const value = label[i];
|
199
|
+
const isExist = getBitValue(faultValue, i);
|
200
|
+
if (isExist) {
|
201
|
+
labels.push(this.getDpLang(faultCode, value));
|
202
|
+
if (onlyPrior) break;
|
280
203
|
}
|
281
|
-
|
282
|
-
return onlyPrior ? labels[0] : labels.join(', ');
|
283
204
|
}
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
}();
|
288
|
-
|
289
|
-
export { I18N as default };
|
205
|
+
return onlyPrior ? labels[0] : labels.join(', ');
|
206
|
+
}
|
207
|
+
}
|