2 lines
6.6 KiB
JavaScript
2 lines
6.6 KiB
JavaScript
import{mapState as e}from"vuex";function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e,t,n,r,o,i,a,s,c,l){"boolean"!=typeof a&&(c=s,s=a,a=!1);var u,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),i?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,c(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},d._ssrRegister=u):t&&(u=a?function(e){t.call(this,l(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,s(e))}),u)if(d.functional){var p=d.render;d.render=function(e,t){return u.call(t),p(e,t)}}else{var h=d.beforeCreate;d.beforeCreate=h?[].concat(h,u):[u]}return n}var o={name:"HeaderUser",data:function(){return{options:[{content:"退出登录",value:"handleLogout"}]}},computed:function(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},e("global",{user:"user",event:"event"})),methods:{clickHandler:function(e){this[e.value]()},handleLogin:function(){this.event.handleLogin&&this.event.handleLogin()},handleLogout:function(){this.event.handleLogout&&this.event.handleLogout()}}},i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"header-user",class:{"is-login":e.user.isLogin}},[e.user.isLogin?n("t-dropdown",{staticClass:"header-user-content",attrs:{placement:"bottom-right",trigger:"hover",options:e.options,minColumnWidth:112},on:{click:e.clickHandler}},[n("span",{staticClass:"header-user-avatar"},[n("t-icon",{attrs:{name:"user"}})],1),e._v(" "),n("span",{staticClass:"header-user-box"},[n("span",{staticClass:"header-user-name"},[e._v(e._s(e.user.info&&e.user.info.name))]),e._v(" "),n("t-icon",{staticClass:"header-user-arrow",attrs:{name:"chevron-down"}})],1)]):n("div",{staticClass:"header-user-login"},[n("span",{staticClass:"header-user-login-btn",on:{click:e.handleLogin}},[e._v("登录")])])],1)};i._withStripped=!0;function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var s={name:"GHeader",components:{headerUser:r({render:i,staticRenderFns:[]},undefined,o,undefined,false,undefined,!1,void 0,void 0,void 0)},mixins:[{methods:{onItemClick:function(e){var t=this,n=e.path,r=e.target,o=e.href;o?window.open(o,r||"_blank"):"_blank"!==r?"_top"!==r?this.$emit(this.selectedEvent,e,(function(){t.$router&&((t.$route&&t.$route.path)!==n&&t.$router.push(n))})):this.$propsFromQiankun.parentInstance&&this.$propsFromQiankun.parentInstance.$router.push(n):window.open(n)}}}],data:function(){return{active:"",selectedEvent:"topbar-selected"}},computed:function(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?a(Object(r),!0).forEach((function(n){t(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},e("global",{topbarActiveKey:"topbarActiveKey",topbarConfig:"topbarConfig",topbarExpandType:"topbarExpandType",headerUserStatus:"headerUserStatus"})),watch:{topbarActiveKey:function(){this.active=this.topbarActiveKey,this.setTopbarActiveMenuItem()}},mounted:function(){this.active=this.topbarActiveKey},methods:{changeHandler:function(e){(console.log("====>> changeHandler",e),"normal"===this.topbarExpandType)&&(this.$router&&(this.$route&&this.$route.path)!==e&&this.$router.push(e))},setTopbarActiveMenuItem:function(){var e=this.getActiveMenuItem(this.topbarConfig,this.active);this.$store.commit("global/".concat(this.$storeGlobalTypes.SET_TOPBAR_ACTIVE_MENU_ITEM),e||{})},getActiveMenuItem:function(e,t){for(var n,r=e.length,o=0;o<r&&!n;o++){var i=e[o],a=i.key||i.href||i.path||i.name;if(i.children&&i.children.length)n=this.getActiveMenuItem(i.children,t);else if(a===t)return i}return n}}},c=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("t-head-menu",{attrs:{value:e.active,expandType:e.topbarExpandType},on:{change:e.changeHandler}},[n("template",{slot:"logo"},[e._t("headLogo")],2),e._v(" "),e._l(e.topbarConfig,(function(t,r){return[t.children?n("t-submenu",{key:r,attrs:{value:t.key||t.name}},[n("span",{attrs:{slot:"title"},slot:"title"},[t.imgUrl?n("img",{staticClass:"t-icon g-menu-icon",attrs:{slot:"icon",src:t.imgUrl},slot:"icon"}):t.iconClassName?n("t-icon",{attrs:{slot:"icon",name:t.iconClassName,url:t.iconFontUrl},slot:"icon"}):e._e(),e._v("\n "+e._s(t.name)+"\n ")],1),e._v(" "),e._l(t.children,(function(r,o){return[r.children?n("t-submenu",{key:o,attrs:{value:r.key||r.name}},[n("span",{attrs:{slot:"title"},slot:"title"},[e._v(" "+e._s(r.name))]),e._v(" "),e._l(r.children,(function(t,r){return[n("t-menu-item",{key:r,attrs:{value:t.key||t.href||t.path||t.name},nativeOn:{click:function(n){return e.onItemClick(t)}}},[e._v(e._s(t.name))])]}))],2):n("t-menu-item",{key:o,attrs:{value:r.key||r.href||r.path||t.name},nativeOn:{click:function(t){return e.onItemClick(r)}}},[r.imgUrl?n("img",{staticClass:"t-icon g-menu-icon",attrs:{slot:"icon",src:r.imgUrl},slot:"icon"}):r.iconClassName?n("t-icon",{attrs:{slot:"icon",name:r.iconClassName,url:r.iconFontUrl},slot:"icon"}):e._e(),e._v(e._s(r.name)+"\n ")],1)]}))],2):n("t-menu-item",{key:r,attrs:{value:t.key||t.href||t.path||t.name},nativeOn:{click:function(n){return e.onItemClick(t)}}},[t.imgUrl?n("img",{staticClass:"t-icon g-menu-icon",attrs:{slot:"icon",src:t.imgUrl},slot:"icon"}):t.iconClassName?n("t-icon",{attrs:{slot:"icon",name:t.iconClassName,url:t.iconFontUrl},slot:"icon"}):e._e(),e._v(e._s(t.name)+"\n ")],1)]})),e._v(" "),n("template",{slot:"options"},[n("div",{staticClass:"g-header-right-icon"},[e._t("headOptions")],2),e._v(" "),e.headerUserStatus?n("header-user"):e._e()],1)],2)};c._withStripped=!0;var l=r({render:c,staticRenderFns:[]},undefined,s,undefined,false,undefined,!1,void 0,void 0,void 0);export{l as Header,l as default};
|