功能:同步小程序流程
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
/**
|
||||
* Purpose: inflightScopes supports action-guard.js by holding or executing the inflight scopes page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const inflightScopes = new Map()
|
||||
|
||||
/**
|
||||
* Purpose: resolveScopeId supports action-guard.js by holding or executing the resolve scope id 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 resolveScopeId(scope) {
|
||||
if (scope && typeof scope === 'string') {
|
||||
return scope
|
||||
@@ -17,6 +25,10 @@ function resolveScopeId(scope) {
|
||||
return 'global'
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getScopeMap supports action-guard.js by holding or executing the get scope map 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 getScopeMap(scopeId) {
|
||||
if (!inflightScopes.has(scopeId)) {
|
||||
inflightScopes.set(scopeId, new Map())
|
||||
@@ -24,6 +36,10 @@ function getScopeMap(scopeId) {
|
||||
return inflightScopes.get(scopeId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: createGuardError supports action-guard.js by holding or executing the create guard error 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 createGuardError(message, scopeId, actionKey) {
|
||||
const error = new Error(message || '\u64cd\u4f5c\u8fdb\u884c\u4e2d\uff0c\u8bf7\u52ff\u91cd\u590d\u70b9\u51fb')
|
||||
error.isActionGuardError = true
|
||||
@@ -32,6 +48,10 @@ function createGuardError(message, scopeId, actionKey) {
|
||||
return error
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: run supports action-guard.js by holding or executing the run 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.
|
||||
*/
|
||||
async function run(scope, actionKey, task, options) {
|
||||
const scopeId = resolveScopeId(scope)
|
||||
const normalizedKey = String(actionKey || 'default')
|
||||
@@ -52,6 +72,10 @@ async function run(scope, actionKey, task, options) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isRunning supports action-guard.js by holding or executing the is running 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 isRunning(scope, actionKey) {
|
||||
const scopeId = resolveScopeId(scope)
|
||||
const scopeMap = inflightScopes.get(scopeId)
|
||||
@@ -61,10 +85,18 @@ function isRunning(scope, actionKey) {
|
||||
return Boolean(scopeMap.get(String(actionKey || 'default')))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: clearScope supports action-guard.js by holding or executing the clear scope 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 clearScope(scope) {
|
||||
inflightScopes.delete(resolveScopeId(scope))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isGuardError supports action-guard.js by holding or executing the is guard error 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 isGuardError(error) {
|
||||
return Boolean(error && error.isActionGuardError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user