171 lines
6.0 KiB
JavaScript
171 lines
6.0 KiB
JavaScript
import ProMenus from "./pro-menus";
|
|
function normalizeComponent(scriptExports, render2, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
if (render2) {
|
|
options.render = render2;
|
|
options.staticRenderFns = staticRenderFns;
|
|
options._compiled = true;
|
|
}
|
|
if (functionalTemplate) {
|
|
options.functional = true;
|
|
}
|
|
if (scopeId) {
|
|
options._scopeId = "data-v-" + scopeId;
|
|
}
|
|
var hook;
|
|
if (moduleIdentifier) {
|
|
hook = function(context) {
|
|
context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
|
|
if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
|
|
context = __VUE_SSR_CONTEXT__;
|
|
}
|
|
if (injectStyles) {
|
|
injectStyles.call(this, context);
|
|
}
|
|
if (context && context._registeredComponents) {
|
|
context._registeredComponents.add(moduleIdentifier);
|
|
}
|
|
};
|
|
options._ssrRegister = hook;
|
|
} else if (injectStyles) {
|
|
hook = shadowMode ? function() {
|
|
injectStyles.call(
|
|
this,
|
|
(options.functional ? this.parent : this).$root.$options.shadowRoot
|
|
);
|
|
} : injectStyles;
|
|
}
|
|
if (hook) {
|
|
if (options.functional) {
|
|
options._injectStyles = hook;
|
|
var originalRender = options.render;
|
|
options.render = function renderWithStyleInjection(h, context) {
|
|
hook.call(context);
|
|
return originalRender(h, context);
|
|
};
|
|
} else {
|
|
var existing = options.beforeCreate;
|
|
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
}
|
|
}
|
|
return {
|
|
exports: scriptExports,
|
|
options
|
|
};
|
|
}
|
|
const _sfc_main = {
|
|
name: "ProHeader",
|
|
components: { ProMenus },
|
|
props: {
|
|
projectName: String,
|
|
levels: Array,
|
|
menus: Array,
|
|
active: String,
|
|
headStyle: String,
|
|
collapse: Boolean,
|
|
showLeftTool: Boolean,
|
|
showCollapse: Boolean,
|
|
showRefresh: Boolean,
|
|
showBreadcrumb: Boolean,
|
|
breadcrumbSeparator: String
|
|
},
|
|
emits: ["logo-click", "reload-page", "toggle-collapse", "open", "close"],
|
|
data() {
|
|
return {
|
|
canScroll: true
|
|
};
|
|
},
|
|
computed: {
|
|
isPrimary() {
|
|
return this.headStyle === "primary";
|
|
},
|
|
themeClass() {
|
|
return this.headStyle !== "light" ? "ele-menu-dark" : "";
|
|
}
|
|
},
|
|
methods: {
|
|
toggleCollapse() {
|
|
this.$emit("toggle-collapse");
|
|
},
|
|
reloadPage() {
|
|
this.$emit("reload-page");
|
|
},
|
|
onLogoClick() {
|
|
this.$emit("logo-click");
|
|
},
|
|
onOpen(index, indexPath) {
|
|
this.$emit("open", index, indexPath);
|
|
},
|
|
onClose(index, indexPath) {
|
|
this.$emit("close", index, indexPath);
|
|
},
|
|
onHeaderNavScroll(e, isFirefox) {
|
|
var _a, _b;
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
const elem = (_b = (_a = e.currentTarget) == null ? void 0 : _a.parentNode) == null ? void 0 : _b.parentNode;
|
|
if (this.canScroll && elem) {
|
|
this.canScroll = false;
|
|
const wheelDelta = e.wheelDelta || e.detail;
|
|
const delta = isFirefox ? -wheelDelta : wheelDelta;
|
|
if (delta > 0) {
|
|
elem.scrollLeft -= 45;
|
|
} else if (delta < 0) {
|
|
elem.scrollLeft += 45;
|
|
}
|
|
setTimeout(() => {
|
|
this.canScroll = true;
|
|
}, 5);
|
|
}
|
|
},
|
|
onFirefoxScroll(e) {
|
|
this.onHeaderNavScroll(e, true);
|
|
},
|
|
updateScrollbar() {
|
|
var _a;
|
|
(_a = this.$refs.scrollbar) == null ? void 0 : _a.update();
|
|
}
|
|
},
|
|
mounted() {
|
|
var _a, _b;
|
|
(_b = (_a = this.$refs.menu) == null ? void 0 : _a.$el) == null ? void 0 : _b.addEventListener(
|
|
"DOMMouseScroll",
|
|
this.onFirefoxScroll
|
|
);
|
|
},
|
|
beforeDestroy() {
|
|
var _a, _b;
|
|
(_b = (_a = this.$refs.menu) == null ? void 0 : _a.$el) == null ? void 0 : _b.removeEventListener(
|
|
"DOMMouseScroll",
|
|
this.onFirefoxScroll
|
|
);
|
|
}
|
|
};
|
|
var _sfc_render = function render() {
|
|
var _vm = this, _c = _vm._self._c;
|
|
return _c("div", { class: ["ele-admin-header", { "ele-admin-header-primary": _vm.isPrimary }] }, [_c("div", { staticClass: "ele-admin-logo", on: { "click": _vm.onLogoClick } }, [_vm._t("logo"), _vm.projectName ? _c("span", [_vm._v(_vm._s(_vm.projectName))]) : _vm._e()], 2), _vm.showLeftTool ? _c("div", { staticClass: "ele-admin-header-tool" }, [_vm.showCollapse ? _c("div", { staticClass: "ele-admin-header-tool-item", on: { "click": _vm.toggleCollapse } }, [_c("i", { class: _vm.collapse ? "el-icon-_unfold" : "el-icon-_fold" })]) : _vm._e(), _vm.showRefresh ? _c("div", { staticClass: "ele-admin-header-tool-item", on: { "click": _vm.reloadPage } }, [_c("i", { staticClass: "el-icon-refresh-right" })]) : _vm._e(), _vm._t("left")], 2) : _vm._e(), _vm.showBreadcrumb ? _c("div", { staticClass: "ele-admin-breadcrumb" }, [_c("el-breadcrumb", { attrs: { "separator": _vm.breadcrumbSeparator } }, _vm._l(_vm.levels, function(d) {
|
|
return _c("el-breadcrumb-item", { key: d.fullPath, attrs: { "to": d.home ? d.fullPath : void 0 } }, [_vm._v(" " + _vm._s(d.title) + " ")]);
|
|
}), 1)], 1) : _vm._e(), _vm._t("center"), _c("div", { staticClass: "ele-admin-header-nav" }, [_c("el-scrollbar", { ref: "scrollbar" }, [_c("ProMenus", { ref: "menu", attrs: { "data": _vm.menus, "active": _vm.active, "mode": "horizontal", "title-slot": "top-title", "theme-class": _vm.themeClass }, on: { "open": _vm.onOpen, "close": _vm.onClose }, nativeOn: { "mousewheel": function($event) {
|
|
return _vm.onHeaderNavScroll.apply(null, arguments);
|
|
} }, scopedSlots: _vm._u([_vm._l(Object.keys(_vm.$scopedSlots), function(name) {
|
|
return { key: name, fn: function(props) {
|
|
return [_vm._t(name, null, null, props || {})];
|
|
} };
|
|
})], null, true) })], 1)], 1), _vm._t("right")], 2);
|
|
};
|
|
var _sfc_staticRenderFns = [];
|
|
var __component__ = /* @__PURE__ */ normalizeComponent(
|
|
_sfc_main,
|
|
_sfc_render,
|
|
_sfc_staticRenderFns,
|
|
false,
|
|
null,
|
|
null,
|
|
null,
|
|
null
|
|
);
|
|
const proHeader = __component__.exports;
|
|
export {
|
|
proHeader as default
|
|
};
|