@ray-js/ipc-player-integration 0.0.1-beta-17 → 0.0.1-beta-19

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.
@@ -8,9 +8,10 @@ export const useBattery = devId => {
8
8
  dpCodes: [POWER_MODE_DP_CODE, POWER_VALUE_DP_CODE]
9
9
  });
10
10
  const batteryInfo = useMemo(() => {
11
+ // 如果电量dp不存在
11
12
  return {
12
- batteryValue: dpState[POWER_VALUE_DP_CODE] || 0,
13
- batteryCharging: dpState[POWER_MODE_DP_CODE] || false
13
+ batteryValue: dpState[POWER_VALUE_DP_CODE],
14
+ batteryCharging: dpState[POWER_MODE_DP_CODE]
14
15
  };
15
16
  }, [dpState]);
16
17
  return batteryInfo;
@@ -1,15 +1,20 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { useDpState } from '../useDpState';
3
3
  import { SENSOR_HUMIDITY } from '../../utils/content/dpCode';
4
+ import { showMathPowValue } from '../../utils/device';
4
5
  export const useHumidity = devId => {
5
6
  const [humidity, setHumidity] = useState('');
6
- const [dpState] = useDpState({
7
+ const [dpState, schemaObj] = useDpState({
7
8
  devId,
8
9
  dpCodes: [SENSOR_HUMIDITY]
9
10
  });
10
11
  useEffect(() => {
11
12
  if (dpState[SENSOR_HUMIDITY] !== undefined) {
12
- setHumidity(dpState[SENSOR_HUMIDITY] + '%');
13
+ var _schema$property;
14
+ const schema = schemaObj && schemaObj[SENSOR_HUMIDITY];
15
+ const scale = (schema === null || schema === void 0 || (_schema$property = schema.property) === null || _schema$property === void 0 ? void 0 : _schema$property.scale) || 0;
16
+ const value = showMathPowValue(dpState[SENSOR_HUMIDITY], scale);
17
+ setHumidity(value + '%');
13
18
  }
14
19
  }, [dpState]);
15
20
  return humidity;
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { TEMP_REPORT_F, TEMP_UNIT_SELECT, SENSOR_TEMPERATURE } from '../../utils/content/dpCode';
3
3
  import { useDpState } from '../useDpState';
4
+ import { showMathPowValue } from '../../utils/device';
4
5
  export const useTemperature = devId => {
5
6
  const [tempUnit, setTempUnit] = useState('');
6
7
  const [tempC, setTempC] = useState('');
7
8
  const [tempF, setTempF] = useState('');
8
- const [dpState] = useDpState({
9
+ const [dpState, schemaObj] = useDpState({
9
10
  devId,
10
11
  dpCodes: [TEMP_UNIT_SELECT, SENSOR_TEMPERATURE, TEMP_REPORT_F]
11
12
  });
@@ -15,10 +16,18 @@ export const useTemperature = devId => {
15
16
  setTempUnit(dpState[TEMP_UNIT_SELECT] + '');
16
17
  }
17
18
  if (dpState[SENSOR_TEMPERATURE] !== undefined) {
18
- setTempC(dpState[SENSOR_TEMPERATURE] + '°C');
19
+ var _schema$property;
20
+ const schema = schemaObj && schemaObj[SENSOR_TEMPERATURE];
21
+ const scale = (schema === null || schema === void 0 || (_schema$property = schema.property) === null || _schema$property === void 0 ? void 0 : _schema$property.scale) || 0;
22
+ const value = showMathPowValue(dpState[SENSOR_TEMPERATURE], scale);
23
+ setTempC(value + '°C');
19
24
  }
20
25
  if (dpState[TEMP_REPORT_F] !== undefined) {
21
- setTempF(dpState[TEMP_REPORT_F] + '°F');
26
+ var _schema$property2;
27
+ const schema = schemaObj && schemaObj[TEMP_REPORT_F];
28
+ const scale = (schema === null || schema === void 0 || (_schema$property2 = schema.property) === null || _schema$property2 === void 0 ? void 0 : _schema$property2.scale) || 0;
29
+ const value = showMathPowValue(dpState[TEMP_REPORT_F], scale);
30
+ setTempF(value + '°F');
22
31
  }
23
32
  }, [dpState]);
24
33
  return {
@@ -20,6 +20,9 @@ export const createBattery = _ref => {
20
20
  batteryValue,
21
21
  batteryCharging
22
22
  } = useBattery(devId);
23
+ if (batteryValue === undefined) {
24
+ return null;
25
+ }
23
26
  return /*#__PURE__*/React.createElement(View, {
24
27
  className: clsx('ipc-player-plugin-battery', {
25
28
  'ipc-player-plugin-battery-relative': store.screenType === 'full',
@@ -46,6 +46,7 @@ export function Screenshot(props) {
46
46
  };
47
47
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
48
48
  onClick: () => {
49
+ console.log('截屏!!!');
49
50
  IPCPlayerContext.snapshot({
50
51
  saveToAlbum,
51
52
  // 保存到 IPC 相册
@@ -15,18 +15,19 @@ export const TempHumidity = props => {
15
15
  } = useTemperature(devId);
16
16
  const humidity = useHumidity(devId);
17
17
  const tempRender = () => {
18
- if (tempUnit === '1') {
19
- return tempF && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
18
+ if (tempUnit === '1' && tempF) {
19
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
20
20
  className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-temperature"
21
21
  }), /*#__PURE__*/React.createElement(Text, {
22
22
  className: "tempHumidity"
23
23
  }, tempF));
24
24
  }
25
- return tempC && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
26
- className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-temperature"
27
- }), /*#__PURE__*/React.createElement(Text, null, tempC), /*#__PURE__*/React.createElement(Text, {
28
- className: "ipc-player-plugin-tempHumidity-divider"
29
- }, "/"));
25
+ if (tempC) {
26
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
27
+ className: "ipc-player-plugin-tempHumidity-text-icon icon-panel icon-panel-temperature"
28
+ }), /*#__PURE__*/React.createElement(Text, null, tempC));
29
+ }
30
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
30
31
  };
31
32
  const humRender = () => {
32
33
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
@@ -35,13 +36,15 @@ export const TempHumidity = props => {
35
36
  className: "tempHumidity"
36
37
  }, `${humidity}`));
37
38
  };
38
- return /*#__PURE__*/React.createElement(React.Fragment, null, (tempC || humidity) && /*#__PURE__*/React.createElement(View, {
39
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (tempC || tempF || humidity) && /*#__PURE__*/React.createElement(View, {
39
40
  className: clsx('ipc-player-plugin-tempHumidity', className)
40
41
  }, (() => {
41
- if (tempC && humidity) {
42
- return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), humRender());
42
+ if ((tempC || tempUnit === '1' && tempF) && humidity) {
43
+ return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender(), /*#__PURE__*/React.createElement(Text, {
44
+ className: "ipc-player-plugin-tempHumidity-divider"
45
+ }, "/"), humRender());
43
46
  }
44
- if (tempC) {
47
+ if (tempC || tempUnit === '1' && tempF) {
45
48
  return /*#__PURE__*/React.createElement(React.Fragment, null, tempRender());
46
49
  }
47
50
  if (humidity) {
@@ -9,5 +9,5 @@ export interface IDpCode {
9
9
  time: number;
10
10
  type: string;
11
11
  }
12
- export declare function getDpCodeObj(devId: string, dpCode: string): Promise<IDpCode | undefined>;
13
12
  export declare function getDpIdsByCodes<T extends string>(devId: string, dpIds: T[]): Promise<Record<T, string>>;
13
+ export declare const showMathPowValue: (value: any, scale: any) => string | 0;
@@ -1,4 +1,3 @@
1
- import { getDpsInfos } from '@ray-js/ray';
2
1
  export function getDpValue(options) {
3
2
  return new Promise((resolve, reject) => {
4
3
  ty.device.getDeviceInfo({
@@ -21,30 +20,6 @@ export function getDpValue(options) {
21
20
  });
22
21
  });
23
22
  }
24
- export function getDpCodeObj(devId, dpCode) {
25
- return new Promise((resolve, reject) => {
26
- getDpsInfos({
27
- devId: devId,
28
- gwId: devId
29
- }).then(res => {
30
- let result;
31
- for (let i = 0; i < res.length; i++) {
32
- const ele = res[i];
33
- const {
34
- code,
35
- value
36
- } = ele;
37
- if (code === dpCode) {
38
- result = ele;
39
- break;
40
- }
41
- }
42
- resolve(result);
43
- }).catch(error => {
44
- reject(error);
45
- });
46
- });
47
- }
48
23
  export function getDpIdsByCodes(devId) {
49
24
  return new Promise((resolve, reject) => {
50
25
  ty.device.getDeviceInfo({
@@ -65,4 +40,16 @@ export function getDpIdsByCodes(devId) {
65
40
  }
66
41
  });
67
42
  });
68
- }
43
+ }
44
+ export const showMathPowValue = (value, scale) => {
45
+ if (isNaN(Number(value))) {
46
+ return 0;
47
+ }
48
+ let v = '';
49
+ if (scale === 0) {
50
+ v = (Number(value) / Math.pow(10, scale)).toFixed(0);
51
+ } else {
52
+ v = (Number(value) / Math.pow(10, scale)).toFixed(1);
53
+ }
54
+ return v;
55
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.1-beta-17",
3
+ "version": "0.0.1-beta-19",
4
4
  "description": "IPC 播放器功能集成",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -35,7 +35,7 @@
35
35
  "@ray-js/ray": "^1.4.9"
36
36
  },
37
37
  "dependencies": {
38
- "@ray-js/ray-ipc-player": "2.0.18-beta-beta-1",
38
+ "@ray-js/ray-ipc-player": "2.0.18-beta-3",
39
39
  "@ray-js/ray-ipc-utils": "1.1.0-beta-12",
40
40
  "@ray-js/ipc-ptz-zoom": "0.0.2-beta-1",
41
41
  "clsx": "^1.2.1",
@@ -56,7 +56,7 @@
56
56
  "standard-version": "9.3.2"
57
57
  },
58
58
  "resolutions": {
59
- "@ray-js/builder-mp": "1.4.15"
59
+ "@ray-js/builder-mp": "1.5.37"
60
60
  },
61
61
  "husky": {
62
62
  "hooks": {