Skip to content

Commit

Permalink
add show temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Apr 10, 2024
1 parent 8e78bd7 commit 85a1f74
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 20 additions & 6 deletions src/components/fan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ const FANDisplayComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => {
//FANRPM模块
const FANRPMComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => {
const [fanrpm, setFanRPM] = useState<number>(0);
const [temperature, setTemperature] = useState<number|undefined>(undefined);
const refresh = async () => {
setFanRPM(FanControl.fanInfo[fanIndex].fanRPM);
const temperature = FanControl.fanInfo[fanIndex].nowPoint.temperature;
if (temperature != undefined) {
setTemperature(Math.trunc(temperature));
}
};

useEffect(() => {
Expand All @@ -314,12 +319,21 @@ const FANRPMComponent: VFC<{ fanIndex: number }> = ({ fanIndex }) => {
}
}, []);
return (
<PanelSectionRow>
<Field focusable={true}
label={localizationManager.getString(localizeStrEnum.FAN_SPEED)}>
{fanrpm + " RPM"}
</Field>
</PanelSectionRow>
<>
<PanelSectionRow>
<Field focusable={true}
label={localizationManager.getString(localizeStrEnum.FAN_SPEED)}>
{fanrpm + " RPM"}
</Field>
</PanelSectionRow>
{temperature &&
<PanelSectionRow>
<Field focusable={true}
label={localizationManager.getString(localizeStrEnum.SENSOR_TEMP)}>
{temperature + " °C"}
</Field>
</PanelSectionRow>}
</>
);
};

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"target": "ES2020",
"jsx": "react",
"jsxFactory": "window.SP_REACT.createElement",
"jsxFragmentFactory": "window.SP_REACT.Fragment",
"declaration": false,
"moduleResolution": "node",
"noUnusedLocals": true,
Expand Down

0 comments on commit 85a1f74

Please sign in to comment.