vue-router-tab.umd.min.js 26 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")}({"02eb":function(t,e,n){},4795:function(t,e,n){t.exports=n("96cf")},"4ba7":function(t,e,n){"use strict";var r=n("02eb"),i=n.n(r);i.a},"8bbf":function(e,n){e.exports=t},"96cf":function(t,e,n){var r=function(t){"use strict";var e,n=Object.prototype,r=n.hasOwnProperty,i="function"===typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(t,e,n,r){var i=e&&e.prototype instanceof p?e:p,o=Object.create(i.prototype),a=new O(r||[]);return o._invoke=C(t,n,a),o}function u(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(r){return{type:"throw",arg:r}}}t.wrap=c;var l="suspendedStart",f="suspendedYield",h="executing",d="completed",v={};function p(){}function m(){}function b(){}var g={};g[o]=function(){return this};var y=Object.getPrototypeOf,x=y&&y(y(I([])));x&&x!==n&&r.call(x,o)&&(g=x);var w=b.prototype=p.prototype=Object.create(g);function T(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function _(t){function e(n,i,o,a){var s=u(t[n],t,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===typeof l&&r.call(l,"__await")?Promise.resolve(l.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(l).then(function(t){c.value=t,o(c)},function(t){return e("throw",t,o,a)})}a(s.arg)}var n;function i(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=i}function C(t,e,n){var r=l;return function(i,o){if(r===h)throw new Error("Generator is already running");if(r===d){if("throw"===i)throw o;return R()}n.method=i,n.arg=o;while(1){var a=n.delegate;if(a){var s=L(a,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===l)throw r=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=u(t,e,n);if("normal"===c.type){if(r=n.done?d:f,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=d,n.method="throw",n.arg=c.arg)}}}function L(t,n){var r=t.iterator[n.method];if(r===e){if(n.delegate=null,"throw"===n.method){if(t.iterator["return"]&&(n.method="return",n.arg=e,L(t,n),"throw"===n.method))return v;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var i=u(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,v;var o=i.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,v):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function $(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 k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach($,this),this.reset(!0)}function I(t){if(t){var n=t[o];if(n)return n.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){while(++i<t.length)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}return{next:R}}function R(){return{value:e,done:!0}}return m.prototype=w.constructor=b,b.constructor=m,b[s]=m.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},T(_.prototype),_.prototype[a]=function(){return this},t.AsyncIterator=_,t.async=function(e,n,r,i){var o=new _(c(e,n,r,i));return t.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},T(w),w[s]="Generator",w[o]=function(){return this},w.toString=function(){return"[object Generator]"},t.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}},t.values=I,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},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 n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;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,v):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),v},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),k(n),v}},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;k(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:I(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=r}catch(i){Function("r","regeneratorRuntime = r")(r)}},e42d:function(t,e,n){"use strict";var r=n("f42e"),i=n.n(r);i.a},f42e:function(t,e,n){},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=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",staticClass:"router-tab-page"},"router-view",t.routerView,!1)):t._e()],1)],1),n("transition-group",t._b({staticClass:"router-tab-iframes",attrs:{tag:"div"}},"transition-group","string"===typeof t.pageTransition?{name:t.pageTransition}:t.pageTransition,!1),t._l(t.iframes,function(e){return n("iframe",{directives:[{name:"show",rawName:"v-show",value:e===t.currentIframe,expression:"url === currentIframe"}],key:e,staticClass:"router-tab-iframe",attrs:{src:e,frameborder:"0"}})}),0)],1),n("transition",{attrs:{name:"router-tab-zoom"}},[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)},o=[],a=n("4795"),s=n.n(a),c=n("8bbf"),u=n.n(c),l=Object.create(null),f=[];function h(t){return void 0!==t&&null!==t}function d(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)}}var v={path:function(t){return t.path},fullpath:function(t){return t.fullPath.replace(t.hash,"")}};function p(){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=v[e.toLowerCase()]),"function"!==typeof e&&(e=v.path),e.bind(this)(t)}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(h(n)&&(h(n.componentOptions)||g(n)))return n}}function g(t){return t.isComment&&t.asyncFactory}function y(t){return t.hash?t.fullPath.replace(t.hash,""):t.fullPath}function x(t,e){return y(t)===y(e)}function w(t){var e=t.matched;return e[e.length-1].components.default}function T(t,e){return w(t)===w(e)}var _={tab:{untitled:"无标题"},contextmenu:{refresh:"刷新",refreshAll:"刷新所有",close:"关闭",closeLefts:"关闭左侧",closeRights:"关闭右侧",closeOthers:"关闭其他"},msg:{keepOneTab:"至少应保留1个页签"}},C={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"}},L={"zh-CN":_,en: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||l,f=u.vm,h=u.route,d=!1,v=o!==i,p=v&&T(i,o);v&&(this.lastRoute=i,c||this.set(s,{route:i})),f&&(x(h,i)?a.componentInstance=f:(f.$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:p,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)}}},k={data:function(){return{iframes:[],currentIframe:null}},methods:{getIframePath:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r="".concat(this.basePath,"/iframe/").concat(encodeURIComponent(t));return e&&(r+="/"+e,n&&(r+="/"+n)),r},openIframeTab:function(t,e,n){var r=this.getIframePath(t,e,n);this.$router.push(r)},closeIframeTab:function(t){var e=this.getIframePath(t);this.close(e,!1)},refreshIframeTab:function(t){var e=this.getIframePath(t);this.refresh(e,!1)}}};function O(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 I(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function a(t){O(o,r,i,a,s,"next",t)}function s(t){O(o,r,i,a,s,"throw",t)}a(void 0)})}}function R(t){return R="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},R(t)}var A={name:"RouterTab",components:{RouterAlive:$},mixins:[k],props:{aliveId:$.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=L[e]:"object"===R(e)&&(t=e),t||(t=L["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}):f},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}):f},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}):f}},watch:{$route:function(t){this.loading=!1,this.hideContextmenu(),this.updateActivedTab(),this.fixCommentPage()},activedTab:function(){var t=I(s.a.mark(function t(){var e,n,r,i;return s.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(){u.a.prototype.$routerTab=this;var t=this.$route.matched;this.basePath=(t[t.length-2]||{}).path},created:function(){this.getTabItems(),this.updateActivedTab(),this.$router.beforeEach(this.routerPageLeaveGuard),this.$nextTick(this.adjust)},mounted:function(){window.addEventListener("resize",this.onResize=d(this.adjust))},destroyed:function(){window.removeEventListener("resize",this.onResize)},methods:{getAliveId:p,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]||l,c=s.route;c&&!x(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||l,a=o.to,s=o.closable,c=o.title,u=o.tips,f=a&&n.match(a);if(f){var h=t.getRouteTab(f),d=h.id;if(!r[d])return c&&(h.title=c),u&&(h.tips=u),h.closable=!1!==s,r[d]=h}}).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=y(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]||l,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=I(s.a.mark(function t(e){var n,r,i;return s.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=I(s.a.mark(function t(){var e,n,r,i,o,a,c=arguments;return s.a.wrap(function(t){while(1)switch(t.prev=t.next){case 0:return e=c.length>0&&void 0!==c[0]?c[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=I(s.a.mark(function t(e){var n,r,i,o,a,c,u,l,f,h,d=this;return s.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,c=!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),c=!0,u=t.t1;case 25:t.prev=25,t.prev=26,a||null==l.return||l.return();case 28:if(t.prev=28,!c){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=I(s.a.mark(function t(){var e,n=arguments;return s.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=I(s.a.mark(function t(){var e,n,r,i,o=arguments;return s.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=s.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=I(s.a.mark(function t(){var e,n=arguments;return s.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||l,i=r.clientY,o=r.clientX;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)}}},S=A;n("e42d"),n("4ba7");function P(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 E=P(S,i,o,!1,null,null,null),j=E.exports,N={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(){if(!this._isRouterPage)return!1;var t=this.$vnode.componentOptions.Ctor.cid;this._ctorId&&this._ctorId!==t&&(this.$destroy(),this.$routerTab.refreshTab()),this._ctorId=t}},q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"router-tab-iframe-fake"})},G=[],F={name:"Iframe",props:{src:String,title:String,icon:String},data:function(){return{routeTab:null}},mounted:function(){var t=this.src,e=this.title,n=this.icon,r=this.$routerTab,i=r.iframes;this.routeTab={title:e,icon:n},i.includes(t)||i.push(t),r.currentIframe=t},activated:function(){this.$routerTab.currentIframe=this.src},deactivated:function(){this.$routerTab.currentIframe=null},destroyed:function(){var t=this.src,e=this.$routerTab.iframes,n=e.indexOf(t);n>-1&&e.splice(n,1)}},z=F,M=P(z,q,G,!1,null,null,null),V=M.exports,W=[{path:"iframe/:src/:title?/:icon?",component:V,props:!0,meta:{aliveId:function(t){return"iframe-".concat(t.params.src)}}}];j.install=function t(e,n){t.installed||(t.installed=!0,e.component(j.name,j),e.mixin(N))},"undefined"!==typeof window&&window.Vue&&window.Vue.use(j);var B=j,U=W;n.d(e,"RouterTabRoutes",function(){return U});e["default"]=B}})});
  2. //# sourceMappingURL=vue-router-tab.umd.min.js.map