From 85a1f7401f6a20e4026b549291e671eec8dd7816 Mon Sep 17 00:00:00 2001 From: honjow Date: Thu, 11 Apr 2024 02:29:35 +0800 Subject: [PATCH] add show temperature --- package.json | 2 +- src/components/fan.tsx | 26 ++++++++++++++++++++------ tsconfig.json | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7e96a40..d53caaf 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerControl", - "version": "2.4.14", + "version": "2.4.15", "description": "PowerControl plugin.", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/components/fan.tsx b/src/components/fan.tsx index a7daf74..5841f96 100755 --- a/src/components/fan.tsx +++ b/src/components/fan.tsx @@ -301,8 +301,13 @@ const FANDisplayComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => { //FANRPM模块 const FANRPMComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => { const [fanrpm, setFanRPM] = useState(0); + const [temperature, setTemperature] = useState(undefined); const refresh = async () => { setFanRPM(FanControl.fanInfo[fanIndex].fanRPM); + const temperature = FanControl.fanInfo[fanIndex].nowPoint.temperature; + if (temperature != undefined) { + setTemperature(Math.trunc(temperature)); + } }; useEffect(() => { @@ -314,12 +319,21 @@ const FANRPMComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => { } }, []); return ( - - - {fanrpm + " RPM"} - - + <> + + + {fanrpm + " RPM"} + + + {temperature && + + + {temperature + " °C"} + + } + ); }; diff --git a/tsconfig.json b/tsconfig.json index f323170..73de370 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "target": "ES2020", "jsx": "react", "jsxFactory": "window.SP_REACT.createElement", + "jsxFragmentFactory": "window.SP_REACT.Fragment", "declaration": false, "moduleResolution": "node", "noUnusedLocals": true,