@ledvance/ui-biz-bundle 1.1.154 → 1.1.155

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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.154",
7
+ "version": "1.1.155",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -43,6 +43,7 @@ export async function updatePrice(devId: string, energyData: EnergyData) {
43
43
  export async function resetElectricity(devId) {
44
44
  const res = await TYSdk.apiRequest('tuya.m.dp.statistics.reset', {devId}, '1.0')
45
45
  xLog('resetElectricity res', res)
46
+ return res
46
47
  }
47
48
 
48
49
  export async function getElectricity(devId: string, addEleDpCode: string, date: string, dateType: DateType): Promise<OverviewItem[]> {
@@ -148,7 +148,7 @@ const EnergyConsumptionCard = (props: EnergyConsumptionProp) => {
148
148
  addEleDpCode: props.addEleDpCode,
149
149
  } as EnergyConsumptionPageProps)}>
150
150
  <Spacer height={cx(16)}/>
151
- <View style={styles.consumedEnergyHeadline}>
151
+ <View accessibilityLabel={'AdvanceCard'} accessibilityHint={I18n.getLang(state.isGeneration ? 'sockets_headline_power' : 'sockets_ce')} style={styles.consumedEnergyHeadline}>
152
152
  <Text
153
153
  style={styles.consumedEnergyCardTitle}>{I18n.getLang(state.isGeneration ? 'sockets_headline_power' : 'sockets_ce')}</Text>
154
154
  <Image source={Res.energyChart} style={{ width: cx(24), height: cx(24), tintColor: props.theme?.icon.normal }}/>
