/** * 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 } /** * 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 } /** * 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 }