UNPKG

@matechat/core

Version:

前端智能化场景解决方案UI库,轻松构建你的AI应用。

196 lines (195 loc) 6.4 kB
import "./index.css"; import { openBlock as r, createElementBlock as s, renderSlot as i, createElementVNode as a, defineComponent as C, ref as f, onMounted as E, onUnmounted as T, Fragment as b, createVNode as H, createCommentVNode as p } from "vue"; import { debounce as R } from "lodash-es"; const l = (o, c) => { const d = o.__vccOpts || o; for (const [_, u] of c) d[_] = u; return d; }, V = {}, I = { class: "mc-layout-aside" }; function z(o, c) { return r(), s("div", I, [ i(o.$slots, "default") ]); } const N = /* @__PURE__ */ l(V, [["render", z]]), O = {}, U = { t: "1773994085709", class: "icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "4044", width: "16", height: "16" }; function D(o, c) { return r(), s("svg", U, c[0] || (c[0] = [ a( "path", { d: "M898.133333 512c-12.8-12.8-32-12.8-44.8-2.133333L544 800V149.333333c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v650.666667L170.666667 509.866667c-12.8-12.8-34.133333-10.666667-44.8 2.133333-12.8 12.8-10.666667 34.133333 2.133333 44.8l362.666667 341.333333c2.133333 2.133333 6.4 4.266667 8.533333 6.4 4.266667 2.133333 6.4 2.133333 10.666667 2.133334s8.533333 0 10.666666-2.133334c4.266667-2.133333 6.4-4.266667 8.533334-6.4l362.666666-341.333333c17.066667-12.8 19.2-32 6.4-44.8z", fill: "#666666", "p-id": "4045" }, null, -1 /* HOISTED */ ) ])); } const W = /* @__PURE__ */ l(O, [["render", D]]), F = {}, P = { t: "1773991901622", class: "icon", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "3858", width: "16", height: "16" }; function Y(o, c) { return r(), s("svg", P, c[0] || (c[0] = [ a( "path", { d: "M896 467.2l-362.666667-341.333333c-2.133333-2.133333-6.4-4.266667-8.533333-6.4-4.266667-2.133333-6.4-2.133333-10.666667-2.133334s-8.533333 0-10.666666 2.133334c-4.266667 2.133333-6.4 4.266667-8.533334 6.4l-362.666666 341.333333c-12.8 12.8-12.8 32-2.133334 44.8 12.8 12.8 32 12.8 44.8 2.133333l309.333334-290.133333V874.666667c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V224L853.333333 514.133333c6.4 6.4 14.933333 8.533333 21.333334 8.533334 8.533333 0 17.066667-4.266667 23.466666-10.666667 12.8-12.8 10.666667-32-2.133333-44.8z", fill: "#666666", "p-id": "3859" }, null, -1 /* HOISTED */ ) ])); } const j = /* @__PURE__ */ l(F, [["render", Y]]), q = { class: "mc-layout-content-container" }, G = /* @__PURE__ */ C({ __name: "Content", props: { autoScroll: { type: Boolean, default: !0 }, showScrollArrow: { type: Boolean, default: !0 } }, emits: ["onScrollerWheel", "onScrollerScroll"], setup(o, { expose: c, emit: d }) { const _ = o, u = d, t = f(), w = f(), y = f(!1), $ = f(!1), L = new ResizeObserver(() => { M(); }); let g = !1; const v = (e) => { t.value && t.value.scrollTo({ top: e, behavior: "smooth" }); }, m = () => { var e; v(((e = t.value) == null ? void 0 : e.scrollHeight) || 0); }, S = () => { v(0); }, M = (e = !1) => { _.autoScroll && (g && !e || m()); }, k = (e) => { if (!t.value) return; const n = Math.abs( t.value.scrollTop + t.value.clientHeight - t.value.scrollHeight ) < 32; e.deltaY !== 0 && (g = !n), u("onScrollerWheel", e); }, h = R((e) => { const n = e.target; n && (y.value = n.scrollTop !== 0, $.value = n.scrollTop + n.clientHeight + 32 < n.scrollHeight, u("onScrollerScroll", e)); }, 100), A = () => { var e, n; (e = t.value) == null || e.addEventListener("scroll", h), (n = t.value) == null || n.addEventListener("wheel", k); }, B = () => { var e, n; (e = t.value) == null || e.removeEventListener("scroll", h), (n = t.value) == null || n.removeEventListener("wheel", k); }; return E(() => { L.observe(w.value), A(), h({ target: t.value }); }), T(() => { L.disconnect(), B(); }), c({ scrollerRef: t, updateScroll: M, scrollToPosition: v, scrollToBottom: m, scrollToTop: S }), (e, n) => (r(), s("div", q, [ a( "div", { ref_key: "scrollerRef", ref: t, class: "mc-layout-content-scroller" }, [ a( "div", { ref_key: "contentRef", ref: w, class: "mc-layout-content" }, [ i(e.$slots, "default", {}, void 0, !0) ], 512 /* NEED_PATCH */ ) ], 512 /* NEED_PATCH */ ), e.showScrollArrow ? (r(), s( b, { key: 0 }, [ y.value ? (r(), s("div", { key: 0, class: "mc-layout-content-arrow up", onClick: S }, [ a("div", null, [ H(j) ]) ])) : p("v-if", !0), $.value ? (r(), s("div", { key: 1, class: "mc-layout-content-arrow down", onClick: m }, [ a("div", null, [ H(W) ]) ])) : p("v-if", !0) ], 64 /* STABLE_FRAGMENT */ )) : p("v-if", !0) ])); } }), J = /* @__PURE__ */ l(G, [["__scopeId", "data-v-9c27afee"]]), K = {}, Q = { class: "mc-layout-header" }; function X(o, c) { return r(), s("div", Q, [ i(o.$slots, "default", {}, void 0, !0) ]); } const Z = /* @__PURE__ */ l(K, [["render", X], ["__scopeId", "data-v-05f64ad5"]]), e3 = {}, o3 = { class: "mc-layout" }; function t3(o, c) { return r(), s("div", o3, [ i(o.$slots, "default", {}, void 0, !0) ]); } const x = /* @__PURE__ */ l(e3, [["render", t3], ["__scopeId", "data-v-f9e238c6"]]), n3 = {}, c3 = { class: "mc-layout-sender" }; function r3(o, c) { return r(), s("div", c3, [ i(o.$slots, "default") ]); } const s3 = /* @__PURE__ */ l(n3, [["render", r3]]); x.install = (o) => { o.component("McLayoutAside", N), o.component("McLayoutContent", J), o.component("McLayoutHeader", Z), o.component("McLayout", x), o.component("McLayoutSender", s3); }; export { x as McLayout, N as McLayoutAside, J as McLayoutContent, Z as McLayoutHeader, s3 as McLayoutSender };