添加灯光管理、自动化和脚本功能,更新依赖项,完善文档

This commit is contained in:
2025-12-22 23:30:13 +08:00
parent 18e4b39ade
commit 47a5c600ea
15 changed files with 392 additions and 118 deletions

19
test/light.ts Normal file
View File

@@ -0,0 +1,19 @@
import { hacore, showMore } from "./common.ts";
import Fuse from 'fuse.js';
const devices = await hacore.getInfoList();
const fuse = new Fuse(devices, {
keys: ['name'], // 搜索字段
threshold: 0.4, // 匹配宽松度0~1越小越严格
includeScore: true,
minMatchCharLength: 1, // 允许单字匹配
});
// const searchKeyword = '次卧灯';
// const searchKeyword = '阳台 灯';
// const searchKeyword = '晾衣机的 灯';
const searchKeyword = ' 阳台 灯';
const result = fuse.search(searchKeyword);
// 输出搜索结果
console.log(`搜索关键词: "${searchKeyword}"`);
console.log(showMore(result.map(r => r.item)));