功能:同步小程序流程
This commit is contained in:
@@ -1,11 +1,43 @@
|
||||
/**
|
||||
* Purpose: options supports idle-session.js by holding or executing the options page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let options = null
|
||||
/**
|
||||
* Purpose: timer supports idle-session.js by holding or executing the timer page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let timer = null
|
||||
/**
|
||||
* Purpose: warningShown supports idle-session.js by holding or executing the warning shown page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let warningShown = false
|
||||
/**
|
||||
* Purpose: loggingOut supports idle-session.js by holding or executing the logging out page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let loggingOut = false
|
||||
/**
|
||||
* Purpose: hiddenAt supports idle-session.js by holding or executing the hidden at page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let hiddenAt = 0
|
||||
/**
|
||||
* Purpose: lastActiveAt supports idle-session.js by holding or executing the last active at page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let lastActiveAt = Date.now()
|
||||
/**
|
||||
* Purpose: pagePatched supports idle-session.js by holding or executing the page patched page or API role.
|
||||
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
let pagePatched = false
|
||||
|
||||
/**
|
||||
* Purpose: shouldTrackMethod supports idle-session.js by holding or executing the should track method page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function shouldTrackMethod(name) {
|
||||
return ![
|
||||
'onHide',
|
||||
@@ -15,6 +47,10 @@ function shouldTrackMethod(name) {
|
||||
].includes(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: ensurePagePatched supports idle-session.js by holding or executing the ensure page patched page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function ensurePagePatched() {
|
||||
if (pagePatched || typeof Page !== 'function') {
|
||||
return
|
||||
@@ -40,6 +76,10 @@ function ensurePagePatched() {
|
||||
pagePatched = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: start supports idle-session.js by holding or executing the start page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function start() {
|
||||
stop()
|
||||
if (!options) {
|
||||
@@ -48,6 +88,10 @@ function start() {
|
||||
timer = setInterval(check, 15000)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: stop supports idle-session.js by holding or executing the stop page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function stop() {
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
@@ -55,10 +99,18 @@ function stop() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isLoggedIn supports idle-session.js by holding or executing the is logged in page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function isLoggedIn() {
|
||||
return options && typeof options.isLoggedIn === 'function' ? Boolean(options.isLoggedIn()) : false
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: markActive supports idle-session.js by holding or executing the mark active page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function markActive() {
|
||||
if (!options || !isLoggedIn() || loggingOut) {
|
||||
return
|
||||
@@ -67,6 +119,10 @@ function markActive() {
|
||||
warningShown = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: onAppShow supports idle-session.js by holding or executing the on app show page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function onAppShow() {
|
||||
if (!options) {
|
||||
return
|
||||
@@ -83,11 +139,19 @@ function onAppShow() {
|
||||
start()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: onAppHide supports idle-session.js by holding or executing the on app hide page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function onAppHide() {
|
||||
hiddenAt = Date.now()
|
||||
stop()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: check supports idle-session.js by holding or executing the check page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function check() {
|
||||
if (!options || !isLoggedIn() || loggingOut) {
|
||||
return
|
||||
@@ -102,6 +166,10 @@ function check() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: showWarning supports idle-session.js by holding or executing the show warning page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function showWarning() {
|
||||
if (!options || warningShown || loggingOut) {
|
||||
return
|
||||
@@ -129,6 +197,10 @@ function showWarning() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: forceLogout supports idle-session.js by holding or executing the force logout page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function forceLogout() {
|
||||
if (!options || loggingOut) {
|
||||
return
|
||||
@@ -145,6 +217,10 @@ function forceLogout() {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: init supports idle-session.js by holding or executing the init page or API role.
|
||||
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
function init(nextOptions) {
|
||||
options = nextOptions || null
|
||||
lastActiveAt = Date.now()
|
||||
|
||||
Reference in New Issue
Block a user