@@ -34,7 +34,7 @@ export const EnergyChartSection = ({ isLandscape, state, actions, params, styles
34
34
  <>
35
35
  <View style={styles.dateTypeContainer}>
36
36
  <DateTypeItem
37
- style={{ flex: 0.5 }}
37
+ style={{ flex: 1 }}
38
38
  dateType={state.dateType}
39
39
  onDateTypeChange={actions.setDateType}
40
40
  />
@@ -121,6 +121,9 @@ export const useEnergyData = (params: EnergyConsumptionChartProps, devId: string
121
121
 
122
122
  // 封装所有修改状态的函数
123
123
  const actions = {
124
+ cleanChartData: useCallback(() => {
125
+ state.chartData = []
126
+ }, []),
124
127
  setChartType: useCallback((type: ChartType) => {
125
128
  state.chartType = type
126
129
  }, []),
@@ -1,4 +1,5 @@
1
1
  import Segmented from '@ledvance/base/src/components/Segmented'
2
+ import { resetElectricity } from './EnergyConsumptionActions'
2
3
  import { ChartType } from './co2Data'
3
4
  import { EnergyChartSection } from './EnergyConsumptionChart/EnergyChartSection'
4
5
  import { PowerChartSection } from './EnergyConsumptionChart/PowerChartSection'
@@ -21,8 +22,10 @@ import {useDeviceId, useSolarPlug, useTimeZoneCity} from "@ledvance/base/src/mod
21
22
  import { flattenDeep, isEmpty } from "lodash";
22
23
  import { exchangeNumber, localeNumber, monthFormat, monthFormatShort, showDialog } from "@ledvance/base/src/utils/common";
23
24
  import {
24
- EnergyGeneration, EnergyHistory,
25
- exportEnergyCsv, getEnergyGenerationValue, setEnergyGenerationValue,
25
+ EnergyGeneration,
26
+ EnergyHistory,
27
+ getEnergyGenerationValue,
28
+ setEnergyGenerationValue,
26
29
  updatePrice,
27
30
  useElectricCurrent,
28
31
  usePower,
@@ -136,8 +139,8 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
136
139
  }, [isSolarPlug, state.generationMode])
137
140
 
138
141
  const totalElectricity = useMemo(() => {
139
- return Math.max(Number(state.totalElectricity) - (state.energyGeneration.totalElectricity || 0), 0)
140
- }, [state.totalElectricity, state.energyGeneration.totalElectricity])
142
+ return Number(state.totalElectricity)
143
+ }, [state.totalElectricity])
141
144
 
142
145
  useUpdateEffect(() =>{
143
146
  if(totalElectricity >= 0 && timeZoneCity){
@@ -167,16 +170,17 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
167
170
  const item: EnergyHistory = {
168
171
  time,
169
172
  generationMode: value,
170
- value: Number(state.totalElectricity) || 0,
173
+ value: 0,
171
174
  type: isSolarPlug ? (value ? 'Consumption' : 'Generation') : (value ? 'Generation' : 'Consumption')
172
175
  }
173
176
  const data: EnergyGeneration = {
174
177
  generationMode: value,
175
- totalElectricity: Number(state.totalElectricity) || 0,
178
+ totalElectricity: 0,
176
179
  history: [item, ...state.energyGeneration.history]
177
180
  }
178
181
  const res = await setEnergyGenerationValue(devId, data)
179
182
  if (res) {
183
+ await cleanEnergyData()
180
184
  state.generationMode = value
181
185
  state.energyGeneration = data
182
186
  } else {
@@ -185,9 +189,15 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
185
189
  state.loading = false
186
190
  }
187
191
 
188
- const onceByDay = () => {
189
- const currentDay = dayjs().startOf('day').valueOf()
190
- return !!state.energyGeneration.history.find(item => item.time === currentDay)
192
+ const cleanEnergyData = async () => {
193
+ const res = await resetElectricity(devId)
194
+ if (res) {
195
+ state.todayElectricity = 0
196
+ state.totalElectricity = 0
197
+ state.overviewList = []
198
+ actions.cleanChartData()
199
+ }
200
+ return res
191
201
  }
192
202
 
193
203
  const getElectricity = async () => {
@@ -212,6 +222,8 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
212
222
  return monthData
213
223
  })
214
224
  state.overviewList = flattenDeep(monthList)
225
+ } else {
226
+ state.overviewList = []
215
227
  }
216
228
  }
217
229
  }
@@ -344,10 +356,17 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
344
356
  style={{ position: 'relative' }}
345
357
  backText={backTitle}
346
358
  headlineText={backTitle}
347
- headlineIcon={state.overviewList.length ? res.download_icon : undefined}
359
+ headlineIcon={res.ic_refresh}
348
360
  onHeadlineIconClick={() => {
349
- const values = state.overviewList.map(item => [item.key, item.value, (Number(state.price) * Number(item.value)).toFixed(2)])
350
- exportEnergyCsv(values, state.unit)
361
+ showDialog({
362
+ method: 'confirm',
363
+ title: I18n.getLang('reset_energy'),
364
+ subTitle: '',
365
+ onConfirm: (_, { close }) => {
366
+ close()
367
+ cleanEnergyData().then()
368
+ }
369
+ })
351
370
  }}
352
371
  showGreenery={isGeneration}
353
372
  greeneryIcon={res.energy_consumption_greenery}
@@ -508,17 +527,6 @@ const EnergyConsumptionPage = (props: {theme?: ThemeType}) => {
508
527
  if (state.loading) {
509
528
  return
510
529
  }
511
- if (onceByDay()) {
512
- showDialog({
513
- method: 'alert',
514
- title: I18n.getLang('switchonlyonce', 'Switching the mode is only allowed once a day.'),
515
- confirmText: I18n.getLang('home_screen_home_dialog_yes_con'),
516
- onConfirm: (_, {close}) => {
517
- close()
518
- }
519
- })
520
- return
521
- }
522
530
  showDialog({
523
531
  method: 'confirm',
524
532
  title: getEnergyModeTitle(value),
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect, useMemo } from "react";
2
- import { StyleSheet, View, Text, Image, FlatList } from 'react-native'
2
+ import { StyleSheet, View, Text, Image, FlatList, Platform } from 'react-native'
3
3
  import Page from '@ledvance/base/src/components/Page'
4
4
  import Tag from '@ledvance/base/src/components/Tag'
5
5
  import Spacer from '@ledvance/base/src/components/Spacer'
@@ -256,8 +256,9 @@ const SleepWakeUpPage = (props: { theme?: ThemeType }) => {
256
256
  addMoodPopover: {
257
257
  width: cx(210),
258
258
  height: cx(90.5),
259
- marginStart: cx(115),
260
- marginTop: cx(100),
259
+ position: 'absolute',
260
+ right: cx(60),
261
+ top: Platform.OS === 'android' ? cx(90) : cx(130),
261
262
  backgroundColor: props.theme?.card.background,
262
263
  },
263
264
  popoverItem: {