FEAT => 本次更新项目为:

设备绑定指引
This commit is contained in:
2025-07-30 12:52:58 +08:00
parent 4a4e9a611f
commit f78af9e77c
14 changed files with 208 additions and 56 deletions

View File

@@ -0,0 +1,30 @@
import { createPersistStore } from "@/store/createPersistStore";
export interface DeviceState {
deviceCount: number;
setDeviceCount: (count: number) => void;
updateDeviceCount: () => Promise<void>;
resetDeviceCount: () => void;
}
export const useDeviceStore = createPersistStore<DeviceState>(
(set, get) => ({
deviceCount: 0,
setDeviceCount: (count: number) => set({ deviceCount: count }),
updateDeviceCount: async () => {
try {
// 这里需要导入getDashboard但为了避免循环依赖我们通过参数传入
// 实际使用时会在组件中调用并传入API函数
set({ deviceCount: 0 }); // 默认设置为0实际值由调用方设置
} catch (error) {
console.error("更新设备数量失败:", error);
set({ deviceCount: 0 });
}
},
resetDeviceCount: () => set({ deviceCount: 0 }),
}),
"device-store",
state => ({
deviceCount: state.deviceCount,
}),
);