fix修复重置问题
This commit is contained in:
parent
8c6392c90e
commit
349d41c62d
@ -18,11 +18,11 @@ export default () => {
|
||||
a2: '',
|
||||
b2: '',
|
||||
})
|
||||
|
||||
const [colorList, setColorList] = useState({
|
||||
one: null,
|
||||
two: null
|
||||
})
|
||||
type ColorList = {
|
||||
one?: any,
|
||||
two?: any
|
||||
}
|
||||
const [colorList, setColorList] = useState<ColorList>()
|
||||
const { state: colorState, measureAndGetLab } = useBluetooth()
|
||||
|
||||
const getLab = async (val) => {
|
||||
@ -57,25 +57,28 @@ export default () => {
|
||||
useEffect(() => {
|
||||
if (colorState.deviceLab) {
|
||||
|
||||
if (colorList.one?.constructor === Object) {
|
||||
const rgb = toRgb([colorList.one.L, colorList.one.a, colorList.one.b])
|
||||
if ((colorList as any).one?.constructor === Object) {
|
||||
const rgb = toRgb([(colorList as any).one.L, (colorList as any).one.a, (colorList as any).one.b])
|
||||
setBlueToothColor(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
|
||||
setTime(getNowTime())
|
||||
setSearchField({ ...searchField, l1: rgb[0], a1: rgb[1], b1: rgb[2] })
|
||||
}
|
||||
if (colorList.two?.constructor === Object) {
|
||||
const rgb = toRgb([colorList.two.L, colorList.two.a, colorList.two.b])
|
||||
if ((colorList as any).two?.constructor === Object) {
|
||||
|
||||
const rgb = toRgb([(colorList as any).two.L, (colorList as any).two.a, (colorList as any).two.b])
|
||||
setBlueToothColorTwo(`rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`)
|
||||
setTimeTwo(getNowTime())
|
||||
setSearchField({ ...searchField, l2: rgb[0], a2: rgb[1], b2: rgb[2] })
|
||||
|
||||
}
|
||||
}
|
||||
}, [colorList])
|
||||
const reset = () => {
|
||||
setColorList({})
|
||||
setBlueToothColor('')
|
||||
setBlueToothColorTwo('')
|
||||
setTime('')
|
||||
setTime('')
|
||||
setTimeTwo('')
|
||||
setData('')
|
||||
setResult('')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user