@ledvance/base 1.3.16 → 1.3.17

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.
@@ -121,16 +121,19 @@ export const exchangeNumber = (v: number | string) => {
121
121
 
122
122
 
123
123
  // 导出文件
124
- export const exportFile = (list) => {
124
+ export const exportFile = (list, priceStr, priceUnit) => {
125
+ const price = isNaN(Number(priceStr)) ? 0 : Number(priceStr)
125
126
  const value = list?.map(item => {
126
- return [item?.key, item?.value]
127
+ return [item?.key, item?.value, price * item?.value]
127
128
  })
128
129
  const data = [
129
- ['Date', `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`],
130
+ ['Date', `${I18n.getLang('consumption_data_annual_bar_chart_system_back_text')} (kWh)`,`Price(${priceUnit})`],
130
131
  ...value,
131
132
  ]
132
133
  const timestamp = dayjs().format('YYYYMMDDHHmmss')
133
134
 
135
+ // Excel默认并不是以UTF-8来打开文件,所以在csv开头加入BOM,告诉Excel文件使用utf-8的编码方式
136
+ const BOM = "\uFEFF";
134
137
  // 将CSV数据转换为CSV格式的字符串
135
138
  const csvData = data.map(row => row.join(','))
136
139
 
@@ -140,7 +143,7 @@ export const exportFile = (list) => {
140
143
  // 定义文件保存路径
141
144
  const documentsPath = RNFetchBlob.fs.dirs.DocumentDir
142
145
  const filePath = Platform.OS === 'android' ? RNFetchBlob.fs.dirs.DownloadDir + `/energyConsumption${timestamp}.csv` : `${documentsPath}/energyConsumption${timestamp}.csv`
143
- RNFetchBlob.fs.writeFile(filePath, csvContent, 'utf8')
146
+ RNFetchBlob.fs.writeFile(filePath, BOM + csvContent, 'utf8')
144
147
  .then(() => {
145
148
  openDownloadFile(filePath)
146
149
  })
package/translateKey.txt CHANGED
@@ -913,4 +913,10 @@ thermostat_hot
913
913
  thermostat_cold
914
914
  thermostat_warm
915
915
  thermostat_childlock_overview_description_text
916
- strip_light_static_mood_add_step_2_headline
916
+ strip_light_static_mood_add_step_2_headline
917
+ format_unit
918
+ year
919
+ month
920
+ day
921
+ energyconsumption_emptydata
922
+ date_type