Files

41 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 18:45:41 +08:00
/**
* Purpose: ensureStore supports page-state.js by holding or executing the ensure store 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 ensureStore() {
const app = getApp()
app.globalData.pageDirtyFlags = app.globalData.pageDirtyFlags || {}
return app.globalData.pageDirtyFlags
}
2026-05-23 18:45:41 +08:00
/**
* Purpose: markDirty supports page-state.js by holding or executing the mark dirty 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 markDirty(key) {
if (!key) {
return
}
const store = ensureStore()
store[key] = true
}
2026-05-23 18:45:41 +08:00
/**
* Purpose: consumeDirty supports page-state.js by holding or executing the consume dirty 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 consumeDirty(key) {
if (!key) {
return false
}
const store = ensureStore()
const value = Boolean(store[key])
delete store[key]
return value
}
module.exports = {
markDirty,
consumeDirty
}