UNPKG

plus-pro-components

Version:

Page level components developed based on Element Plus.

97 lines (94 loc) 3.75 kB
import { defineComponent, getCurrentInstance, computed, ref, watchEffect, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, Fragment, renderList, resolveDynamicComponent, normalizeProps, createCommentVNode, renderSlot, guardReactiveProps, createTextVNode, toDisplayString } from 'vue'; import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'; import { removeChildrenField } from '../../utils/index.mjs'; import { isFunction } from '../../utils/is.mjs'; var _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "PlusBreadcrumb" }, __name: "index", props: { routes: { default: () => [] }, replace: { type: Boolean, default: false }, renderTitle: {} }, setup(__props) { const props = __props; const instance = getCurrentInstance(); const route = computed( () => instance.appContext.config.globalProperties.$route ); const breadcrumbList = ref([]); watchEffect(() => { var _a; const breadcrumb = ((_a = props.routes) == null ? void 0 : _a.length) ? props.routes : route.value ? route.value.matched : []; breadcrumbList.value = breadcrumb.filter((item) => { var _a2; return ((_a2 = item.meta) == null ? void 0 : _a2.hideInBreadcrumb) !== true; }); }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(ElBreadcrumb), mergeProps(_ctx.$attrs, { class: ["plus-breadcrumb", { "no-data": breadcrumbList.value.length === 0 }] }), { default: withCtx(() => [ (openBlock(true), createElementBlock( Fragment, null, renderList(breadcrumbList.value, (item) => { return openBlock(), createBlock(unref(ElBreadcrumbItem), { key: item.path, class: "plus-breadcrumb-item", to: item.redirect || item.path, replace: _ctx.replace }, { default: withCtx(() => { var _a; return [ _ctx.renderTitle && unref(isFunction)(_ctx.renderTitle) ? (openBlock(), createBlock( resolveDynamicComponent(_ctx.renderTitle), normalizeProps(mergeProps({ key: 0 }, unref(removeChildrenField)(item))), null, 16 /* FULL_PROPS */ )) : _ctx.$slots["breadcrumb-item-title"] ? (openBlock(), createElementBlock( Fragment, { key: 1 }, [ createCommentVNode(" \u9762\u5305\u5C51title \u63D2\u69FD "), renderSlot(_ctx.$slots, "breadcrumb-item-title", normalizeProps(guardReactiveProps(item))) ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */ )) : (openBlock(), createElementBlock( Fragment, { key: 2 }, [ createTextVNode( toDisplayString(((_a = item.meta) == null ? void 0 : _a.title) || item.name || item.path), 1 /* TEXT */ ) ], 64 /* STABLE_FRAGMENT */ )) ]; }), _: 2 /* DYNAMIC */ }, 1032, ["to", "replace"]); }), 128 /* KEYED_FRAGMENT */ )) ]), _: 3 /* FORWARDED */ }, 16, ["class"]); }; } }); export { _sfc_main as default };