@ray-js/ray-ipc-utils 1.1.3 → 1.1.5
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/lib/service/index.d.ts +1 -1
- package/lib/service/index.js +46 -30
- package/package.json +1 -1
package/lib/service/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const getIpcConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>
|
|
|
11
11
|
* 包含: 视频清晰度、对讲方式、拾音器、视频缩放最大倍数
|
|
12
12
|
* @param {string} deviceId 设备id
|
|
13
13
|
*/
|
|
14
|
-
export declare const getCameraConfigInfo: <T>(deviceId: string) => Promise<IRes<T>>;
|
|
14
|
+
export declare const getCameraConfigInfo: <T>(deviceId: string, type?: 'mini' | 'native') => Promise<IRes<T>>;
|
|
15
15
|
/**
|
|
16
16
|
* 获取IPC设备配置收藏点信息列表
|
|
17
17
|
* @param {string} deviceId 设备id
|
package/lib/service/index.js
CHANGED
|
@@ -102,7 +102,8 @@ export const getIpcConfigInfo = async deviceId => {
|
|
|
102
102
|
* @param {string} deviceId 设备id
|
|
103
103
|
*/
|
|
104
104
|
// eslint-disable-next-line consistent-return
|
|
105
|
-
export const getCameraConfigInfo = async deviceId
|
|
105
|
+
export const getCameraConfigInfo = async function (deviceId) {
|
|
106
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'native';
|
|
106
107
|
try {
|
|
107
108
|
const devInfo = await getDevInfo(deviceId);
|
|
108
109
|
if (devInfo.code !== 0) {
|
|
@@ -139,13 +140,15 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
139
140
|
|
|
140
141
|
const nativeStorageInfo = await Promise.all([`${deviceId}_resolution`, `${deviceId}_intercom`, `${deviceId}_microphone`, `${deviceId}_maxZoomSettings`].map(key => getNativeStorage(key)));
|
|
141
142
|
ipcTTTOperatorLog(`Utils: nativeStorageInfo: ${nativeStorageInfo}`);
|
|
142
|
-
console.log(nativeStorageInfo, 'nativeStorageInfo');
|
|
143
143
|
const [resolutionStorage, intercomStorage, microphoneStorage, maxZoomSettingsStorage] = nativeStorageInfo;
|
|
144
144
|
// 任意缓存为空,则请求接口
|
|
145
|
-
|
|
145
|
+
|
|
146
|
+
console.log(nativeStorageInfo, 'nativeStorageInfo');
|
|
147
|
+
const noCache = nativeStorageInfo.some(item => {
|
|
146
148
|
var _item$data;
|
|
147
149
|
return !(item !== null && item !== void 0 && (_item$data = item.data) !== null && _item$data !== void 0 && _item$data.data);
|
|
148
|
-
})
|
|
150
|
+
});
|
|
151
|
+
if (noCache) {
|
|
149
152
|
// 非虚拟机设备,请求接口
|
|
150
153
|
if (!isVirtualDevice) {
|
|
151
154
|
var _microphoneStorage$da, _intercomStorage$data, _resolutionStorage$da, _maxZoomSettingsStora;
|
|
@@ -175,12 +178,18 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
175
178
|
intercomInfo.defaultIntercomMode = intercomCallMode[supportedIntercomModes[0]];
|
|
176
179
|
intercomInfo.supportedIntercomModes = supportedIntercomModes.map(mode => intercomCallMode[mode]);
|
|
177
180
|
// 获取APP当前存储的对讲模式, 因目前设置页对讲设置使用的还是原生页面,需要读取APP缓存保持一致
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
+
|
|
182
|
+
if (type === 'native') {
|
|
183
|
+
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
184
|
+
if (appIntercomCached.code !== 0) {
|
|
185
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
|
|
186
|
+
} else {
|
|
187
|
+
var _appIntercomCached$da;
|
|
188
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da = appIntercomCached.data) === null || _appIntercomCached$da === void 0 ? void 0 : _appIntercomCached$da.talkbackMode];
|
|
189
|
+
}
|
|
181
190
|
} else {
|
|
182
|
-
|
|
183
|
-
intercomInfo.cachedIntercomMode = intercomCallMode[
|
|
191
|
+
// 针对mini程序,直接使用接口返回的第一项数据
|
|
192
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
|
|
184
193
|
}
|
|
185
194
|
}
|
|
186
195
|
|
|
@@ -192,6 +201,7 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
192
201
|
// 4. 最大倍数模块
|
|
193
202
|
maxZoomSettings = (rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes) !== 0 ? rtcApiResult === null || rtcApiResult === void 0 ? void 0 : rtcApiResult.maxZoomInTimes : 6;
|
|
194
203
|
}
|
|
204
|
+
|
|
195
205
|
// 由于utils为统一返回,多加了一层data,所以需要取data.data
|
|
196
206
|
// 1. 设置拾音器缓存
|
|
197
207
|
const microphoneStorageData = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da = microphoneStorage.data) === null || _microphoneStorage$da === void 0 ? void 0 : _microphoneStorage$da.data;
|
|
@@ -215,27 +225,43 @@ export const getCameraConfigInfo = async deviceId => {
|
|
|
215
225
|
if (!maxZoomSettingsStorageData) {
|
|
216
226
|
setNativeStorage(`${deviceId}_maxZoomSettings`, maxZoomSettings);
|
|
217
227
|
}
|
|
228
|
+
} else {
|
|
229
|
+
// 针对虚拟设备未有数据时设置缓存
|
|
230
|
+
setNativeStorage(`${deviceId}_microphone`, microphoneSettings);
|
|
231
|
+
if (type === 'native') {
|
|
232
|
+
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
233
|
+
// 如果接口返回成功,则取接口返回值
|
|
234
|
+
if (appIntercomCached.code === 0) {
|
|
235
|
+
var _appIntercomCached$da2;
|
|
236
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da2 = appIntercomCached.data) === null || _appIntercomCached$da2 === void 0 ? void 0 : _appIntercomCached$da2.talkbackMode];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
setNativeStorage(`${deviceId}_intercom`, intercomInfo);
|
|
240
|
+
setNativeStorage(`${deviceId}_resolution`, videoResolution);
|
|
241
|
+
setNativeStorage(`${deviceId}_maxZoomSettings`, maxZoomSettings);
|
|
218
242
|
}
|
|
219
243
|
} else {
|
|
220
244
|
var _intercomStorage$data2, _resolutionStorage$da2, _microphoneStorage$da2, _maxZoomSettingsStora2;
|
|
245
|
+
// 都有缓存的情况下,直接返回取缓存
|
|
221
246
|
// 对于对讲缓存的方式每次需从APP获取更新
|
|
222
247
|
const intercomStorageData = intercomStorage === null || intercomStorage === void 0 || (_intercomStorage$data2 = intercomStorage.data) === null || _intercomStorage$data2 === void 0 ? void 0 : _intercomStorage$data2.data;
|
|
223
248
|
intercomInfo = intercomStorageData;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
249
|
+
if (type === 'native') {
|
|
250
|
+
const appIntercomCached = await getCurrentSupportedTalkMode(deviceId);
|
|
251
|
+
if (appIntercomCached.code !== 0) {
|
|
252
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[supportedIntercomModes[0]];
|
|
253
|
+
} else {
|
|
254
|
+
var _appIntercomCached$da3;
|
|
255
|
+
intercomInfo.cachedIntercomMode = intercomCallMode[appIntercomCached === null || appIntercomCached === void 0 || (_appIntercomCached$da3 = appIntercomCached.data) === null || _appIntercomCached$da3 === void 0 ? void 0 : _appIntercomCached$da3.talkbackMode];
|
|
256
|
+
}
|
|
257
|
+
if (intercomStorageData.cachedIntercomMode !== intercomInfo.cachedIntercomMode) {
|
|
258
|
+
setNativeStorage(`${deviceId}_intercom`, intercomInfo);
|
|
259
|
+
}
|
|
233
260
|
}
|
|
234
261
|
videoResolution = resolutionStorage === null || resolutionStorage === void 0 || (_resolutionStorage$da2 = resolutionStorage.data) === null || _resolutionStorage$da2 === void 0 ? void 0 : _resolutionStorage$da2.data;
|
|
235
262
|
microphoneSettings = microphoneStorage === null || microphoneStorage === void 0 || (_microphoneStorage$da2 = microphoneStorage.data) === null || _microphoneStorage$da2 === void 0 ? void 0 : _microphoneStorage$da2.data;
|
|
236
263
|
maxZoomSettings = maxZoomSettingsStorage === null || maxZoomSettingsStorage === void 0 || (_maxZoomSettingsStora2 = maxZoomSettingsStorage.data) === null || _maxZoomSettingsStora2 === void 0 ? void 0 : _maxZoomSettingsStora2.data;
|
|
237
264
|
}
|
|
238
|
-
console.log(videoResolution, intercomInfo, microphoneSettings, maxZoomSettings, '_____');
|
|
239
265
|
const ipcConfig = {
|
|
240
266
|
videoResolution,
|
|
241
267
|
intercomInfo,
|
|
@@ -378,16 +404,6 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
|
|
|
378
404
|
};
|
|
379
405
|
}
|
|
380
406
|
const cruiseSwitchInfo = await getDpStateValue(deviceId, 'cruise_switch');
|
|
381
|
-
if ((cruiseSwitchInfo === null || cruiseSwitchInfo === void 0 ? void 0 : cruiseSwitchInfo.code) === -1) {
|
|
382
|
-
ty.showToast({
|
|
383
|
-
icon: 'error',
|
|
384
|
-
title: cruiseSwitchInfo.msg
|
|
385
|
-
});
|
|
386
|
-
return {
|
|
387
|
-
code: -1,
|
|
388
|
-
msg: cruiseSwitchInfo.msg
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
407
|
if (cruiseSwitchInfo.data) {
|
|
392
408
|
ty.showToast({
|
|
393
409
|
icon: 'error',
|
|
@@ -398,7 +414,7 @@ export const addCollectionPointsInfo = async (deviceId, name) => {
|
|
|
398
414
|
msg: Strings.getLang('ipc_utils_cruise_ing_tip')
|
|
399
415
|
};
|
|
400
416
|
}
|
|
401
|
-
// 2.
|
|
417
|
+
// 2. 获取收藏点 dpCode: memory_point_set
|
|
402
418
|
const memoryPointSetDpId = await getDpIdByCode(deviceId, 'memory_point_set');
|
|
403
419
|
if ((cruiseSwitchInfo === null || cruiseSwitchInfo === void 0 ? void 0 : cruiseSwitchInfo.code) === -1) {
|
|
404
420
|
ty.showToast({
|