@ledvance/base 1.2.38 → 1.2.39

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/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.2.38",
7
+ "version": "1.2.39",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
@@ -84,7 +84,7 @@ const DrawToolView = (props: DrawToolViewProps) => {
84
84
  }, [props.ledNum])
85
85
 
86
86
  useUpdateEffect(() =>{
87
- state.visible = props.ledNumModalVisible
87
+ state.visible = props.ledNumModalVisible || false
88
88
  }, [props.ledNumModalVisible])
89
89
 
90
90
  const onLayout = (event: any) => {
@@ -103,7 +103,11 @@ const DrawToolView = (props: DrawToolViewProps) => {
103
103
  }
104
104
  return '#ffffff'
105
105
  }, [props.isColorMode, props.h, props.s])
106
-
106
+
107
+ const ledNumValidator = (num?: number) => {
108
+ return num && Number.isInteger(num) && num >= 5 && num <= 48;
109
+ }
110
+
107
111
  return (
108
112
  <Card style={{ marginHorizontal: cx(24) }}>
109
113
  <LdvSwitch
@@ -216,10 +220,10 @@ const DrawToolView = (props: DrawToolViewProps) => {
216
220
  <Spacer />
217
221
  <DeleteButton
218
222
  text={I18n.getLang('auto_scan_system_wifi_confirm')}
219
- style={{ width: cx(150), height: cx(40), backgroundColor: (state.ledNum < 5 || state.ledNum > 48) ? '#666' : '#f60' }}
223
+ style={{ width: cx(150), height: cx(40), backgroundColor: ledNumValidator(state.ledNum) ? '#f60' : '#666' }}
220
224
  textStyle={{ fontSize: cx(14) }}
221
225
  onPress={() => {
222
- if(state.ledNum < 5 || state.ledNum > 48) return
226
+ if (!ledNumValidator(state.ledNum)) return
223
227
  props.setLedNum(state.ledNum)
224
228
  state.visible = false
225
229
  }} />
@@ -254,4 +258,4 @@ const styles = StyleSheet.create({
254
258
  },
255
259
  })
256
260
 
257
- export default DrawToolView
261
+ export default DrawToolView
@@ -4,7 +4,9 @@ import { formatNumber, openDownloadFile } from 'api/native'
4
4
  import dayjs from 'dayjs'
5
5
  import RNFetchBlob from 'rn-fetch-blob'
6
6
  import { isEqual } from 'lodash'
7
- import { Dialog } from 'tuya-panel-kit'
7
+ import { Dialog, Utils } from 'tuya-panel-kit'
8
+
9
+ const { toFixedString } = Utils.NumberUtils
8
10
 
9
11
  const loopsText = [
10
12
  I18n.getLang('timeschedule_add_schedule_weekday7_text'),
@@ -313,19 +315,21 @@ export function convertTo12HourFormat(time24: string) {
313
315
  }
314
316
 
315
317
  // 将分钟数转换为12小时制时间
316
- export function convertMinutesTo12HourFormat(minutes: number) {
317
- var hours = Math.floor(minutes / 60); // 获取小时数
318
- var mins = minutes % 60; // 获取剩余分钟数
319
-
318
+ export function convertMinutesTo12HourFormat(minutes: number, is24: boolean) {
319
+ let hours = Math.floor(minutes / 60); // 获取小时数
320
+ const mins = minutes % 60; // 获取剩余分钟数
321
+ if(is24){
322
+ return `${toFixedString(hours, 2)}:${toFixedString(mins, 2)}`
323
+ }
320
324
  // 检查小时数是否大于12,并调整
321
325
  if (hours > 12) {
322
326
  hours -= 12;
323
327
  }
324
328
 
325
329
  // 构造12小时制时间字符串
326
- var suffix = (hours >= 12) ? I18n.getLang('manage_user_calendar_label_pm') : I18n.getLang('manage_user_calendar_label_am');
330
+ const suffix = (hours >= 12) ? I18n.getLang('manage_user_calendar_label_pm') : I18n.getLang('manage_user_calendar_label_am');
327
331
  hours = (hours == 0) ? 12 : hours; // 处理午夜0点为12小时制的12点
328
- var time12Hour = suffix + ' ' + hours + ':' + (mins < 10 ? '0' : '') + mins;
332
+ const time12Hour = suffix + ' ' + hours + ':' + (mins < 10 ? '0' : '') + mins;
329
333
 
330
334
  return time12Hour;
331
335
  }