Files
zhibo/node_modules/ele-admin/es/ele-pro-layout/components/pro-tab-dropdown.js
T
xiaoyu 5488f5f0a2 init
2023-05-22 14:07:59 +08:00

63 lines
1.7 KiB
JavaScript

import Locale from "element-ui/lib/mixins/locale";
const proTabDropdown = {
name: "ProTabDropdown",
mixins: [Locale],
props: {
active: String,
showRefresh: Boolean,
bodyFullscreen: Boolean
},
emits: ["menu-click"],
methods: {
onClick(command) {
this.$emit("menu-click", command);
}
},
render(h) {
const hMI = (command, label, icon) => {
return h("el-dropdown-item", { props: { command, icon } }, [label]);
};
const itemNodes = (() => {
const dropSlot = this.$scopedSlots.dropdown;
if (typeof dropSlot === "function") {
return dropSlot({ active: this.active, refresh: this.showRefresh });
}
const items = [
hMI(
"fullscreen",
this.bodyFullscreen ? this.t("ele.tabs.fullscreenExit") : this.t("ele.tabs.fullscreen"),
this.bodyFullscreen ? "el-icon-_compress" : "el-icon-full-screen"
),
hMI("left", this.t("ele.tabs.closeLeft"), "el-icon-back"),
hMI("right", this.t("ele.tabs.closeRight"), "el-icon-right"),
hMI("other", this.t("ele.tabs.closeOther"), "el-icon-remove-outline"),
hMI("all", this.t("ele.tabs.closeAll"), "el-icon-circle-close")
];
if (this.showRefresh) {
items.push(
hMI("reload", this.t("ele.tabs.reload"), "el-icon-refresh-right")
);
}
return items;
})();
return h(
"el-dropdown",
{
class: "ele-admin-tabs-drop",
on: { command: this.onClick }
},
[
h("i", { class: "el-icon-arrow-down" }),
h(
"el-dropdown-menu",
{ slot: "dropdown", class: "ele-dropdown-menu-pro" },
itemNodes
)
]
);
}
};
export {
proTabDropdown as default
};