6 lines
6.9 KiB
JavaScript
6 lines
6.9 KiB
JavaScript
|
/**
|
||
|
* vuex v2.0.0
|
||
|
* (c) 2016 Evan You
|
||
|
* @license MIT
|
||
|
*/
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Vuex=e()}(this,function(){"use strict";function t(t){b&&(t._devtoolHook=b,b.emit("vuex:init",t),b.on("vuex:travel-to-state",function(e){t.replaceState(e)}),t.subscribe(function(t,e){b.emit("vuex:mutation",t,e)}))}function e(t){function e(){var t=this.$options;t.store?this.$store=t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}var n=Number(t.version.split(".")[0]);if(n>=2){var o=t.config._lifecycleHooks.indexOf("init")>-1;t.mixin(o?{init:e}:{beforeCreate:e})}else{var i=t.prototype._init;t.prototype._init=function(t){void 0===t&&(t={}),t.init=t.init?[e].concat(t.init):e,i.call(this,t)}}}function n(t){var e={};return s(t).forEach(function(t){var n=t.key,o=t.val;e[n]=function(){return"function"==typeof o?o.call(this,this.$store.state,this.$store.getters):this.$store.state[o]}}),e}function o(t){var e={};return s(t).forEach(function(t){var n=t.key,o=t.val;e[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return this.$store.commit.apply(this.$store,[o].concat(t))}}),e}function i(t){var e={};return s(t).forEach(function(t){var n=t.key,o=t.val;e[n]=function(){return o in this.$store.getters||console.error("[vuex] unknown getter: "+o),this.$store.getters[o]}}),e}function r(t){var e={};return s(t).forEach(function(t){var n=t.key,o=t.val;e[n]=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return this.$store.dispatch.apply(this.$store,[o].concat(t))}}),e}function s(t){return Array.isArray(t)?t.map(function(t){return{key:t,val:t}}):Object.keys(t).map(function(e){return{key:e,val:t[e]}})}function u(t){return null!==t&&"object"==typeof t}function a(t){return t&&"function"==typeof t.then}function c(t,e){if(!t)throw new Error("[vuex] "+e)}function f(t,e){if(e.actions&&(t.actions=e.actions),e.mutations&&(t.mutations=e.mutations),e.getters&&(t.getters=e.getters),e.modules)for(var n in e.modules){if(!t.modules||!t.modules[n])return void console.warn("[vuex] trying to add a new module '"+n+"' on hot reloading, manual reload is needed");f(t.modules[n],e.modules[n])}}function l(t){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null);var e=t.state;p(t,e,[],t._options,!0),Object.keys(t._runtimeModules).forEach(function(n){p(t,e,n.split("."),t._runtimeModules[n],!0)}),h(t,e)}function h(t,e){var n=t._vm;t.getters={};var o=t._wrappedGetters,i={};Object.keys(o).forEach(function(e){var n=o[e];i[e]=function(){return n(t)},Object.defineProperty(t.getters,e,{get:function(){return t._vm[e]}})});var r=w.config.silent;w.config.silent=!0,t._vm=new w({data:{state:e},computed:i}),w.config.silent=r,t.strict&&y(t),n&&(t._withCommit(function(){n.state=null}),w.nextTick(function(){return n.$destroy()}))}function p(t,e,n,o,i){var r=!n.length,s=o.state,u=o.actions,a=o.mutations,c=o.getters,f=o.modules;if(!r&&!i){var l=_(e,n.slice(0,-1)),h=n[n.length-1];t._withCommit(function(){w.set(l,h,s||{})})}a&&Object.keys(a).forEach(function(e){d(t,e,a[e],n)}),u&&Object.keys(u).forEach(function(e){m(t,e,u[e],n)}),c&&v(t,c,n),f&&Object.keys(f).forEach(function(o){p(t,e,n.concat(o),f[o],i)})}function d(t,e,n,o){void 0===o&&(o=[]);var i=t._mutations[e]||(t._mutations[e]=[]);i.push(function(e){n(_(t.state,o),e)})}function m(t,e,n,o){void 0===o&&(o=[]);var i=t._actions[e]||(t._actions[e]=[]),r=t.dispatch,s=t.commit;i.push(function(e,i){var u=n({dispatch:r,commit:s,getters:t.getters,state:_(t.state,o),rootState:t.state},e,i);return a(u)||(u=Promise.resolve(u)),t._devtoolHook?u.catch(function(e){throw t._devtoolHook.emit("vuex:error",e),e}):u})}function v(t,e,n){Object.keys(e).forEach(function(o){var i=e[o];return t._wrappedGetters[o]?void console.error("[vuex] duplicate getter key: "+o):void(t._wrappedGetters[o]=function(t){return i(_(t.state,n),t.getters,t.state)})})}function y(t){t._vm.$watch("state",function(){c(t._committing,"Do not mutate vuex store state outside mutation handlers.")},{deep:!0,sync:!0})}function _(t,e){return e.length?e.re
|