This action will force synchronization from 小海同学/store-miniprogram, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
/*!* omix v2.4.0 by dntzhang* Github: https://github.com/Tencent/omi* MIT Licensed.*/import obaa from './obaa'import { getPath, needUpdate, fixPath, getUsing } from './path'function create(store, option) {if (arguments.length === 2) {if (!store.instances) {store.instances = {}}if (!store.__changes_) {store.__changes_ = []}const changes = store.__changes_if (!store.onChange) {store.onChange = function (fn) {changes.push(fn)}}if (!store.offChange) {store.offChange = function (fn) {for (let i = 0, len = changes.length; i < len; i++) {if (changes[i] === fn) {changes.splice(i, 1)break}}}}const hasData = typeof option.data !== 'undefined'let cloneif (option.data) {clone = JSON.parse(JSON.stringify(option.data))option.data.$ = store.data} else {option.data = store.data}observeStore(store)const onLoad = option.onLoadconst onUnload = option.onUnloadoption.onLoad = function (e) {this.store = storeoption.use && (this.__updatePath = getPath(option.use))this.__use = option.usethis.__hasData = hasDataif (hasData) {Object.assign(option.data, JSON.parse(JSON.stringify(clone)))}store.instances[this.route] = store.instances[this.route] || []store.instances[this.route].push(this)this.computed = option.computedthis.setData(option.data)const using = getUsing(store.data, option.use)option.computed && compute(option.computed, store, using, this)this.setData(using)onLoad && onLoad.call(this, e)}option.onUnload = function (e) {store.instances[this.route] = store.instances[this.route].filter(ins => ins !== this)onUnload && onUnload.call(this, e)}Page(option)} else {store.lifetimes = store.lifetimes || {}const ready = store.lifetimes.ready || store.readystore.ready = store.lifetimes.ready = function () {const page = getCurrentPages()[getCurrentPages().length - 1]store.use && (this.__updatePath = getPath(store.use))this.store = page.storethis.__use = store.usethis.computed = store.computedstore.data = this.store.datathis.setData(store.data)const using = getUsing(this.store.data, store.use)store.computed && compute(store.computed, this.store, using, this)this.setData(using)page._omixComponents = page._omixComponents || []page._omixComponents.push(this)ready && ready.call(this)}Component(store)}}create.Page = function (store, option) {create(store, option)}create.Component = function (store, option) {if (arguments.length === 2) {if (!store.instances) {store.instances = {}}if (!store.__changes_) {store.__changes_ = []}const changes = store.__changes_if (!store.onChange) {store.onChange = function (fn) {changes.push(fn)}}if (!store.offChange) {store.offChange = function (fn) {for (let i = 0, len = changes.length; i < len; i++) {if (changes[i] === fn) {changes.splice(i, 1)break}}}}const hasData = typeof option.data !== 'undefined'let cloneif (option.data) {clone = JSON.parse(JSON.stringify(option.data))option.data.$ = store.data} else {option.data = store.data}observeStore(store)const detached = option.detachedoption.lifetimes = option.lifetimes || {}const created = option.lifetimes.created || option.createdconst ready = option.lifetimes.ready || option.readyoption.created = option.lifetimes.created = function (e) {this.store = storeoption.use && (this.__updatePath = getPath(option.use))this.__use = option.usethis.__hasData = hasDataif (hasData) {Object.assign(option.data, JSON.parse(JSON.stringify(clone)))}created && created.call(this, e)}option.ready = option.lifetimes.ready = function (e) {const store = this.storestore.instances[this.route] = store.instances[this.route] || []store.instances[this.route].push(this)this.computed = option.computedthis.setData(option.data)const using = getUsing(store.data, option.use)option.computed && compute(option.computed, store, using, this)this.setData(using)ready && ready.call(this, e)}option.lifetimes.detached = option.detached = function (e) {this.store.instances[this.route] = this.store.instances[this.route].filter(ins => ins !== this)detached && detached.call(this, e)}Component(option)} else {store.lifetimes = store.lifetimes || {}const ready = store.lifetimes.ready || store.readystore.ready = store.lifetimes.ready = function () {const page = getCurrentPages()[getCurrentPages().length - 1]store.use && (this.__updatePath = getPath(store.use))this.store = page.storethis.__use = store.usethis.computed = store.computedstore.data = this.store.datathis.setData(store.data)const using = getUsing(this.store.data, store.use)store.computed && compute(store.computed, this.store, using, this)this.setData(using)page._omixComponents = page._omixComponents || []page._omixComponents.push(this)ready && ready.call(this)}Component(store)}}function compute(computed, store, using, scope) {for (let key in computed) {using[key] = computed[key].call(store.data, scope)}}function observeStore(store) {const oba = obaa(store.data, (prop, value, old, path) => {let patch = {}if (prop.indexOf('Array-push') === 0) {let dl = value.length - old.lengthfor (let i = 0; i < dl; i++) {patch[fixPath(path + '-' + (old.length + i))] = value[(old.length + i)]}} else if (prop.indexOf('Array-') === 0) {patch[fixPath(path)] = value} else {patch[fixPath(path + '-' + prop)] = value}_update(patch, store)})if (!store.set) {store.set = function (obj, prop, val) {obaa.set(obj, prop, val, oba)}}const backer = store.dataObject.defineProperty(store, 'data', {enumerable: true,get: function() {return backer},set: function() {throw new Error('You must not replace store.data directly, instead assign nest prop')}})}function _update(kv, store) {for (let key in store.instances) {store.instances[key].forEach(ins => {_updateOne(kv, store, ins)if(ins._omixComponents){ins._omixComponents.forEach(compIns => {_updateOne(kv, store, compIns)})}})}store.__changes_.forEach(change => {change(kv)})store.debug && storeChangeLogger(store, kv)}function _updateOne(kv, store, ins){if (!(store.updateAll || ins.__updatePath && needUpdate(kv, ins.__updatePath))) {return}if (!ins.__hasData) {return _updateImpl(kv, store, ins)}const patch = Object.assign({}, kv)for (let pk in patch) {if (!/\$\./.test(pk)) {patch['$.' + pk] = kv[pk]delete patch[pk]}}_updateImpl(patch, store, ins)}function _updateImpl(data, store, ins) {if (!wx.nextTick) {return _doUpdate(data, store, ins)}if (ins._omixDataBuffer === undefined) {ins._omixDataBuffer = {}}Object.assign(ins._omixDataBuffer, data)if (!ins._omixTickScheduled) {wx.nextTick(function() {_doUpdate(ins._omixDataBuffer, store, ins)ins._omixDataBuffer = {}ins._omixTickScheduled = false})ins._omixTickScheduled = true}}function _doUpdate(data, store, ins) {if (Object.keys(data).length === 0) {return}ins.setData.call(ins, data)const using = getUsing(store.data, ins.__use)ins.computed && compute(ins.computed, store, using, ins)ins.setData.call(ins, using)}function storeChangeLogger(store, diffResult) {try {const preState = wx.getStorageSync(`CurrentState`) || {}const title = `Data Changed`console.groupCollapsed(`%c ${title} %c ${Object.keys(diffResult)}`, 'color:#e0c184; font-weight: bold', 'color:#f0a139; font-weight: bold')console.log(`%c Pre Data`, 'color:#ff65af; font-weight: bold', preState)console.log(`%c Change Data`, 'color:#3d91cf; font-weight: bold', diffResult)console.log(`%c Next Data`, 'color:#2c9f67; font-weight: bold', store.data)console.groupEnd()wx.setStorageSync(`CurrentState`, store.data)} catch (e) {console.log(e)}}create.obaa = obaaexport default create
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。