功能:同步小程序流程
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
/**
|
||||
* Purpose: DRAFT_PREFIX supports form-draft.js by holding or executing the draft prefix 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 DRAFT_PREFIX = 'miniDraft:'
|
||||
|
||||
/**
|
||||
* Purpose: buildDraftKey supports form-draft.js by holding or executing the build draft key 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 buildDraftKey(key) {
|
||||
return `${DRAFT_PREFIX}${key}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadDraft supports form-draft.js by holding or executing the load draft 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 loadDraft(key, defaultValue) {
|
||||
if (!key) {
|
||||
return defaultValue
|
||||
@@ -16,6 +28,10 @@ function loadDraft(key, defaultValue) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: saveDraft supports form-draft.js by holding or executing the save draft 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 saveDraft(key, value) {
|
||||
if (!key) {
|
||||
return
|
||||
@@ -28,6 +44,10 @@ function saveDraft(key, value) {
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: clearDraft supports form-draft.js by holding or executing the clear draft 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 clearDraft(key) {
|
||||
if (!key) {
|
||||
return
|
||||
@@ -37,6 +57,10 @@ function clearDraft(key) {
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: getDraftValue supports form-draft.js by holding or executing the get draft value 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 getDraftValue(key, defaultValue) {
|
||||
const record = loadDraft(key, null)
|
||||
if (!record || typeof record !== 'object' || !Object.prototype.hasOwnProperty.call(record, 'value')) {
|
||||
@@ -45,6 +69,10 @@ function getDraftValue(key, defaultValue) {
|
||||
return record.value
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: scheduleDraftSave supports form-draft.js by holding or executing the schedule draft save 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 scheduleDraftSave(context, key, buildValue, delay) {
|
||||
if (!context) {
|
||||
return
|
||||
@@ -57,6 +85,10 @@ function scheduleDraftSave(context, key, buildValue, delay) {
|
||||
}, delay || 300)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: clearDraftTimer supports form-draft.js by holding or executing the clear draft timer 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 clearDraftTimer(context) {
|
||||
if (context && context.__draftSaveTimer) {
|
||||
clearTimeout(context.__draftSaveTimer)
|
||||
|
||||
Reference in New Issue
Block a user