From 349d41c62d96afae2e51dbaa0ed3190da37fe818 Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Wed, 29 Jun 2022 20:09:30 +0800 Subject: [PATCH] =?UTF-8?q?fix=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sampleComparison/index.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pages/sampleComparison/index.tsx b/src/pages/sampleComparison/index.tsx index 6639e3a..6dc80ff 100644 --- a/src/pages/sampleComparison/index.tsx +++ b/src/pages/sampleComparison/index.tsx @@ -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() 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('') }