UNPKG

vue3-chat-yzx

Version:

vue3-chat-yzx

256 lines (255 loc) 8.59 kB
import { defineComponent as D, computed as y, createElementBlock as v, openBlock as u, normalizeClass as r, unref as l, createCommentVNode as W, createElementVNode as c, normalizeStyle as m, renderSlot as d, createBlock as k, resolveDynamicComponent as F, toDisplayString as g, createTextVNode as V, useSlots as I, watch as A, resolveComponent as L, createVNode as p, withCtx as b, Transition as M, withDirectives as U, vShow as j } from "vue"; import { Opportunity as q, Loading as G, SuccessFilled as H, CircleCloseFilled as J, ArrowUpBold as K } from "@element-plus/icons-vue"; function P(a, n, o, s, t) { let f = `${a}-${n}`; return o && (f += `-${o}`), f; } function E(a) { const n = "Vc"; return { namespace: n, b: (s = "") => P(n, a, s) }; } const Q = ["src"], R = /* @__PURE__ */ D({ __name: "Welcome", props: { classNames: {}, description: {}, extra: {}, icon: {}, rootClassName: {}, styles: {}, title: {}, variant: { default: "filled" }, directions: {} }, setup(a) { const n = a, o = E("welcome"), s = y(() => [ n.rootClassName, { [o.b("filled")]: n.variant === "filled", [o.b("borderless")]: n.variant === "borderless", [o.b("left")]: n.directions === "left", [o.b("right")]: n.directions === "right" } ]); return (t, f) => { var C, i, $, w, B, N, e, S; return u(), v("div", { class: r([l(o).b(), s.value]) }, [ t.$slots.icon || t.icon ? (u(), v("div", { key: 0, class: r([l(o).b("icon"), (C = t.classNames) == null ? void 0 : C.icon]), style: m((i = t.styles) == null ? void 0 : i.icon) }, [ d(t.$slots, "icon", {}, () => [ typeof t.icon == "string" ? (u(), v("img", { key: 0, src: t.icon, alt: "欢迎图标" }, null, 8, Q)) : (u(), k(F(t.icon), { key: 1 })) ], !0) ], 6)) : W("", !0), c("div", { class: r(l(o).b("content-wrapper")) }, [ t.$slots.title || t.title ? (u(), v("div", { key: 0, class: r([l(o).b("title"), ($ = t.classNames) == null ? void 0 : $.title, (t.$slots.extra || t.extra) && "extra"]), style: m((w = t.styles) == null ? void 0 : w.title) }, [ d(t.$slots, "title", {}, () => [ c("h4", null, g(t.title), 1) ], !0), t.$slots.extra || t.extra ? (u(), v("div", { key: 0, class: r([l(o).b("extra"), (B = t.classNames) == null ? void 0 : B.extra]), style: m((N = t.styles) == null ? void 0 : N.extra) }, [ d(t.$slots, "extra", {}, () => [ V(g(t.extra), 1) ], !0) ], 6)) : W("", !0) ], 6)) : W("", !0), c("span", { class: r([l(o).b("description"), (e = t.classNames) == null ? void 0 : e.description]), style: m((S = t.styles) == null ? void 0 : S.description) }, [ d(t.$slots, "description", {}, () => [ V(g(t.description), 1) ], !0) ], 6) ], 2) ], 2); }; } }), z = (a, n) => { const o = a.__vccOpts || a; for (const [s, t] of n) o[s] = t; return o; }, T = /* @__PURE__ */ z(R, [["__scopeId", "data-v-f9b19b9d"]]); T.install = (a) => { a.component("Welcome", T); }; const X = ["disabled"], Y = /* @__PURE__ */ D({ __name: "Thinking", props: { content: { default: "" }, modelValue: { type: Boolean, default: !0 }, status: { default: "start" }, autoCollapse: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, duration: { default: "0.2s" }, buttonWidth: { default: "160px" }, maxWidth: { default: "500px" }, backgroundColor: {}, color: { default: "#00" }, isBorder: { type: Boolean, default: !1 }, lb: { type: Boolean, default: !0 } }, emits: ["update:modelValue", "change"], setup(a, { emit: n }) { const o = E("thinking"), s = a, t = y(() => s.status === "start" ? "开始思考" : s.status === "thinking" ? "思考中" : s.status === "end" ? "思考完成" : "思考失败"), f = n, C = I(), i = y({ get() { return s.modelValue; }, set(e) { f("update:modelValue", e); } }), $ = () => { i.value = !i.value, f("change", !i.value, s.status); }, w = y(() => { const e = {}; return s.buttonWidth && (e.width = s.buttonWidth), s.isBorder && (e.border = "1px solid var(--border-color)"), e; }), B = y(() => { const e = {}; return s.maxWidth && (e.maxWidth = s.maxWidth), s.backgroundColor && (s.backgroundColor.includes("linear-gradient") ? e.background = s.backgroundColor : e.backgroundColor = s.backgroundColor), s.color && (e.color = s.color), e; }), N = y(() => ({ transition: s.duration ? `transform ${s.duration} ease` : "transform $motion-duration-slow ease" })); return A( () => s.status, (e) => { s.autoCollapse && e === "end" && (i.value = !1, console.log("isOpen.value", i.value)); } ), A( () => i.value, (e) => { console.log("Watch isOpen.value", e); } ), (e, S) => { const h = L("el-icon"); return u(), v("div", { class: r(l(o).b()) }, [ c("div", null, [ c("button", { class: r(l(o).b("top")), disabled: e.disabled, style: m(w.value), onClick: $ }, [ c("span", { class: r(l(o).b("icon")) }, [ d(e.$slots, "icon", { status: e.status }, () => [ e.status === "start" ? (u(), k(h, { key: 0, style: { color: "var(--start-color)" } }, { default: b(() => [ p(l(q)) ]), _: 1 })) : e.status === "thinking" ? (u(), k(h, { key: 1, style: { color: "var(--thinking-color)" }, class: "thinking-loading" }, { default: b(() => [ p(l(G)) ]), _: 1 })) : e.status === "end" ? (u(), k(h, { key: 2, style: { color: "var(--end-color)" } }, { default: b(() => [ p(l(H)) ]), _: 1 })) : e.status === "error" ? (u(), k(h, { key: 3, style: { color: "var(--error-color)" } }, { default: b(() => [ p(l(J)) ]), _: 1 })) : W("", !0) ], !0) ], 2), c("span", { class: r(l(o).b("label")) }, [ d(e.$slots, "label", { status: e.status }, () => [ V(g(t.value), 1) ], !0) ], 2), c("span", { class: r([l(o).b("arrow"), { "is-open": i.value }]), style: m(N.value) }, [ d(e.$slots, "arrow", {}, () => [ p(h, { class: "el-icon-center" }, { default: b(() => [ p(l(K)) ]), _: 1 }) ], !0) ], 6) ], 14, X) ]), p(M, { name: "thinking-content" }, { default: b(() => [ U(c("div", { class: r([ l(o).b("content"), { [l(o).b("content-lb")]: e.lb } ]), style: m(B.value) }, [ l(C).error && e.status === "error" ? d(e.$slots, "error", { key: 0 }, void 0, !0) : d(e.$slots, "content", { key: 1, status: e.status, content: e.content }, () => [ V(g(e.content), 1) ], !0) ], 6), [ [j, i.value] ]) ]), _: 3 }) ], 2); }; } }), O = /* @__PURE__ */ z(Y, [["__scopeId", "data-v-144544e5"]]); O.install = (a) => { a.component("Thinking", O); }; const Z = [T, O], _ = (a) => { Z.forEach((n) => { a.component(n.__name, n); }); }, te = { install: _ }; export { O as Thinking, T as Welcome, te as default };