@ray-js/api 1.5.0-beta.12 → 1.5.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/@types/BaseKit.d.ts +246 -126
- package/@types/BizKit.d.ts +1 -1
- package/@types/MapKit.d.ts +237 -1
- package/@types/MiniKit.d.ts +1 -1
- package/@types/OutdoorKit.d.ts +232 -0
- package/@types/P2PKit.d.ts +24 -2
- package/@types/all-kits.d.ts +1 -0
- package/@types/api-extend.d.ts +8 -2
- package/@types/index.d.ts +87 -0
- package/lib/{BaseKit-3.3.10.d.ts → BaseKit-3.11.0.d.ts} +1 -0
- package/lib/{BaseKit-3.3.10.js → BaseKit-3.11.0.js} +6 -2
- package/lib/BizKit-3.2.7.js +2 -1
- package/lib/DeviceKit-3.3.1.js +2 -1
- package/lib/HomeKit-3.1.4.js +2 -1
- package/lib/{MapKit-3.0.7.d.ts → MapKit-3.4.13.d.ts} +5 -0
- package/lib/{MapKit-3.0.7.js → MapKit-3.4.13.js} +19 -1
- package/lib/MiniKit-3.1.0.js +3 -2
- package/lib/OutdoorKit-1.0.4.d.ts +14 -0
- package/lib/OutdoorKit-1.0.4.js +39 -0
- package/lib/P2PKit-2.0.3.d.ts +1 -0
- package/lib/P2PKit-2.0.3.js +5 -1
- package/lib/PlayNetKit-1.1.3.d.ts +24 -25
- package/lib/PlayNetKit-1.1.3.js +2 -1
- package/lib/all-kits.d.ts +3 -2
- package/lib/all-kits.js +3 -2
- package/lib/cloud/alarm.js +2 -2
- package/lib/cloud/core.js +1 -1
- package/lib/cloud/device.d.ts +25 -1
- package/lib/cloud/device.js +20 -6
- package/lib/cloud/doorlock/README.md +62 -0
- package/lib/cloud/doorlock/auth.d.ts +235 -0
- package/lib/cloud/doorlock/auth.js +223 -0
- package/lib/cloud/doorlock/auth.md +323 -0
- package/lib/cloud/doorlock/device.d.ts +137 -0
- package/lib/cloud/doorlock/device.js +187 -0
- package/lib/cloud/doorlock/device.md +265 -0
- package/lib/cloud/doorlock/index.d.ts +10 -0
- package/lib/cloud/doorlock/index.js +20 -0
- package/lib/cloud/doorlock/log.d.ts +113 -0
- package/lib/cloud/doorlock/log.js +53 -0
- package/lib/cloud/doorlock/log.md +153 -0
- package/lib/cloud/doorlock/member-opmode.d.ts +121 -0
- package/lib/cloud/doorlock/member-opmode.js +104 -0
- package/lib/cloud/doorlock/member-opmode.md +279 -0
- package/lib/cloud/doorlock/member.d.ts +110 -0
- package/lib/cloud/doorlock/member.js +72 -0
- package/lib/cloud/doorlock/member.md +276 -0
- package/lib/cloud/doorlock/offline-pwd.d.ts +61 -0
- package/lib/cloud/doorlock/offline-pwd.js +67 -0
- package/lib/cloud/doorlock/offline-pwd.md +155 -0
- package/lib/cloud/doorlock/old.d.ts +36 -0
- package/lib/cloud/doorlock/old.js +102 -0
- package/lib/cloud/doorlock/temp-pwd.d.ts +194 -0
- package/lib/cloud/doorlock/temp-pwd.js +193 -0
- package/lib/cloud/doorlock/temp-pwd.md +362 -0
- package/lib/cloud/doorlock/unlock-method.d.ts +62 -0
- package/lib/cloud/doorlock/unlock-method.js +85 -0
- package/lib/cloud/doorlock/unlock-method.md +121 -0
- package/lib/cloud/doorlock/unlock.d.ts +89 -0
- package/lib/cloud/doorlock/unlock.js +76 -0
- package/lib/cloud/doorlock/unlock.md +222 -0
- package/lib/cloud/index.d.ts +4 -0
- package/lib/cloud/index.js +10 -1
- package/lib/cloud/interface.d.ts +39 -2
- package/lib/cloud/linkage.d.ts +8 -5
- package/lib/cloud/linkage.js +38 -17
- package/lib/cloud/outdoor.d.ts +15 -0
- package/lib/cloud/outdoor.js +25 -0
- package/lib/cloud/recipe/README.md +36 -0
- package/lib/cloud/recipe/basket.d.ts +220 -0
- package/lib/cloud/recipe/basket.js +328 -0
- package/lib/cloud/recipe/basket.md +431 -0
- package/lib/cloud/recipe/category-list.d.ts +71 -0
- package/lib/cloud/recipe/category-list.js +65 -0
- package/lib/cloud/recipe/category-list.md +132 -0
- package/lib/cloud/recipe/custom.d.ts +177 -0
- package/lib/cloud/recipe/custom.js +171 -0
- package/lib/cloud/recipe/custom.md +265 -0
- package/lib/cloud/recipe/index.d.ts +8 -0
- package/lib/cloud/recipe/index.js +8 -0
- package/lib/cloud/recipe/menu.d.ts +170 -0
- package/lib/cloud/recipe/menu.js +76 -0
- package/lib/cloud/recipe/menu.md +276 -0
- package/lib/cloud/recipe/query.d.ts +87 -0
- package/lib/cloud/recipe/query.js +101 -0
- package/lib/cloud/recipe/query.md +112 -0
- package/lib/cloud/recipe/record.d.ts +54 -0
- package/lib/cloud/recipe/record.js +87 -0
- package/lib/cloud/recipe/record.md +115 -0
- package/lib/cloud/recipe/score.d.ts +69 -0
- package/lib/cloud/recipe/score.js +106 -0
- package/lib/cloud/recipe/score.md +112 -0
- package/lib/cloud/recipe/star.d.ts +131 -0
- package/lib/cloud/recipe/star.js +151 -0
- package/lib/cloud/recipe/star.md +196 -0
- package/lib/cloud/recipe/types.d.ts +7 -0
- package/lib/cloud/recipe/types.js +0 -0
- package/lib/cloud/remoteGroup.d.ts +10 -0
- package/lib/cloud/remoteGroup.js +31 -0
- package/lib/cloud/statistic.js +9 -9
- package/lib/cloud/timer.js +14 -14
- package/lib/constants.js +1 -1
- package/lib/errorCode.d.ts +4 -0
- package/lib/errorCode.js +3 -0
- package/lib/getCdnUrl/index.d.ts +2 -2
- package/lib/getCdnUrl/index.js +1 -2
- package/lib/getCdnUrl/index.wechat.d.ts +2 -2
- package/lib/getCdnUrl/index.wechat.js +1 -2
- package/lib/getElementById/index.thing.js +1 -1
- package/lib/getElementById/index.wechat.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/nativeRouters/common.d.ts +15 -0
- package/lib/nativeRouters/common.js +38 -0
- package/lib/nativeRouters/device.d.ts +59 -0
- package/lib/nativeRouters/device.js +69 -0
- package/lib/nativeRouters/gw.d.ts +23 -0
- package/lib/nativeRouters/gw.js +27 -0
- package/lib/nativeRouters/index.d.ts +6 -1
- package/lib/nativeRouters/index.js +6 -1
- package/lib/nativeRouters/ipc.d.ts +30 -0
- package/lib/nativeRouters/ipc.js +44 -0
- package/lib/nativeRouters/outdoors.d.ts +47 -0
- package/lib/nativeRouters/outdoors.js +41 -0
- package/lib/nativeRouters/remoteGroup.d.ts +22 -0
- package/lib/nativeRouters/remoteGroup.js +11 -0
- package/lib/nativeRouters/root.d.ts +41 -0
- package/lib/nativeRouters/root.js +53 -0
- package/lib/openGroupCreate/index.js +3 -3
- package/lib/panel/i18n/index.d.ts +7 -6
- package/lib/panel/i18n/index.js +39 -23
- package/lib/panel/i18n/index.wechat.js +13 -12
- package/lib/panel/normalizeNetwork.js +1 -1
- package/lib/panel/publishDps.js +1 -1
- package/lib/redirectTo/index.js +1 -0
- package/lib/utils.d.ts +5 -2
- package/lib/utils.js +46 -20
- package/lib/utils.wechat.d.ts +3 -0
- package/lib/utils.wechat.js +22 -6
- package/lib/viewAPI.d.ts +1 -0
- package/lib/viewAPI.js +4 -3
- package/package.json +8 -7
- package/@types/PlayNetKit.d.ts +0 -444
- package/lib/nativeRouters/scene.d.ts +0 -34
- package/lib/nativeRouters/scene.js +0 -60
@@ -0,0 +1,41 @@
|
|
1
|
+
import { ICommon } from './common';
|
2
|
+
type OpenAppScanParams = {
|
3
|
+
gwId?: string;
|
4
|
+
source?: string;
|
5
|
+
} & ICommon;
|
6
|
+
/**
|
7
|
+
* 打开APP扫码
|
8
|
+
* @param params {gwId: string, source: string}
|
9
|
+
* @returns
|
10
|
+
*/
|
11
|
+
export declare function openAppScan(params?: OpenAppScanParams): Promise<void>;
|
12
|
+
type OpenHelpAndFeedback = {} & ICommon;
|
13
|
+
/**
|
14
|
+
* 打开帮助与反馈
|
15
|
+
* @param params { }
|
16
|
+
* @returns
|
17
|
+
*/
|
18
|
+
export declare function openHelpAndFeedback(params?: OpenHelpAndFeedback): Promise<void>;
|
19
|
+
type OpenMoreService = {} & ICommon;
|
20
|
+
/**
|
21
|
+
* 跳转到更多服务
|
22
|
+
*/
|
23
|
+
export declare function openMoreService(params?: OpenMoreService): Promise<void>;
|
24
|
+
type OpenAppHelpCenter = {} & ICommon;
|
25
|
+
/**
|
26
|
+
* 跳转到App帮助与反馈页
|
27
|
+
*/
|
28
|
+
export declare function openAppHelpCenter(params?: OpenAppHelpCenter): Promise<void>;
|
29
|
+
type OpenMessageCenter = {
|
30
|
+
category?: 0 | 1 | 2;
|
31
|
+
} & ICommon;
|
32
|
+
/**
|
33
|
+
* 跳转到消息中心
|
34
|
+
*/
|
35
|
+
export declare function openMessageCenter(params?: OpenMessageCenter): Promise<void>;
|
36
|
+
type OpenCompleteUserInfo = {} & ICommon;
|
37
|
+
/**
|
38
|
+
* 完善用户信息
|
39
|
+
*/
|
40
|
+
export declare function openCompleteUserInfo(params?: OpenCompleteUserInfo): Promise<void>;
|
41
|
+
export {};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { nativeRouter } from './common';
|
2
|
+
/**
|
3
|
+
* 打开APP扫码
|
4
|
+
* @param params {gwId: string, source: string}
|
5
|
+
* @returns
|
6
|
+
*/
|
7
|
+
export function openAppScan(params) {
|
8
|
+
return nativeRouter('scan', params);
|
9
|
+
}
|
10
|
+
/**
|
11
|
+
* 打开帮助与反馈
|
12
|
+
* @param params { }
|
13
|
+
* @returns
|
14
|
+
*/
|
15
|
+
export function openHelpAndFeedback(params) {
|
16
|
+
return nativeRouter('helpAndFeedBack', params);
|
17
|
+
}
|
18
|
+
|
19
|
+
// more_service
|
20
|
+
|
21
|
+
/**
|
22
|
+
* 跳转到更多服务
|
23
|
+
*/
|
24
|
+
export function openMoreService(params) {
|
25
|
+
return nativeRouter('more_service', params);
|
26
|
+
}
|
27
|
+
|
28
|
+
// helpCenter
|
29
|
+
|
30
|
+
/**
|
31
|
+
* 跳转到App帮助与反馈页
|
32
|
+
*/
|
33
|
+
export function openAppHelpCenter(params) {
|
34
|
+
return nativeRouter('helpCenter', params);
|
35
|
+
}
|
36
|
+
|
37
|
+
// messageCenter
|
38
|
+
|
39
|
+
/**
|
40
|
+
* 跳转到消息中心
|
41
|
+
*/
|
42
|
+
export function openMessageCenter(params) {
|
43
|
+
return nativeRouter('messageCenter', params);
|
44
|
+
}
|
45
|
+
|
46
|
+
// 完善用户信息 complete_user_information
|
47
|
+
|
48
|
+
/**
|
49
|
+
* 完善用户信息
|
50
|
+
*/
|
51
|
+
export function openCompleteUserInfo(params) {
|
52
|
+
return nativeRouter('complete_user_information', params);
|
53
|
+
}
|
@@ -24,15 +24,15 @@ export function openGroupCreate(params) {
|
|
24
24
|
}
|
25
25
|
}, rest), {}, {
|
26
26
|
success() {
|
27
|
-
success === null || success === void 0
|
27
|
+
success === null || success === void 0 || success();
|
28
28
|
resolve();
|
29
29
|
},
|
30
30
|
fail(err) {
|
31
|
-
fail === null || fail === void 0
|
31
|
+
fail === null || fail === void 0 || fail(err);
|
32
32
|
reject(err);
|
33
33
|
},
|
34
34
|
complete() {
|
35
|
-
complete === null || complete === void 0
|
35
|
+
complete === null || complete === void 0 || complete();
|
36
36
|
}
|
37
37
|
}));
|
38
38
|
});
|
@@ -1,27 +1,28 @@
|
|
1
1
|
type LanguageMap = {
|
2
2
|
[key: string]: Record<string, string>;
|
3
3
|
};
|
4
|
-
export
|
4
|
+
export declare const updateI18n: (data: LanguageMap) => void;
|
5
|
+
export default class I18N<LanMap extends LanguageMap, Lan extends LanMap[keyof LanMap] = LanMap[keyof LanMap]> {
|
5
6
|
[x: string]: any;
|
6
|
-
strings:
|
7
|
+
strings: LanMap;
|
7
8
|
defaultLang: string;
|
8
9
|
__language: string;
|
9
|
-
constructor(props:
|
10
|
+
constructor(props: LanMap);
|
10
11
|
forceUpdateNetworkLang(productId: string): void;
|
11
|
-
mergeLanguage(L1: LanguageMap, L2: LanguageMap):
|
12
|
+
mergeLanguage(L1: LanguageMap, L2: LanguageMap): any;
|
12
13
|
isZh(language: string): boolean;
|
13
14
|
setLanguage(language: string): void;
|
14
15
|
buildLanguage(language: string): void;
|
15
16
|
_getBestMatchingLanguage(language: string, props: LanguageMap): any;
|
16
17
|
formatString(str: string, ...values: any[]): string;
|
17
|
-
formatValue(key:
|
18
|
+
formatValue(key: keyof Lan, ...values: any[]): any;
|
18
19
|
_replaceAll(find: string, replace: string, str: string): string;
|
19
20
|
getDpLang(code: string | number, value?: undefined | boolean | string): any;
|
20
21
|
getDpName(code: string, defaultName: string): any;
|
21
22
|
getDpsLang(key: {
|
22
23
|
[key: string]: string;
|
23
24
|
}): {};
|
24
|
-
getLang(key:
|
25
|
+
getLang(key: keyof Lan, defaultString?: string): any;
|
25
26
|
/**
|
26
27
|
* 获取picker标题
|
27
28
|
* @param {*} dpCode
|
package/lib/panel/i18n/index.js
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
1
2
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
2
3
|
import { getBitValue } from '../utils';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* I18n 智能小程序中用来获取多语言的对象
|
7
|
+
* 文档: https://developer.tuya.com/cn/miniapp/framework/app/i18n
|
8
|
+
*/
|
9
|
+
|
10
|
+
export const updateI18n = () => {
|
11
|
+
// 微信小程序中使用的方法,这里不需要实现
|
12
|
+
};
|
13
|
+
function hasKey(key) {
|
14
|
+
if (typeof I18n.has === 'function') {
|
15
|
+
return I18n.has(key);
|
16
|
+
}
|
17
|
+
return I18n.t(key) !== key;
|
18
|
+
}
|
3
19
|
export default class I18N {
|
4
20
|
constructor(props) {
|
5
21
|
this.strings = this.mergeLanguage(props, {});
|
@@ -10,7 +26,7 @@ export default class I18N {
|
|
10
26
|
}
|
11
27
|
forceUpdateNetworkLang(productId) {
|
12
28
|
requestCloud({
|
13
|
-
api:
|
29
|
+
api: "".concat(THING, ".m.i18n.get"),
|
14
30
|
version: '1.0',
|
15
31
|
data: {
|
16
32
|
productId,
|
@@ -101,14 +117,14 @@ export default class I18N {
|
|
101
117
|
formatString(str) {
|
102
118
|
let res = str;
|
103
119
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
104
|
-
res = this._replaceAll(
|
120
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
105
121
|
}
|
106
122
|
return res;
|
107
123
|
}
|
108
124
|
formatValue(key) {
|
109
|
-
let res =
|
125
|
+
let res = this.getLang(key);
|
110
126
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
111
|
-
res = this._replaceAll(
|
127
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
112
128
|
}
|
113
129
|
return res;
|
114
130
|
}
|
@@ -121,37 +137,37 @@ export default class I18N {
|
|
121
137
|
getDpLang(code, value) {
|
122
138
|
let key;
|
123
139
|
if (typeof value === 'undefined') {
|
124
|
-
key =
|
140
|
+
key = "dp_".concat(code).toLowerCase();
|
125
141
|
} else if (typeof value === 'boolean') {
|
126
142
|
const valStr = value ? 'on' : 'off';
|
127
|
-
key =
|
143
|
+
key = "dp_".concat(code, "_").concat(valStr).toLowerCase();
|
128
144
|
} else {
|
129
|
-
key =
|
145
|
+
key = "dp_".concat(code, "_").concat(value).toLowerCase();
|
130
146
|
}
|
131
|
-
return
|
147
|
+
return hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
132
148
|
}
|
133
149
|
getDpName(code, defaultName) {
|
134
|
-
const key =
|
135
|
-
return
|
150
|
+
const key = "dp_".concat(code).toLowerCase();
|
151
|
+
return hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
136
152
|
}
|
137
153
|
getDpsLang(key) {
|
138
154
|
let strs = {};
|
139
155
|
if (typeof key === 'object') {
|
140
156
|
if (typeof key.strKey === 'string') {
|
141
|
-
strs =
|
157
|
+
strs = hasKey(key.strKey) ? I18n.t(key.strKey) : typeof this[key.strKey] !== 'undefined' ? this[key.strKey] : I18n.t(key.strKey);
|
142
158
|
} else {
|
143
159
|
Object.keys(key).map(i => {
|
144
|
-
strs[key[i]] =
|
160
|
+
strs[key[i]] = hasKey(key[i]) ? I18n.t(key[i]) : typeof this[key[i]] !== 'undefined' ? this[key[i]] : I18n.t(key[i]);
|
145
161
|
return null;
|
146
162
|
});
|
147
163
|
}
|
148
164
|
} else {
|
149
|
-
strs =
|
165
|
+
strs = hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
150
166
|
}
|
151
167
|
return strs;
|
152
168
|
}
|
153
169
|
getLang(key, defaultString) {
|
154
|
-
return
|
170
|
+
return hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : typeof defaultString !== 'undefined' ? defaultString : I18n.t(key);
|
155
171
|
}
|
156
172
|
|
157
173
|
/**
|
@@ -163,8 +179,8 @@ export default class I18N {
|
|
163
179
|
if (typeof schema === 'undefined') return result;
|
164
180
|
const lists = schema.range;
|
165
181
|
lists.map(v => {
|
166
|
-
const key =
|
167
|
-
result[v] =
|
182
|
+
const key = "dp_".concat(dpCode, "_").concat(v).toLowerCase();
|
183
|
+
result[v] = hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
168
184
|
return null;
|
169
185
|
});
|
170
186
|
return result;
|
@@ -177,13 +193,13 @@ export default class I18N {
|
|
177
193
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
178
194
|
*/
|
179
195
|
parseCountdown(t, power) {
|
180
|
-
const h = parseFloat(
|
181
|
-
const m = parseFloat(
|
182
|
-
const tHour =
|
183
|
-
const tMinute =
|
184
|
-
const time = h >= 1.0 ?
|
185
|
-
const key =
|
186
|
-
const str =
|
196
|
+
const h = parseFloat("".concat(t / 3600));
|
197
|
+
const m = parseFloat("".concat(t / 60 - h * 60));
|
198
|
+
const tHour = hasKey('t_hour') ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
199
|
+
const tMinute = hasKey('t_minute') ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
200
|
+
const time = h >= 1.0 ? "".concat(Math.round(h)).concat(tHour) : "".concat(Math.round(m)).concat(tMinute);
|
201
|
+
const key = "countdown_".concat(power ? 'on' : 'off');
|
202
|
+
const str = hasKey(key) ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
187
203
|
return this.formatString(str, time);
|
188
204
|
}
|
189
205
|
getFaultStrings(schema, faultCode, faultValue) {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import "core-js/modules/es.string.replace.js";
|
1
2
|
import { requestCloud, getSystemInfoSync, THING } from '../..';
|
2
3
|
import { getBitValue } from '../utils';
|
3
4
|
|
@@ -15,7 +16,7 @@ export default class I18N {
|
|
15
16
|
}
|
16
17
|
forceUpdateNetworkLang(productId) {
|
17
18
|
requestCloud({
|
18
|
-
api:
|
19
|
+
api: "".concat(THING, ".m.i18n.get"),
|
19
20
|
version: '1.0',
|
20
21
|
data: {
|
21
22
|
productId,
|
@@ -106,14 +107,14 @@ export default class I18N {
|
|
106
107
|
formatString(str) {
|
107
108
|
let res = str;
|
108
109
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
109
|
-
res = this._replaceAll(
|
110
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
110
111
|
}
|
111
112
|
return res;
|
112
113
|
}
|
113
114
|
formatValue(key) {
|
114
115
|
let res = typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
115
116
|
for (let i = 0; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
|
116
|
-
res = this._replaceAll(
|
117
|
+
res = this._replaceAll("{".concat(i, "}"), i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1], res);
|
117
118
|
}
|
118
119
|
return res;
|
119
120
|
}
|
@@ -126,17 +127,17 @@ export default class I18N {
|
|
126
127
|
getDpLang(code, value) {
|
127
128
|
let key;
|
128
129
|
if (typeof value === 'undefined') {
|
129
|
-
key =
|
130
|
+
key = "dp_".concat(code).toLowerCase();
|
130
131
|
} else if (typeof value === 'boolean') {
|
131
132
|
const valStr = value ? 'on' : 'off';
|
132
|
-
key =
|
133
|
+
key = "dp_".concat(code, "_").concat(valStr).toLowerCase();
|
133
134
|
} else {
|
134
|
-
key =
|
135
|
+
key = "dp_".concat(code, "_").concat(value).toLowerCase();
|
135
136
|
}
|
136
137
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
137
138
|
}
|
138
139
|
getDpName(code, defaultName) {
|
139
|
-
const key =
|
140
|
+
const key = "dp_".concat(code).toLowerCase();
|
140
141
|
return I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : defaultName;
|
141
142
|
}
|
142
143
|
getDpsLang(key) {
|
@@ -168,7 +169,7 @@ export default class I18N {
|
|
168
169
|
if (typeof schema === 'undefined') return result;
|
169
170
|
const lists = schema.range;
|
170
171
|
lists.map(v => {
|
171
|
-
const key =
|
172
|
+
const key = "dp_".concat(dpCode, "_").concat(v).toLowerCase();
|
172
173
|
result[v] = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
173
174
|
return null;
|
174
175
|
});
|
@@ -182,12 +183,12 @@ export default class I18N {
|
|
182
183
|
* @param {*} power 设备当前的开关状态 (如果当前设备为开启状态, 则倒计时显示为关闭)
|
183
184
|
*/
|
184
185
|
parseCountdown(t, power) {
|
185
|
-
const h = parseFloat(
|
186
|
-
const m = parseFloat(
|
186
|
+
const h = parseFloat("".concat(t / 3600));
|
187
|
+
const m = parseFloat("".concat(t / 60 - h * 60));
|
187
188
|
const tHour = I18n.t('t_hour') !== 't_hour' ? I18n.t('t_hour') : typeof this.t_hour !== 'undefined' ? this.t_hour : I18n.t('t_hour');
|
188
189
|
const tMinute = I18n.t('t_minute') !== 't_minute' ? I18n.t('t_minute') : typeof this.t_minute !== 'undefined' ? this.t_minute : I18n.t('t_minute');
|
189
|
-
const time = h >= 1.0 ?
|
190
|
-
const key =
|
190
|
+
const time = h >= 1.0 ? "".concat(Math.round(h)).concat(tHour) : "".concat(Math.round(m)).concat(tMinute);
|
191
|
+
const key = "countdown_".concat(power ? 'on' : 'off');
|
191
192
|
const str = I18n.t(key) !== key ? I18n.t(key) : typeof this[key] !== 'undefined' ? this[key] : I18n.t(key);
|
192
193
|
return this.formatString(str, time);
|
193
194
|
}
|
@@ -11,7 +11,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
11
11
|
export function normalizeNetwork(network, data) {
|
12
12
|
var _result$networkType;
|
13
13
|
const result = _objectSpread(_objectSpread({}, network), data);
|
14
|
-
const networkType = result === null || result === void 0
|
14
|
+
const networkType = result === null || result === void 0 || (_result$networkType = result.networkType) === null || _result$networkType === void 0 ? void 0 : _result$networkType.toUpperCase();
|
15
15
|
result.networkType = networkType;
|
16
16
|
if (typeof result.isConnected === 'undefined') {
|
17
17
|
result.isConnected = networkType !== 'NONE';
|
package/lib/panel/publishDps.js
CHANGED
@@ -25,7 +25,7 @@ export function sendDps(data) {
|
|
25
25
|
const codeIds = (devInfo === null || devInfo === void 0 ? void 0 : devInfo.codeIds) || {};
|
26
26
|
Object.keys(data).forEach(code => {
|
27
27
|
if (codeIds[code] !== undefined) {
|
28
|
-
dps[
|
28
|
+
dps["".concat(codeIds[code])] = data[code];
|
29
29
|
} else {
|
30
30
|
dps[code] = data[code];
|
31
31
|
}
|
package/lib/redirectTo/index.js
CHANGED
package/lib/utils.d.ts
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
import { UrlObject } from 'query-string';
|
1
2
|
type Opts = {
|
2
3
|
deprecated?: boolean;
|
3
4
|
namespace?: string;
|
4
5
|
};
|
6
|
+
export declare function createFactory(kitName: string): (name: string, opts?: Opts) => () => any;
|
5
7
|
export declare function factory(name: string, opts?: Opts): () => any;
|
6
|
-
export declare function
|
7
|
-
export declare
|
8
|
+
export declare function factoryConstants(name: string, opts?: Opts): any;
|
9
|
+
export declare const parseUrl: (url: string) => import("query-string").ParsedUrl;
|
10
|
+
export declare const stringifyUrl: (object: UrlObject) => string;
|
8
11
|
export {};
|
package/lib/utils.js
CHANGED
@@ -1,41 +1,67 @@
|
|
1
|
+
import { parseUrl as _parseUrl, stringifyUrl as _stringifyUrl } from 'query-string';
|
2
|
+
export function createFactory(kitName) {
|
3
|
+
return function (name) {
|
4
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5
|
+
return function () {
|
6
|
+
var _inst$opts$namespace;
|
7
|
+
const methodName = "ty.".concat(opts.namespace ? opts.namespace + '.' : '').concat(name);
|
8
|
+
if (opts.deprecated) {
|
9
|
+
console.warn("\"".concat(methodName, "\" method has been deprecated."));
|
10
|
+
}
|
11
|
+
const inst = typeof ty === 'undefined' ? {} : ty;
|
12
|
+
const method = opts.namespace ? ((_inst$opts$namespace = inst[opts.namespace]) !== null && _inst$opts$namespace !== void 0 ? _inst$opts$namespace : {})[name] : inst[name];
|
13
|
+
if (!method) {
|
14
|
+
console.warn('tips:', "\"".concat(methodName, "\" method not exits."));
|
15
|
+
console.warn('tips:', "Please check kit \"".concat(kitName, "\" dependency is enabled."));
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
// eslint-disable-next-line prefer-rest-params
|
19
|
+
return method.apply(this, arguments);
|
20
|
+
};
|
21
|
+
};
|
22
|
+
}
|
1
23
|
export function factory(name) {
|
2
24
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
3
25
|
return function () {
|
4
|
-
var _inst$opts$
|
26
|
+
var _inst$opts$namespace2;
|
27
|
+
const methodName = "ty.".concat(opts.namespace ? opts.namespace + '.' : '').concat(name);
|
5
28
|
if (opts.deprecated) {
|
6
|
-
console.warn(
|
29
|
+
console.warn("\"".concat(methodName, "\" method has been deprecated."));
|
7
30
|
}
|
8
31
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
9
|
-
const method = opts.namespace ? ((_inst$opts$
|
32
|
+
const method = opts.namespace ? ((_inst$opts$namespace2 = inst[opts.namespace]) !== null && _inst$opts$namespace2 !== void 0 ? _inst$opts$namespace2 : {})[name] : inst[name];
|
10
33
|
if (!method) {
|
11
|
-
console.warn(
|
34
|
+
console.warn('tips:', "\"".concat(methodName, "\" method not exits."));
|
12
35
|
return;
|
13
36
|
}
|
37
|
+
// eslint-disable-next-line prefer-rest-params
|
14
38
|
return method.apply(this, arguments);
|
15
39
|
};
|
16
40
|
}
|
17
|
-
export function
|
41
|
+
export function factoryConstants(name) {
|
18
42
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
19
43
|
if (opts.deprecated) {
|
20
|
-
console.warn(
|
44
|
+
console.warn("\"ty.".concat(name, "\" constant has been deprecated."));
|
21
45
|
}
|
22
46
|
const inst = typeof ty === 'undefined' ? {} : ty;
|
23
47
|
if (!inst[name]) {
|
24
|
-
console.warn(
|
48
|
+
console.warn('tips', "\"ty.".concat(name, "\" constant not exits."));
|
25
49
|
return;
|
26
50
|
}
|
27
51
|
return inst[name];
|
28
52
|
}
|
29
|
-
export
|
30
|
-
|
31
|
-
|
32
|
-
//
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
53
|
+
export const parseUrl = url => {
|
54
|
+
return _parseUrl(url, {
|
55
|
+
arrayFormat: 'bracket',
|
56
|
+
// WARN: 这里的参数与微信不一致, 但是无法进行修改了, 存量的项目已经在使用
|
57
|
+
// 例如 url=encodeURIComponent('https://www.baidu.com?name=1&age=2') 在微信中不会进行 decode
|
58
|
+
// 而在涂鸦小程序上会进行 decode, 这里是需要注意的地方
|
59
|
+
decode: true
|
60
|
+
});
|
61
|
+
};
|
62
|
+
export const stringifyUrl = object => {
|
63
|
+
return _stringifyUrl(object, {
|
64
|
+
arrayFormat: 'bracket',
|
65
|
+
encode: true
|
66
|
+
});
|
67
|
+
};
|
package/lib/utils.wechat.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { UrlObject } from 'query-string';
|
1
2
|
type Opts = {
|
2
3
|
deprecated?: boolean;
|
3
4
|
namespace?: string;
|
@@ -7,4 +8,6 @@ export declare function factory(name: string, opts?: Opts): (option: {
|
|
7
8
|
data?: any;
|
8
9
|
}) => any;
|
9
10
|
export declare function factoryContants(name: string, opts?: Opts): any;
|
11
|
+
export declare const parseUrl: (url: string) => import("query-string").ParsedUrl;
|
12
|
+
export declare const stringifyUrl: (object: UrlObject) => string;
|
10
13
|
export {};
|
package/lib/utils.wechat.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
// @ts-ignore
|
2
2
|
import * as tyWx from '@ray-js/wechat';
|
3
|
+
import { stringifyUrl as _stringifyUrl, parseUrl as _parseUrl } from 'query-string';
|
3
4
|
export function factory(name) {
|
4
5
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5
6
|
if (/(set|get|remove|clear)+Storage(Sync)?$/.test(name)) {
|
6
7
|
return function (option) {
|
7
8
|
if (opts.deprecated) {
|
8
|
-
console.warn(
|
9
|
+
console.warn("\u8BE5\u65B9\u6CD5 ".concat(name, " \u5DF2\u5F03\u7528"));
|
9
10
|
}
|
10
11
|
// eslint-disable-next-line prefer-rest-params
|
11
12
|
return wx[name].call(this, option.key, option.data);
|
@@ -13,10 +14,10 @@ export function factory(name) {
|
|
13
14
|
}
|
14
15
|
return function () {
|
15
16
|
if (opts.deprecated) {
|
16
|
-
console.warn(
|
17
|
+
console.warn("\u8BE5\u65B9\u6CD5 ".concat(name, " \u5DF2\u5F03\u7528"));
|
17
18
|
}
|
18
19
|
if (!tyWx[name] && !wx[name]) {
|
19
|
-
console.warn(
|
20
|
+
console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u65B9\u6CD5 wx.".concat(name));
|
20
21
|
return;
|
21
22
|
}
|
22
23
|
// 优先取得 TTT 能力的方法
|
@@ -30,12 +31,27 @@ export function factory(name) {
|
|
30
31
|
export function factoryContants(name) {
|
31
32
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
32
33
|
if (opts.deprecated) {
|
33
|
-
console.warn(
|
34
|
+
console.warn("\u8BE5\u53D8\u91CF ".concat(name, " \u5DF2\u5F03\u7528"));
|
34
35
|
}
|
35
36
|
const inst = typeof wx === 'undefined' ? {} : wx;
|
36
37
|
if (!inst[name]) {
|
37
|
-
console.warn(
|
38
|
+
console.warn("// TODO \u6682\u672A\u5B9E\u73B0\u53D8\u91CF ".concat(name));
|
38
39
|
return;
|
39
40
|
}
|
40
41
|
return inst[name];
|
41
|
-
}
|
42
|
+
}
|
43
|
+
export const parseUrl = url => {
|
44
|
+
return _parseUrl(url, {
|
45
|
+
arrayFormat: 'bracket',
|
46
|
+
// WARN: 这里的参数与微信不一致, 但是无法进行修改了, 存量的项目已经在使用
|
47
|
+
// 例如 url=encodeURIComponent('https://www.baidu.com?name=1&age=2') 在微信中不会进行 decode
|
48
|
+
// 而在涂鸦小程序上会进行 decode, 这里是需要注意的地方
|
49
|
+
decode: true
|
50
|
+
});
|
51
|
+
};
|
52
|
+
export const stringifyUrl = object => {
|
53
|
+
return _stringifyUrl(object, {
|
54
|
+
arrayFormat: 'bracket',
|
55
|
+
encode: true
|
56
|
+
});
|
57
|
+
};
|
package/lib/viewAPI.d.ts
CHANGED
@@ -12,3 +12,4 @@ export declare const createNativeVideoContext: typeof ty.createNativeVideoContex
|
|
12
12
|
export declare const createMapContext: typeof ty.createMapContext;
|
13
13
|
export declare const createIpcPlayerContext: typeof ty.createIpcPlayerContext;
|
14
14
|
export declare const createCameraContext: typeof ty.createCameraContext;
|
15
|
+
export declare const createWebviewContext: typeof ty.createWebviewContext;
|
package/lib/viewAPI.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference path="../@types/api.d.ts" />
|
2
2
|
|
3
|
-
import { factory,
|
4
|
-
export const env =
|
3
|
+
import { factory, factoryConstants } from './utils';
|
4
|
+
export const env = factoryConstants('env');
|
5
5
|
export const createAnimation = factory('createAnimation');
|
6
6
|
export const pageScrollTo = factory('pageScrollTo');
|
7
7
|
export const createSelectorQuery = factory('createSelectorQuery');
|
@@ -13,4 +13,5 @@ export const createVideoContext = factory('createVideoContext');
|
|
13
13
|
export const createNativeVideoContext = factory('createNativeVideoContext');
|
14
14
|
export const createMapContext = factory('createMapContext');
|
15
15
|
export const createIpcPlayerContext = factory('createIpcPlayerContext');
|
16
|
-
export const createCameraContext = factory('createCameraContext');
|
16
|
+
export const createCameraContext = factory('createCameraContext');
|
17
|
+
export const createWebviewContext = factory('createWebviewContext');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/api",
|
3
|
-
"version": "1.5.
|
3
|
+
"version": "1.5.1",
|
4
4
|
"description": "Ray universal api",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -29,13 +29,14 @@
|
|
29
29
|
"watch": "ray start --type=component"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@ray-js/framework": "
|
33
|
-
"@ray-js/router": "
|
34
|
-
"@ray-js/wechat": "^0.
|
35
|
-
"base64-browser": "^1.0.1"
|
32
|
+
"@ray-js/framework": "1.5.1",
|
33
|
+
"@ray-js/router": "1.5.1",
|
34
|
+
"@ray-js/wechat": "^0.2.9",
|
35
|
+
"base64-browser": "^1.0.1",
|
36
|
+
"query-string": "^7.1.3"
|
36
37
|
},
|
37
38
|
"devDependencies": {
|
38
|
-
"@ray-js/cli": "
|
39
|
+
"@ray-js/cli": "1.5.1",
|
39
40
|
"art-template": "^4.13.2",
|
40
41
|
"fs-extra": "^10.1.0",
|
41
42
|
"miniprogram-api-typings": "^3.12.2",
|
@@ -45,5 +46,5 @@
|
|
45
46
|
"access": "public",
|
46
47
|
"registry": "https://registry.npmjs.org"
|
47
48
|
},
|
48
|
-
"gitHead": "
|
49
|
+
"gitHead": "c72417d2eda79e7cb4a0ae547e0483eb72d6330f"
|
49
50
|
}
|