// 当pad端做了7天免登录时动态更新保持不退出
let timer = null;
// 测试数据
let num = 0;
function getCookie(name) {
const strcookie = document.cookie; //获取cookie字符串
const arrcookie = strcookie.split("; "); //分割
//遍历匹配
for (let i = 0; i < arrcookie.length; i++) {
const arr = arrcookie[i].split("=");
if (arr[0] == name) {
return arr[1];
}
}
return "";
}
function setTimer() {
num = num + 1;
let pad = getCookie("pad");
//todo something
if (timer) {
clearTimeout(timer);
}
if (pad || num < 10) {
timer = setTimeout(function () {
setTimer();
// 十分钟
}, 600000);
}
}
setTimer();
定时器使用
于 2023-05-25 11:50:12 首次发布