mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
no message
This commit is contained in:
parent
208598a6df
commit
bfb9795913
54
resources/assets/js/functions/common.js
vendored
54
resources/assets/js/functions/common.js
vendored
@ -1343,6 +1343,60 @@ const timezone = require("dayjs/plugin/timezone");
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('等待条件超时');
|
throw new Error('等待条件超时');
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行指定次数的定时任务,返回一个可以取消的对象
|
||||||
|
* @param {Function} fn 要执行的函数
|
||||||
|
* @param {number} interval 间隔时间(毫秒)
|
||||||
|
* @param {number} times 执行次数
|
||||||
|
* @returns {object} 包含 clear 方法的对象
|
||||||
|
*/
|
||||||
|
repeatWithCount(fn, interval, times) {
|
||||||
|
if (typeof fn !== 'function') {
|
||||||
|
return () => {}; // 返回空函数而不是null,保持返回类型一致
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interval < 0 || times < 0) {
|
||||||
|
return () => {}; // 返回空函数
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let timer = null;
|
||||||
|
|
||||||
|
const clear = () => {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const execute = () => {
|
||||||
|
if (count >= times) {
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (fn(count) === true) {
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
clear();
|
||||||
|
console.error('Error in callback function:', error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
timer = setTimeout(execute, interval);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 立即开始第一次执行
|
||||||
|
timer = setTimeout(execute, 0);
|
||||||
|
|
||||||
|
// 直接返回clear函数
|
||||||
|
return clear;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2356,6 +2356,13 @@ export default {
|
|||||||
this.focusTimer && clearTimeout(this.focusTimer)
|
this.focusTimer && clearTimeout(this.focusTimer)
|
||||||
this.focusLazy = true
|
this.focusLazy = true
|
||||||
this.$emit("on-focus")
|
this.$emit("on-focus")
|
||||||
|
//
|
||||||
|
if ($A.isIos()) {
|
||||||
|
this.tempRepeat && this.tempRepeat()
|
||||||
|
this.tempRepeat = $A.repeatWithCount(() => {
|
||||||
|
this.$refs.footer.scrollIntoView({block: 'end'})
|
||||||
|
}, 50, 10)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onEventBlur() {
|
onEventBlur() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user