vue-router-tab.umd.min.js 25 KB

12
  1. (function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("vue")):"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vue-router-tab"]=e(require("vue")):t["vue-router-tab"]=e(t["Vue"])})("undefined"!==typeof self?self:this,function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"2d3b":function(t,e,n){},4795:function(t,e,n){t.exports=n("bbdd")},"8bbf":function(e,n){e.exports=t},"96cf":function(t,e){!function(e){"use strict";var n,r=Object.prototype,i=r.hasOwnProperty,o="function"===typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag",u="object"===typeof t,l=e.regeneratorRuntime;if(l)u&&(t.exports=l);else{l=e.regeneratorRuntime=u?t.exports:{},l.wrap=x;var f="suspendedStart",h="suspendedYield",d="executing",v="completed",p={},m={};m[a]=function(){return this};var b=Object.getPrototypeOf,g=b&&b(b(E([])));g&&g!==r&&i.call(g,a)&&(m=g);var y=C.prototype=T.prototype=Object.create(m);_.prototype=y.constructor=C,C.constructor=_,C[c]=_.displayName="GeneratorFunction",l.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},l.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,C):(t.__proto__=C,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(y),t},l.awrap=function(t){return{__await:t}},L(k.prototype),k.prototype[s]=function(){return this},l.AsyncIterator=k,l.async=function(t,e,n,r){var i=new k(x(t,e,n,r));return l.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},L(y),y[c]="Generator",y[a]=function(){return this},y.toString=function(){return"[object Generator]"},l.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){while(e.length){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=E,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(A),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return s.type="throw",s.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;A(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),p}}}function x(t,e,n,r){var i=e&&e.prototype instanceof T?e:T,o=Object.create(i.prototype),a=new j(r||[]);return o._invoke=O(t,n,a),o}function w(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(r){return{type:"throw",arg:r}}}function T(){}function _(){}function C(){}function L(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function k(t){function e(n,r,o,a){var s=w(t[n],t,r);if("throw"!==s.type){var c=s.arg,u=c.value;return u&&"object"===typeof u&&i.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(u).then(function(t){c.value=t,o(c)},function(t){return e("throw",t,o,a)})}a(s.arg)}var n;function r(t,r){function i(){return new Promise(function(n,i){e(t,r,n,i)})}return n=n?n.then(i,i):i()}this._invoke=r}function O(t,e,n){var r=f;return function(i,o){if(r===d)throw new Error("Generator is already running");if(r===v){if("throw"===i)throw o;return S()}n.method=i,n.arg=o;while(1){var a=n.delegate;if(a){var s=$(a,n);if(s){if(s===p)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=d;var c=w(t,e,n);if("normal"===c.type){if(r=n.done?v:h,c.arg===p)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=v,n.method="throw",n.arg=c.arg)}}}function $(t,e){var r=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,$(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var i=w(r,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,p;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function R(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(R,this),this.reset(!0)}function E(t){if(t){var e=t[a];if(e)return e.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){while(++r<t.length)if(i.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}return{next:S}}function S(){return{value:n,done:!0}}}(function(){return this||"object"===typeof self&&self}()||Function("return this")())},bbdd:function(t,e,n){var r=function(){return this||"object"===typeof self&&self}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,o=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=n("96cf"),i)r.regeneratorRuntime=o;else try{delete r.regeneratorRuntime}catch(a){r.regeneratorRuntime=void 0}},ca5a:function(t,e,n){},d8de:function(t,e,n){"use strict";var r=n("2d3b"),i=n.n(r);i.a},f143:function(t,e,n){"use strict";var r=n("ca5a"),i=n.n(r);i.a},fb15:function(t,e,n){"use strict";var r;(n.r(e),"undefined"!==typeof window)&&((r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=r[1]));var i={created:function(){var t=this.$route,e=this.$vnode,n=e&&e.data.routerAlive;if(!n)return!1;this._isRouterPage=!0;var r=n.getAliveId(t),i=n.set(r,{route:t,vm:this});this.$watch("routeTab",function(t,e){i.tab="string"===typeof t?{title:t}:t,n.set(r,i)},{deep:!0,immediate:!0})},activated:function(){var t=this.$routerTab,e=this.$vnode,n=this._isRouterPage;if(!n)return!1;var r=e.componentOptions.Ctor.cid;this._ctorId&&this._ctorId!==r&&(this.$destroy(),t.refreshTab()),this._ctorId=r}},o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"router-tab"},[n("header",{staticClass:"router-tab-header"},[n("div",{staticClass:"router-tab-scroll"},[n("transition-group",t._b({staticClass:"router-tab-nav",attrs:{tag:"ul"},on:{"after-enter":t.onTabTransitionEnd,"after-leave":t.onTabTransitionEnd}},"transition-group","string"===typeof t.tabTransition?{name:t.tabTransition}:t.tabTransition,!1),t._l(t.items,function(e,r){var i=e.id,o=e.to,a=e.title,s=e.icon,c=e.tips,u=e.closable;return n("router-link",{key:i||o,staticClass:"router-tab-item",class:{actived:t.activedTab===i,contextmenu:t.contextmenu.id===i},attrs:{tag:"li",title:c||a||"",to:o},nativeOn:{contextmenu:function(e){return e.preventDefault(),function(e){return t.showContextmenu(i,r,e)}(e)}}},[t._t("default",[s?n("i",{staticClass:"tab-icon",class:s}):t._e(),n("span",{staticClass:"tab-title"},[t._v(t._s(a||t.lang.tab.untitled))]),!1!==u&&t.items.length>1?n("i",{staticClass:"tab-close",attrs:{title:t.lang.contextmenu.close},on:{click:function(e){return e.preventDefault(),t.closeTab(i)}}}):t._e()],null,{tab:t.items[r],tabs:t.items,index:r})],2)}),1)],1),n("a",{staticClass:"el-icon-caret-left nav-prev",on:{click:function(e){return t.tabScroll("left")}}}),n("a",{staticClass:"el-icon-caret-right nav-next",on:{click:function(e){return t.tabScroll("right")}}})]),n("div",{staticClass:"router-tab-container",class:{loading:t.loading}},[n("router-alive",{ref:"routerAlive",attrs:{"alive-id":t.aliveId},on:{update:t.updateTab}},[n("transition",t._b({attrs:{appear:""},on:{"after-enter":t.onPageTransitionEnd,"after-leave":t.onPageTransitionEnd}},"transition","string"===typeof t.pageTransition?{name:t.pageTransition}:t.pageTransition,!1),[t.isRouterAlive?n("router-view",t._b({ref:"routerView"},"router-view",t.routerView,!1)):t._e()],1)],1)],1),n("transition",{attrs:{name:"router-tab-zoom-lt"}},[t.contextmenu.id?n("div",{staticClass:"router-tab-contextmenu",style:"left: "+t.contextmenu.left+"px; top: "+t.contextmenu.top+"px;"},[n("a",{staticClass:"contextmenu-item",attrs:{disabled:!t.isContextTabActived},on:{click:function(e){t.isContextTabActived&&t.refreshTab(t.contextmenu.id)}}},[t._v("\n "+t._s(t.lang.contextmenu.refresh)+"\n ")]),n("a",{staticClass:"contextmenu-item",attrs:{disabled:t.items.length<2},on:{click:function(e){t.items.length>1&&t.refreshAll()}}},[t._v("\n "+t._s(t.lang.contextmenu.refreshAll)+"\n ")]),n("a",{staticClass:"contextmenu-item",attrs:{disabled:!t.isContextTabCanBeClosed},on:{click:function(e){t.isContextTabCanBeClosed&&t.closeTab(t.contextmenu.id)}}},[t._v("\n "+t._s(t.lang.contextmenu.close)+"\n ")]),n("a",{staticClass:"contextmenu-item",attrs:{disabled:!t.tabsLeft.length},on:{click:function(e){t.tabsLeft.length&&t.closeMulti(t.tabsLeft)}}},[t._v("\n "+t._s(t.lang.contextmenu.closeLefts)+"\n ")]),n("a",{staticClass:"contextmenu-item",attrs:{disabled:!t.tabsRight.length},on:{click:function(e){t.tabsRight.length&&t.closeMulti(t.tabsRight)}}},[t._v("\n "+t._s(t.lang.contextmenu.closeRights)+"\n ")]),n("a",{staticClass:"contextmenu-item",attrs:{disabled:!t.tabsOther.length},on:{click:function(e){t.tabsOther.length&&t.closeMulti(t.tabsOther)}}},[t._v("\n "+t._s(t.lang.contextmenu.closeOthers)+"\n ")])]):t._e()])],1)},a=[],s=n("4795"),c=n.n(s),u=n("8bbf"),l=n.n(u),f={path:function(t){return t.path},fullpath:function(t){return t.fullPath.replace(t.hash,"")}},h=Object.create(null),d=[];function v(t){return void 0!==t&&null!==t}function p(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=null;return function(){var r=this,i=arguments;clearTimeout(n),n=setTimeout(function(){t.call(r,i)},e)}}function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t.scrollTo?t.scrollTo({left:e,top:n,behavior:"smooth"}):(t.scrollLeft=e,t.scrollTop=n)}function b(t){if(Array.isArray(t))for(var e=0;e<t.length;e++){var n=t[e];if(v(n)&&(v(n.componentOptions)||y(n)))return n}}function g(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.$route,e=t.meta&&t.meta.aliveId||this.aliveId;return"string"===typeof e&&(e=f[e.toLowerCase()]),"function"!==typeof e&&(e=f.path),e.bind(this)(t)}function y(t){return t.isComment&&t.asyncFactory}function x(t){return t.hash?t.fullPath.replace(t.hash,""):t.fullPath}function w(t,e){return x(t)===x(e)}function T(t){var e=t.matched;return e[e.length-1].components.default}function _(t,e){return T(t)===T(e)}var C={name:"RouterAlive",props:{aliveId:{type:[String,Function],default:"path"}},beforeCreate:function(){Object.assign(this,{cache:Object.create(null),lastRoute:this.$route})},render:function(){var t=this.$slots.default,e=b(t),n=e&&e.componentOptions;if(n){var r=this.cache,i=this.$route,o=this.lastRoute,a="transition"===n.tag?n.children[0]:e;if(a&&a.componentOptions){var s=this.getAliveId(),c=r[s],u=c||h,l=u.vm,f=u.route,d=!1,v=o!==i,p=v&&_(i,o);v&&(this.lastRoute=i,c||this.set(s,{route:i})),l&&(w(f,i)?a.componentInstance=l:(l.$destroy(),c.vm=null,d=!0)),p&&(d=!0),d&&this.$routerTab.reloadRouter(),a.data.keepAlive=!0,a.data.routerAlive=this}}return e||t&&t[0]},methods:{getAliveId:g,set:function(t,e){var n=this.cache;return this.$emit("update",t,e),n[t]=e},remove:function(t){var e=this.cache,n=e[t];n&&(n.vm&&n.vm.$destroy(),delete e[t]),this.$emit("remove",[t])},clear:function(t){var e=this.cache[t],n=e&&e.vm;n&&(n.$destroy(),e.vm=null)}}},L={tab:{untitled:"无标题"},contextmenu:{refresh:"刷新",refreshAll:"刷新所有",close:"关闭",closeLefts:"关闭左侧",closeRights:"关闭右侧",closeOthers:"关闭其他"},msg:{keepOneTab:"至少应保留1个页签"}},k={tab:{untitled:"Untitled"},contextmenu:{refresh:"Refresh",refreshAll:"Refresh All",close:"Close",closeLefts:"Close to the Left",closeRights:"Close to the Right",closeOthers:"Close Others"},msg:{keepOneTab:"Keep at least 1 tab"}},O={"zh-CN":L,en:k};function $(t,e,n,r,i,o,a){try{var s=t[o](a),c=s.value}catch(u){return void n(u)}s.done?e(c):Promise.resolve(c).then(r,i)}function R(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function a(t){$(o,r,i,a,s,"next",t)}function s(t){$(o,r,i,a,s,"throw",t)}a(void 0)})}}function A(t){return A="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}var j={name:"RouterTab",components:{RouterAlive:C},props:{aliveId:C.props.aliveId,i18n:{type:[String,Object],default:"zh-CN"},tabs:{type:Array,default:function(){return[]}},routerView:Object,tabTransition:{type:[String,Object],default:"router-tab-zoom"},pageTransition:{type:[String,Object],default:function(){return{name:"router-tab-swap",mode:"out-in"}}}},data:function(){return{loading:!1,items:[],activedTab:null,isRouterAlive:!0,contextmenu:{id:null,index:-1,left:0,top:0}}},computed:{lang:function(){var t=null,e=this.i18n;return"string"===typeof e?t=O[e]:"object"===A(e)&&(t=e),t||(t=O["en"]),t},isContextTabActived:function(){return this.contextmenu.id===this.activedTab},isContextTabCanBeClosed:function(){var t=this.items,e=this.contextmenu,n=t[e.index];return t.length>1&&n&&!1!==n.closable},tabsLeft:function(){var t=this.items,e=this.contextmenu,n=e.id,r=e.index;return n?t.slice(0,r).filter(function(t){var e=t.closable;return!1!==e}):d},tabsRight:function(){var t=this.items,e=this.contextmenu,n=e.id,r=e.index;return n?t.slice(r+1).filter(function(t){var e=t.closable;return!1!==e}):d},tabsOther:function(){var t=this.items,e=this.contextmenu.id;return e?t.filter(function(t){var n=t.closable,r=t.id;return!1!==n&&e!==r}):d}},watch:{$route:function(t){this.loading=!1,this.hideContextmenu(),this.updateActivedTab(),this.fixCommentPage()},activedTab:function(){var t=R(c.a.mark(function t(){var e,n,r,i;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,this.$nextTick();case 2:e=this.$el.querySelector(".router-tab-nav .actived"),n=this.$el.querySelector(".router-tab-scroll"),e&&(r=e.offsetLeft,i=n.scrollLeft,(r<i||r+e.clientWidth>i+n.clientWidth)&&this.adjust());case 5:case"end":return t.stop()}},t,this)}));function e(){return t.apply(this,arguments)}return e}(),"contextmenu.id":function(t,e){var n=this;!e&&t?document.addEventListener("click",this.onClick=function(t){t.target!==n.$el.querySelector(".router-tab-contextmenu")&&n.hideContextmenu()}):e&&!t&&document.removeEventListener("click",this.onClick)}},beforeCreate:function(){l.a.prototype.$routerTab=this},created:function(){this.getTabItems(),this.updateActivedTab(),this.$router.beforeEach(this.routerPageLeaveGuard),this.$nextTick(this.adjust)},mounted:function(){window.addEventListener("resize",this.onResize=p(this.adjust))},destroyed:function(){window.removeEventListener("resize",this.onResize)},methods:{getAliveId:g,routerPageLeaveGuard:function(t,e,n){if(this._isDestroyed){var r=this.$router.beforeHooks,i=r.indexOf(this.routerPageLeaveGuard);i>-1&&r.splice(i,1),n()}else{var o=this.getAliveId(t),a=this.$refs.routerAlive,s=a&&a.cache[o]||h,c=s.route;c&&!w(t,c)?this.pageLeavePromise(o,"replace").then(function(){return n()}).catch(function(){return n(!1)}):n()}},getTabItems:function(){var t=this,e=this.tabs,n=this.$router,r={};this.items=e.map(function(e,i){var o="string"===typeof e?{to:e}:e||h,a=o.to,s=o.closable,c=o.title,u=o.tips,l=a&&n.match(a);if(l){var f=t.getRouteTab(l),d=f.id;if(!r[d])return c&&(f.title=c),u&&(f.tips=u),f.closable=!1!==s,r[d]=f}}).filter(function(t){return!!t})},updateActivedTab:function(){this.activedTab=this.getAliveId()},updateTab:function(t,e){var n=e.route,r=e.tab,i=this.items,o=i.findIndex(function(e){var n=e.id;return n===t}),a=Object.assign(this.getRouteTab(n),r);if(o>-1){var s=i[o];a.closable=!1!==s.closable,this.$set(i,o,a)}else i.push(a)},getIdByLocation:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t){var n=this.$router.match(t,this.$router.currentRoute);if(!e)return this.getAliveId(n);var r=x(n),i=this.items.find(function(t){var e=t.to;return e.split("#")[0]===r});return i?i.id:void 0}},getRouteTab:function(t){var e=this.getAliveId(t),n=t.fullPath,r=t.meta,i=r.title,o=r.icon,a=r.tips;return{id:e,to:n,title:i,icon:o,tips:a}},pageLeavePromise:function(t,e){var n=this;return new Promise(function(r,i){var o=n.$refs.routerAlive,a=n.items.find(function(e){return e.id===t}),s=o.cache[t]||h,c=s.vm,u=c&&c.$vnode.componentOptions.Ctor.options.beforePageLeave;"function"===typeof u?u.bind(c)(r,i,a,e):r()})},removeTab:function(){var t=R(c.a.mark(function t(e){var n,r,i;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:if(n=this.items,r=this.$refs.routerAlive,i=n.findIndex(function(t){return t.id===e}),1!==n.length){t.next=5;break}throw new Error(this.lang.msg.keepOneTab);case 5:return t.prev=5,t.next=8,this.pageLeavePromise(e,"close");case 8:r.remove(e),i>-1&&n.splice(i,1),t.next=14;break;case 12:t.prev=12,t.t0=t["catch"](5);case 14:case"end":return t.stop()}},t,this,[[5,12]])}));function e(e){return t.apply(this,arguments)}return e}(),close:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t){var n=this.getIdByLocation(t,e);n&&this.closeTab(n)}else this.closeTab()},closeTab:function(){var t=R(c.a.mark(function t(){var e,n,r,i,o,a,s=arguments;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return e=s.length>0&&void 0!==s[0]?s[0]:this.activedTab,n=this.activedTab,r=this.items,i=this.$router,o=r.findIndex(function(t){return t.id===e}),t.prev=3,t.next=6,this.removeTab(e);case 6:n===e&&(a=r[o]||r[o-1],i.replace(a.to)),t.next=12;break;case 9:t.prev=9,t.t0=t["catch"](3),console.warn(t.t0);case 12:case"end":return t.stop()}},t,this,[[3,9]])}));function e(){return t.apply(this,arguments)}return e}(),closeMulti:function(){var t=R(c.a.mark(function t(e){var n,r,i,o,a,s,u,l,f,h,d=this;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:n=this.items,r=this.$router,i=this.contextmenu,o=n.find(function(t){var e=t.id;return e===i.id}),a=!0,s=!1,u=void 0,t.prev=5,l=e[Symbol.iterator]();case 7:if(a=(f=l.next()).done){t.next=19;break}return h=f.value.id,t.prev=9,t.next=12,this.removeTab(h);case 12:t.next=16;break;case 14:t.prev=14,t.t0=t["catch"](9);case 16:a=!0,t.next=7;break;case 19:t.next=25;break;case 21:t.prev=21,t.t1=t["catch"](5),s=!0,u=t.t1;case 25:t.prev=25,t.prev=26,a||null==l.return||l.return();case 28:if(t.prev=28,!s){t.next=31;break}throw u;case 31:return t.finish(28);case 32:return t.finish(25);case 33:-1===n.findIndex(function(t){var e=t.id;return e===d.activedTab})&&r.replace(o.to);case 34:case"end":return t.stop()}},t,this,[[5,21,25,33],[9,14],[26,,28,32]])}));function e(e){return t.apply(this,arguments)}return e}(),refresh:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(t){var n=this.getIdByLocation(t,e);n&&this.refreshTab(n)}else this.refreshTab()},refreshTab:function(){var t=R(c.a.mark(function t(){var e,n=arguments;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:this.activedTab,t.prev=1,t.next=4,this.pageLeavePromise(e,"refresh");case 4:this.$refs.routerAlive.clear(e),e===this.activedTab&&this.reloadRouter(),t.next=10;break;case 8:t.prev=8,t.t0=t["catch"](1);case 10:case"end":return t.stop()}},t,this,[[1,8]])}));function e(){return t.apply(this,arguments)}return e}(),refreshAll:function(){var t=R(c.a.mark(function t(){var e,n,r,i,o=arguments;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:e=o.length>0&&void 0!==o[0]&&o[0],n=this.$refs.routerAlive,r=n.cache,t.t0=c.a.keys(r);case 4:if((t.t1=t.t0()).done){t.next=20;break}if(i=t.t1.value,e){t.next=17;break}return t.prev=7,t.next=10,this.pageLeavePromise(i,"refresh");case 10:n.clear(i),t.next=15;break;case 13:t.prev=13,t.t2=t["catch"](7);case 15:t.next=18;break;case 17:n.clear(i);case 18:t.next=4;break;case 20:this.reloadRouter();case 21:case"end":return t.stop()}},t,this,[[7,13]])}));function e(){return t.apply(this,arguments)}return e}(),reloadRouter:function(){var t=R(c.a.mark(function t(){var e,n=arguments;return c.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:if(e=n.length>0&&void 0!==n[0]&&n[0],this.isRouterAlive=!1,!e){t.next=6;break}return t.next=5,this.$nextTick();case 5:this.isRouterAlive=!0;case 6:case"end":return t.stop()}},t,this)}));function e(){return t.apply(this,arguments)}return e}(),onTabTransitionEnd:function(){this.adjust()},onPageTransitionEnd:function(){this.isRouterAlive||(this.isRouterAlive=!0)},showContextmenu:function(t,e,n){var r=n||h,i=r.y,o=r.x;Object.assign(this.contextmenu,{id:t,index:e,top:i,left:o})},hideContextmenu:function(){this.showContextmenu(null,-1)},tabScroll:function(t){var e=this.$el.querySelector(".router-tab-header"),n=e.querySelector(".router-tab-scroll"),r=e.clientWidth-110;m(n,n.scrollLeft+("left"===t?-r:r))},adjust:function(){var t=this.$el.querySelector(".router-tab-header"),e=t.querySelector(".router-tab-scroll"),n=e.querySelector(".router-tab-nav"),r=n.querySelector(".actived"),i=n.clientWidth>e.clientWidth;t.classList[i?"add":"remove"]("is-scroll"),r&&i&&m(e,r.offsetLeft+(r.clientWidth-e.clientWidth)/2)},fixCommentPage:function(){8===this.$refs.routerAlive.$el.nodeType&&this.reloadRouter(!0)}}},E=j;n("f143"),n("d8de");function S(t,e,n,r,i,o,a,s){var c,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(c=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):i&&(c=s?function(){i.call(this,this.$root.$options.shadowRoot)}:i),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}var P=S(E,o,a,!1,null,null,null),I=P.exports;I.install=function t(e,n){t.installed||(t.installed=!0,e.component(I.name,I),e.mixin(i))},"undefined"!==typeof window&&window.Vue&&window.Vue.use(I);var N=I;e["default"]=N}})});
  2. //# sourceMappingURL=vue-router-tab.umd.min.js.map