From 1d109550d49dd846275af38d25354f4dbad8945e Mon Sep 17 00:00:00 2001 From: jazz <jazzxhunter@163.com> Date: 星期三, 13 十二月 2023 11:42:08 +0800 Subject: [PATCH] update_202312131141_房间增加敷麻状态,且刷新按钮改为刷新整个浏览器页面 --- src/utils/fn.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/src/utils/fn.js b/src/utils/fn.js index c569024..15fa356 100644 --- a/src/utils/fn.js +++ b/src/utils/fn.js @@ -330,6 +330,47 @@ fn_obj[`timer_${pageKey}`] = null } +/** + * 杞寮傛璋冪敤鎺ュ彛 + * @param {Object} page 椤甸潰瀵硅薄this + * @param {String} fnName 瑕佽疆璇㈢殑鏂规硶鍚嶇О + * @param {String} pageKey 椤甸潰鍏抽敭瀛� + * @param {Number} timeStamp 澶氬皯绉掕疆璇� + */ +function pollingAjaxFn(page, fnName, pageKey, timeStamp = 1000) { + if (!page || !fnName || !pageKey) { + return + } + page[fnName] && page[fnName]() + fn_obj[`pollingTimer_${pageKey}`] = setTimeout(() => { + pollingAjaxFn(page, fnName, pageKey, timeStamp) + }, timeStamp) +} + +/** + * 鍋滄杞 + * @param {String} pageKey 椤甸潰鍏抽敭璇� + */ +function stopPollingAjaxFn(pageKey) { + clearTimeout(fn_obj[`pollingTimer_${pageKey}`]) + fn_obj[`pollingTimer_${pageKey}`] = null +} + +// 闅忔満12浣嶆暟 +function getCheckedId() { + var s = [] + var hexDigits = '0123456789abcdef' + for (var i = 0; i < 12; i++) { + s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) + } + // s[14] = '4'; + // s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); + + // s[8] = s[13] = s[18] = s[23] = '-' + var uuid = s.join('') + return uuid +} + var fn = { getLocalStorage, getSessionStorage, @@ -358,6 +399,9 @@ countGetTime, stopCountGetTime, + pollingAjaxFn, + stopPollingAjaxFn, + getCheckedId, /** * 娣辨嫹璐� -- Gitblit v1.8.0