@ledvance/base 1.3.30 → 1.3.32
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/localazy.json +42 -1
- package/package.json +1 -1
- package/src/components/Card.tsx +2 -2
- package/src/components/StripLightView.tsx +3 -1
- package/src/i18n/strings.ts +8670 -7563
- package/src/utils/common.ts +44 -1
- package/translateKey.txt +41 -0
package/src/utils/common.ts
CHANGED
|
@@ -119,6 +119,44 @@ export const exchangeNumber = (v: number | string) => {
|
|
|
119
119
|
return v.toString().replace(/[\,]/g, '.')
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* 判断数字精度是否匹配
|
|
124
|
+
* @param num
|
|
125
|
+
* @param precision
|
|
126
|
+
*/
|
|
127
|
+
export const isPrecisionValid = (num: number | string, precision: number): boolean => {
|
|
128
|
+
const numStr = num.toString()
|
|
129
|
+
const index = numStr.indexOf('.')
|
|
130
|
+
const decimalPlaces = index != -1 ? numStr.length - index - 1 : 0
|
|
131
|
+
return decimalPlaces <= precision
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const exportCsvFile = (headers: any[], values: any[][], functionName: string = '') => {
|
|
135
|
+
const data = [
|
|
136
|
+
headers,
|
|
137
|
+
...values,
|
|
138
|
+
]
|
|
139
|
+
const timestamp = dayjs().format('YYYYMMDDHHmmss')
|
|
140
|
+
|
|
141
|
+
// Excel默认并不是以UTF-8来打开文件,所以在csv开头加入BOM,告诉Excel文件使用utf-8的编码方式
|
|
142
|
+
const BOM = "\uFEFF";
|
|
143
|
+
// 将CSV数据转换为CSV格式的字符串
|
|
144
|
+
const csvData = data.map(row => row.join(','))
|
|
145
|
+
|
|
146
|
+
// 创建 CSV 文件内容
|
|
147
|
+
const csvContent = csvData.join('\n')
|
|
148
|
+
|
|
149
|
+
// 定义文件保存路径
|
|
150
|
+
const documentsPath = RNFetchBlob.fs.dirs.DocumentDir
|
|
151
|
+
const filePath = Platform.OS === 'android' ? RNFetchBlob.fs.dirs.DownloadDir + `/${functionName}${timestamp}.csv` : `${documentsPath}/${functionName}${timestamp}.csv`
|
|
152
|
+
RNFetchBlob.fs.writeFile(filePath, BOM + csvContent, 'utf8')
|
|
153
|
+
.then(() => {
|
|
154
|
+
openDownloadFile(filePath)
|
|
155
|
+
})
|
|
156
|
+
.catch(error => {
|
|
157
|
+
console.error('导出 CSV 文件时出现错误:', error)
|
|
158
|
+
})
|
|
159
|
+
}
|
|
122
160
|
|
|
123
161
|
// 导出文件
|
|
124
162
|
export const exportFile = (list, priceStr, priceUnit) => {
|
|
@@ -259,7 +297,7 @@ interface DialogProps {
|
|
|
259
297
|
confirmText?: string
|
|
260
298
|
subTitle?: string
|
|
261
299
|
onConfirm: (data: any, args: { close: () => void }) => void
|
|
262
|
-
onCancel
|
|
300
|
+
onCancel?: () => void
|
|
263
301
|
}
|
|
264
302
|
|
|
265
303
|
export function showDialog(props: DialogProps) {
|
|
@@ -302,6 +340,11 @@ export function showDialog(props: DialogProps) {
|
|
|
302
340
|
)
|
|
303
341
|
}
|
|
304
342
|
|
|
343
|
+
export function formatHourAndMinute(hour: number, minute: number, is24Hour: boolean = true) {
|
|
344
|
+
const time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
345
|
+
return is24Hour ? time : convertTo12HourFormat(time)
|
|
346
|
+
}
|
|
347
|
+
|
|
305
348
|
export function convertTo12HourFormat(time24: string) {
|
|
306
349
|
// 将字符串按照':'分割成小时和分钟
|
|
307
350
|
var timeParts = time24.split(':');
|
package/translateKey.txt
CHANGED
|
@@ -971,3 +971,44 @@ thermostat_inputlosteditscene
|
|
|
971
971
|
thermostat_infocancelscene
|
|
972
972
|
thermostat_cancelscene
|
|
973
973
|
thermostat_deletescene
|
|
974
|
+
irrigation_controller
|
|
975
|
+
last_water_usage
|
|
976
|
+
current_temp_humidity
|
|
977
|
+
working_status
|
|
978
|
+
working_status_idle
|
|
979
|
+
working_status_manual
|
|
980
|
+
working_status_automatic
|
|
981
|
+
working_status_delay
|
|
982
|
+
next_irrigation
|
|
983
|
+
manual_mode
|
|
984
|
+
controller
|
|
985
|
+
sensor
|
|
986
|
+
activate_sensor
|
|
987
|
+
first_irrigation
|
|
988
|
+
second_irrigation
|
|
989
|
+
third_irrigation
|
|
990
|
+
irrigation_duration
|
|
991
|
+
irrigation_quantity
|
|
992
|
+
irrigation
|
|
993
|
+
spray
|
|
994
|
+
irrigation_by_quantity
|
|
995
|
+
irrigation_on_time
|
|
996
|
+
spray_by_quantity
|
|
997
|
+
spray_on_time
|
|
998
|
+
misting_period
|
|
999
|
+
drip_irrigation_time
|
|
1000
|
+
intermittent_time
|
|
1001
|
+
irrigation_schedule_param_invalid
|
|
1002
|
+
water_consumption
|
|
1003
|
+
daily
|
|
1004
|
+
monthly
|
|
1005
|
+
yearly
|
|
1006
|
+
temperature
|
|
1007
|
+
humidity
|
|
1008
|
+
overview
|
|
1009
|
+
date
|
|
1010
|
+
legend_temp
|
|
1011
|
+
legend_humidity
|
|
1012
|
+
battery_status_normal
|
|
1013
|
+
battery_status_low
|
|
1014
|
+
battery_status_empty
|