FEAT => 本次更新项目为:
设备绑定指引
This commit is contained in:
30
nkebao/src/utils/device.ts
Normal file
30
nkebao/src/utils/device.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { getDashboard } from "@/pages/mobile/home/api";
|
||||
|
||||
/**
|
||||
* 更新设备数量到store
|
||||
* @param setDeviceCount store中的setDeviceCount函数
|
||||
* @returns 更新后的设备数量
|
||||
*/
|
||||
export const updateDeviceCount = async (
|
||||
setDeviceCount: (count: number) => void,
|
||||
): Promise<number> => {
|
||||
try {
|
||||
const dashboardData = await getDashboard();
|
||||
const deviceCount = dashboardData?.deviceNum || 0;
|
||||
setDeviceCount(deviceCount);
|
||||
return deviceCount;
|
||||
} catch (error) {
|
||||
console.error("更新设备数量失败:", error);
|
||||
setDeviceCount(0);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 检查是否需要设备绑定
|
||||
* @param deviceCount 设备数量
|
||||
* @returns 是否需要设备绑定
|
||||
*/
|
||||
export const needsDeviceBinding = (deviceCount: number): boolean => {
|
||||
return deviceCount === 0;
|
||||
};
|
||||
Reference in New Issue
Block a user