1
0
forked from dyf/APP

优化实时获取设备,前端取消掉超时状态,根据服务的超时来判断

This commit is contained in:
fengerli
2025-08-14 14:39:10 +08:00
parent e56bbfe674
commit a773823c3f
3 changed files with 15 additions and 25 deletions

View File

@ -75,10 +75,9 @@
* 获取设备状态(带自动轮询)
* @param {number} val - 功能模式
* @param {string} batchId - 批次ID
* @param {number} [maxRetries=30] - 最大重试次数约30秒
* @param {number} [interval=1000] - 轮询间隔(毫秒)
*/
async getdeviceSTatus(val, batchId, maxRetries = 30, interval = 2000) {
async getdeviceSTatus(val, batchId, interval = 800) {
let retries = 0;
const checkStatus = async () => {
try {
@ -96,9 +95,6 @@
case 'OK':
return res; // 成功完成
case 'ACTIVE':
if (++retries >= maxRetries) {
throw new Error('操作超时');
}
await new Promise(r => setTimeout(r, interval));
return checkStatus(); // 继续轮询
case 'FAILED':