Skip to content

Commit

Permalink
feat: 添加WebSocket支持,增强与服务的实时通信 (#50)
Browse files Browse the repository at this point in the history
* feat: 添加WebSocket支持,增强与服务的实时通信

* feat: 添加WebSocket支持,更新相关配置和依赖项

* chore: 清理代码,统一格式,优化可读性

* feat: 更新冰箱配件的制冷状态和温度阈值设置

---------

Co-authored-by: baran.wang <[email protected]>
  • Loading branch information
baranwang and baran.wang authored Jan 15, 2025
1 parent cba5df2 commit 5b073fe
Show file tree
Hide file tree
Showing 19 changed files with 572 additions and 208 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-onions-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"homebridge-plugin-haier": minor
---

使用 WebSocket 增强性能
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ homebridge-ui/
# IDE
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea

test/hb-config
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cSpell.words": [
"haier"
],
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
}
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"watch": ["dist", "homebridge-ui"],
"ext": "js",
"ignore": [],
"exec": "homebridge -U ./test/hb-config -I -D",
"exec": "homebridge -U ./test/hb-config -I -D",
"signal": "SIGTERM",
"env": {
"NODE_OPTIONS": "--trace-warnings"
Expand Down
67 changes: 59 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,12 @@
"node": "^18.20.4 || ^20.18.0 || ^22.10.0",
"homebridge": "^1.8.0 || ^2.0.0-beta.0"
},
"files": [
"dist",
"homebridge-ui",
"config.schema.json",
"CHANGELOG.md"
],
"keywords": [
"homebridge-plugin",
"haier",
"海尔"
],
"files": ["dist", "homebridge-ui", "config.schema.json", "CHANGELOG.md"],
"keywords": ["homebridge-plugin", "haier", "海尔"],
"dependencies": {
"@homebridge/plugin-ui-utils": "^2.0.0",
"axios": "^1.7.9"
"axios": "^1.7.9",
"ws": "^8.18.0"
},
"devDependencies": {
"@biomejs/biome": "1.9.2",
Expand All @@ -66,6 +58,7 @@
"@types/node": "^22.10.5",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@types/ws": "^8.5.13",
"ahooks": "^3.8.4",
"concurrently": "^9.1.2",
"cross-env": "^7.0.3",
Expand Down
11 changes: 5 additions & 6 deletions rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineConfig, type LibConfig } from '@rslib/core';
import pkg from './package.json';
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';


const NODE_ENV = process.env.NODE_ENV === 'production' ? 'production' : 'development';

const commonLibConfig: LibConfig = {
Expand All @@ -28,7 +27,7 @@ export default defineConfig({
esm: {
__dirname: true,
},
}
},
},
// CJS Plugin Configuration
{
Expand All @@ -41,7 +40,7 @@ export default defineConfig({
id: 'ui-renderer',
format: 'umd',
autoExtension: false,
plugins: [pluginReact(),],
plugins: [pluginReact()],
source: {
entry: {
index: './src-ui/index.tsx',
Expand Down Expand Up @@ -104,11 +103,11 @@ export default defineConfig({
chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [
{
supports: {
generateTileGraph: true
}
generateTileGraph: true,
},
},
]);
}
},
}
},
});
2 changes: 1 addition & 1 deletion src-ui/hooks/use-devices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useDevices(familyId?: string) {
window.homebridge.hideSpinner();
}
}, [loading]);

return {
devices,
};
Expand Down
2 changes: 1 addition & 1 deletion src-ui/hooks/use-family-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useFamilyList({ username, password }: { username?: string; passw
debounceWait: 1000,
onError: (error) => {
window.homebridge.toast.error(error.message);
}
},
},
);
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src-ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const App: React.FC<{
const newConfigs = pluginConfigs ? [...pluginConfigs] : [];
newConfigs[0] = { ...newConfigs[0], ...configs };
window.homebridge.updatePluginConfig(newConfigs);
}
};

useEffect(() => {
if (!devices?.length) {
Expand Down
Loading

0 comments on commit 5b073fe

Please sign in to comment.