@seer-ai/seer-vue 0.1.0-beta.12 → 0.1.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.js +148 -134
- package/dist/useSeerChat.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.seer-order-card[data-v-17d9e82e]{background:linear-gradient(#eef1fb,#fff 56px);border:1px solid #7f8faa38;border-radius:16px;margin-top:8px;padding:14px 14px 12px}.seer-order-card__title[data-v-17d9e82e]{color:#1d2129;margin:0 0 10px;font-size:18px;font-weight:800}.seer-order-card__panel[data-v-17d9e82e]{background:#fff;border-radius:12px;gap:10px;padding:12px;display:grid}.seer-order-card__channel[data-v-17d9e82e]{color:#1d2129;margin:0;font-size:14px;font-weight:600}.seer-order-card__rows[data-v-17d9e82e]{border:1px solid #e5e6eb;border-radius:10px;margin:0;overflow:hidden}.seer-order-card__row[data-v-17d9e82e]{grid-template-columns:1fr auto;gap:12px;padding:9px 12px;display:grid}.seer-order-card__row+.seer-order-card__row[data-v-17d9e82e]{border-top:1px solid #e5e6eb}.seer-order-card__label[data-v-17d9e82e]{color:#4e5969;font-weight:700}.seer-order-card__value[data-v-17d9e82e]{color:#1d2129;text-align:right;margin:0;font-weight:400}.seer-order-card__value--struck[data-v-17d9e82e]{text-decoration:line-through}.seer-order-card__subsidy[data-v-17d9e82e]{color:#c4161c;border:1px solid #c4161c;border-radius:10px;gap:2px;padding:8px 12px;font-size:13px;display:grid}.seer-order-card__total[data-v-17d9e82e]{justify-content:space-between;align-items:baseline;display:flex}.seer-order-card__total-value[data-v-17d9e82e]{color:#1d2129;font-size:20px;font-weight:800}.seer-order-card__submit[data-v-17d9e82e]{color:#1d2129;cursor:pointer;background:#fc0;border:0;border-radius:10px;padding:11px 0;font-size:16px;font-weight:700}.seer-order-card__submit[data-v-17d9e82e]:disabled{cursor:not-allowed;opacity:.5}.seer-order-card__blocked[data-v-17d9e82e]{color:#c4161c;margin:0;font-size:13px}.seer-chat[data-v-
|
|
1
|
+
.seer-order-card[data-v-17d9e82e]{background:linear-gradient(#eef1fb,#fff 56px);border:1px solid #7f8faa38;border-radius:16px;margin-top:8px;padding:14px 14px 12px}.seer-order-card__title[data-v-17d9e82e]{color:#1d2129;margin:0 0 10px;font-size:18px;font-weight:800}.seer-order-card__panel[data-v-17d9e82e]{background:#fff;border-radius:12px;gap:10px;padding:12px;display:grid}.seer-order-card__channel[data-v-17d9e82e]{color:#1d2129;margin:0;font-size:14px;font-weight:600}.seer-order-card__rows[data-v-17d9e82e]{border:1px solid #e5e6eb;border-radius:10px;margin:0;overflow:hidden}.seer-order-card__row[data-v-17d9e82e]{grid-template-columns:1fr auto;gap:12px;padding:9px 12px;display:grid}.seer-order-card__row+.seer-order-card__row[data-v-17d9e82e]{border-top:1px solid #e5e6eb}.seer-order-card__label[data-v-17d9e82e]{color:#4e5969;font-weight:700}.seer-order-card__value[data-v-17d9e82e]{color:#1d2129;text-align:right;margin:0;font-weight:400}.seer-order-card__value--struck[data-v-17d9e82e]{text-decoration:line-through}.seer-order-card__subsidy[data-v-17d9e82e]{color:#c4161c;border:1px solid #c4161c;border-radius:10px;gap:2px;padding:8px 12px;font-size:13px;display:grid}.seer-order-card__total[data-v-17d9e82e]{justify-content:space-between;align-items:baseline;display:flex}.seer-order-card__total-value[data-v-17d9e82e]{color:#1d2129;font-size:20px;font-weight:800}.seer-order-card__submit[data-v-17d9e82e]{color:#1d2129;cursor:pointer;background:#fc0;border:0;border-radius:10px;padding:11px 0;font-size:16px;font-weight:700}.seer-order-card__submit[data-v-17d9e82e]:disabled{cursor:not-allowed;opacity:.5}.seer-order-card__blocked[data-v-17d9e82e]{color:#c4161c;margin:0;font-size:13px}.seer-chat[data-v-4cdc6832]{color:#18212f;background:radial-gradient(circle at 18% 0,#476aff24,#0000 32%),linear-gradient(#fff 0%,#f7f9fd 100%);border:1px solid #7f8faa47;border-radius:28px;gap:18px;max-width:720px;min-height:640px;padding:0;display:grid;overflow:hidden;box-shadow:0 24px 70px #151f3429}.seer-chat__header[data-v-4cdc6832]{color:#fff;background:linear-gradient(135deg,#141f34f5,#243f76f0),#172033;justify-content:space-between;align-items:flex-start;gap:16px;padding:22px 22px 18px;display:flex}.seer-chat__header h2[data-v-4cdc6832]{letter-spacing:-.03em;margin:0;font-size:22px}.seer-chat__header p[data-v-4cdc6832],.seer-chat__empty[data-v-4cdc6832],.seer-chat__status[data-v-4cdc6832]{color:#5f6f89;margin:4px 0 0;font-size:14px}.seer-chat__header p[data-v-4cdc6832]{color:#ffffffb8;max-width:34ch}.seer-chat__messages[data-v-4cdc6832]{align-content:start;gap:12px;min-height:330px;max-height:470px;padding:18px 18px 4px;display:grid;overflow-y:auto}.seer-chat__empty[data-v-4cdc6832]{color:#66748a;text-align:center;background:#ffffff9e;border:1px dashed #7f8faa61;border-radius:22px;place-items:center;min-height:260px;padding:0 28px;display:grid}.seer-chat__message[data-v-4cdc6832]{background:#ffffffe0;border:1px solid #7f8faa29;border-radius:18px 18px 18px 6px;gap:6px;max-width:min(86%,520px);padding:13px 15px;display:grid;box-shadow:0 12px 28px #151f3414}.seer-chat__message--user[data-v-4cdc6832]{color:#fff;background:linear-gradient(135deg,#285cff,#1d45c9);border-color:#0000;border-radius:18px 18px 6px;justify-self:end;box-shadow:0 14px 30px #1f5eff3d}.seer-chat__role[data-v-4cdc6832]{opacity:.75;font-size:12px;font-weight:700}.seer-chat__body[data-v-4cdc6832]{flex-direction:column;display:flex}.seer-chat__line[data-v-4cdc6832]{white-space:pre-wrap;overflow-wrap:anywhere;margin:0}.seer-chat__line[data-v-4cdc6832]:not(:last-child){margin-bottom:5px}.seer-chat__line[data-v-4cdc6832]:empty{height:7px}.seer-chat__strong[data-v-4cdc6832]{font-weight:700}.seer-chat__message--assistant .seer-chat__line[data-v-4cdc6832]:has(.seer-chat__label-text){color:#1d2129}.seer-chat__label-text[data-v-4cdc6832]{color:#4e5969;font-weight:700}.seer-chat__message--user .seer-chat__label-text[data-v-4cdc6832]{color:inherit}.seer-chat__price[data-v-4cdc6832]{color:#e0331d;font-weight:600}.seer-chat__message--user .seer-chat__price[data-v-4cdc6832]{color:#ffe2dc}.seer-chat__link[data-v-4cdc6832]{color:#1f5eff;text-underline-offset:2px;overflow-wrap:anywhere;font-weight:600;text-decoration:underline}.seer-chat__link[data-v-4cdc6832]:hover{color:#173fb3}.seer-chat__message--user .seer-chat__link[data-v-4cdc6832]{color:#fff}.seer-chat__image-button[data-v-4cdc6832]{cursor:zoom-in;background:0 0;border:0;padding:0;display:block}.seer-chat__image-button[data-v-4cdc6832]:not(:disabled):hover{transform:none}.seer-chat__image[data-v-4cdc6832]{border:1px solid #7f8faa38;border-radius:12px;max-width:100%;margin:6px 0;transition:filter .16s;display:block}.seer-chat__image-button:hover .seer-chat__image[data-v-4cdc6832]{filter:brightness(.96)}.seer-chat__lightbox[data-v-4cdc6832]{z-index:1000;cursor:zoom-out;background:#0a0f1ad1;place-items:center;padding:32px;animation:.14s seer-chat__fade-in-4cdc6832;display:grid;position:fixed;inset:0}.seer-chat__lightbox-image[data-v-4cdc6832]{object-fit:contain;border-radius:12px;max-width:min(92vw,1200px);max-height:90vh;box-shadow:0 30px 80px #00000080}.seer-chat__lightbox-close[data-v-4cdc6832]{color:#fff;background:#ffffff24;border-radius:50%;place-items:center;width:40px;height:40px;font-size:26px;line-height:1;display:grid;position:fixed;top:18px;right:22px}.seer-chat__lightbox-close[data-v-4cdc6832]:not(:disabled):hover{background:#ffffff3d}@keyframes seer-chat__fade-in-4cdc6832{0%{opacity:0}to{opacity:1}}.seer-chat__error[data-v-4cdc6832],.seer-chat__handoff[data-v-4cdc6832]{border-radius:14px;margin:0 18px;padding:10px 12px}.seer-chat__error[data-v-4cdc6832]{color:#8a1f11;background:#fff0ed}.seer-chat__handoff[data-v-4cdc6832]{color:#704600;background:#fff7db}.seer-chat__form[data-v-4cdc6832]{background:#fff;border:1px solid #7f8faa42;border-radius:22px;gap:11px;margin:0 18px 18px;padding:14px;display:grid;box-shadow:0 18px 38px #151f3417}.seer-chat__form--dragging[data-v-4cdc6832]{background:#f3f6ff;border:1px dashed #285cff}.seer-chat__label[data-v-4cdc6832]{font-size:13px;font-weight:700}.seer-chat textarea[data-v-4cdc6832]{box-sizing:border-box;width:100%;min-height:92px;color:inherit;resize:vertical;background:#f8fafd;border:1px solid #0000;border-radius:16px;outline:none;padding:14px;line-height:1.55;transition:background .16s,border-color .16s,box-shadow .16s}.seer-chat button[data-v-4cdc6832]{color:inherit;cursor:pointer;border:0;font-weight:700;transition:transform .16s,box-shadow .16s,opacity .16s}.seer-chat button[data-v-4cdc6832]:not(:disabled):hover{transform:translateY(-1px)}.seer-chat button[data-v-4cdc6832]:disabled{cursor:not-allowed;opacity:.5}.seer-chat button[data-v-4cdc6832]:focus-visible,.seer-chat textarea[data-v-4cdc6832]:focus-visible{border-color:#1f5eff6b;box-shadow:0 0 0 4px #1f5eff21}.seer-chat__clear-button[data-v-4cdc6832]{color:#ffffffc7;background:0 0;border-radius:12px;flex:none;padding:8px 11px;font-size:12px;border:1px solid #ffffff2e!important}.seer-chat__clear-button[data-v-4cdc6832]:not(:disabled):hover{color:#fff;box-shadow:none;background:#ffffff1a}.seer-chat__stop-button[data-v-4cdc6832]{color:#6c3b12;background:#fff1df;border-radius:12px;padding:8px 11px;font-size:12px}.seer-chat__mic-button[data-v-4cdc6832],.seer-chat__attach-button[data-v-4cdc6832]{color:#285cff;background:#edf2ff;border-radius:50%;flex:none;place-items:center;width:40px;height:40px;padding:0;display:grid}.seer-chat__mic-button[data-v-4cdc6832]:not(:disabled):hover,.seer-chat__attach-button[data-v-4cdc6832]:not(:disabled):hover{background:#dfe8ff}.seer-chat__file-input[data-v-4cdc6832]{display:none}.seer-chat__attachments[data-v-4cdc6832]{flex-wrap:wrap;gap:6px;margin:0 0 8px;padding:0;list-style:none;display:flex}.seer-chat__attachment[data-v-4cdc6832]{color:#1f2a44;background:#edf2ff;border-radius:999px;align-items:center;gap:4px;max-width:100%;padding:4px 6px 4px 10px;font-size:13px;display:inline-flex}.seer-chat__attachment-name[data-v-4cdc6832]{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.seer-chat__attachment-remove[data-v-4cdc6832]{color:#4b5878;background:0 0;border-radius:50%;width:20px;height:20px;padding:0;line-height:1}.seer-chat__attachment-remove[data-v-4cdc6832]:hover{background:#dfe8ff}.seer-chat__mic-button--recording[data-v-4cdc6832]{color:#fff;background:#d9342b;animation:1.4s ease-in-out infinite seer-chat__recording-pulse-4cdc6832;box-shadow:0 0 0 5px #d9342b24}.seer-chat__mic-button--recording[data-v-4cdc6832]:not(:disabled):hover{background:#bd271f}.seer-chat__stop-icon[data-v-4cdc6832]{background:currentColor;border-radius:3px;width:12px;height:12px}@keyframes seer-chat__recording-pulse-4cdc6832{50%{box-shadow:0 0 0 9px #d9342b14}}.seer-chat__send-button[data-v-4cdc6832]{color:#fff;background:linear-gradient(135deg,#1f5eff,#173fb3);border-radius:14px;justify-content:center;align-items:center;gap:8px;min-width:86px;padding:10px 14px;display:inline-flex;box-shadow:0 12px 24px #1f5eff38}.seer-chat__send-button[data-v-4cdc6832]:not(:disabled):hover{box-shadow:0 14px 28px #1f5eff47}.seer-chat__hint[data-v-4cdc6832]{color:#7a879a;margin-right:auto;font-size:12px}.seer-chat__composer-footer[data-v-4cdc6832]{justify-content:flex-end;align-items:center;gap:8px;display:flex}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/index.js
CHANGED
|
@@ -251,7 +251,7 @@ var H = Symbol("seer-chat-options"), U = { install(e, t) {
|
|
|
251
251
|
e.provide(H, t);
|
|
252
252
|
} };
|
|
253
253
|
// src/useSeerChat.ts
|
|
254
|
-
function
|
|
254
|
+
function ee(e = {}) {
|
|
255
255
|
let t = s() ? c(H, void 0) : void 0, n = Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0)), r = {
|
|
256
256
|
...t,
|
|
257
257
|
...n
|
|
@@ -268,11 +268,11 @@ function W(e = {}) {
|
|
|
268
268
|
model: r.model,
|
|
269
269
|
fetcher: r.fetcher
|
|
270
270
|
}), a = f([]), o = f(!1), l = f(null), u = f(), d = f([]), p = f(!1), m = r.voiceEnabled !== !1 && i.transcriptionEnabled, h = r.uploadEnabled !== !1 && i.uploadEnabled, g = r.maxRecordingSeconds ?? 60, _ = f([]), v = f(!1), y = null;
|
|
271
|
-
async function S(e) {
|
|
271
|
+
async function S(e, t = {}) {
|
|
272
272
|
v.value = !0, l.value = null;
|
|
273
273
|
try {
|
|
274
|
-
let
|
|
275
|
-
_.value = [..._.value,
|
|
274
|
+
let n = await i.upload(e, e.name);
|
|
275
|
+
_.value = t.replace ? [n] : [..._.value, n];
|
|
276
276
|
} catch (e) {
|
|
277
277
|
l.value = e instanceof Error ? e.message : String(e);
|
|
278
278
|
} finally {
|
|
@@ -345,17 +345,17 @@ function W(e = {}) {
|
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
347
|
// src/components/SeerOrderCard.vue?vue&type=script&setup=true&lang.ts
|
|
348
|
-
var
|
|
348
|
+
var W = ["aria-label"], G = { class: "seer-order-card__title" }, K = { class: "seer-order-card__panel" }, q = { class: "seer-order-card__channel" }, J = { class: "seer-order-card__rows" }, Y = { class: "seer-order-card__label" }, X = {
|
|
349
349
|
key: 0,
|
|
350
350
|
class: "seer-order-card__row"
|
|
351
|
-
},
|
|
351
|
+
}, Z = { class: "seer-order-card__label" }, Q = { class: "seer-order-card__value" }, $ = {
|
|
352
352
|
key: 0,
|
|
353
353
|
class: "seer-order-card__subsidy"
|
|
354
|
-
},
|
|
354
|
+
}, te = { class: "seer-order-card__total" }, ne = ["title"], re = { class: "seer-order-card__total-value" }, ie = ["disabled"], ae = {
|
|
355
355
|
key: 2,
|
|
356
356
|
class: "seer-order-card__blocked",
|
|
357
357
|
role: "note"
|
|
358
|
-
},
|
|
358
|
+
}, oe = /*@__PURE__*/ o({
|
|
359
359
|
__name: "SeerOrderCard",
|
|
360
360
|
props: {
|
|
361
361
|
card: {},
|
|
@@ -367,63 +367,63 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
367
367
|
return (n, s) => (d(), i("section", {
|
|
368
368
|
class: "seer-order-card",
|
|
369
369
|
"aria-label": t.card.title
|
|
370
|
-
}, [a("h3",
|
|
371
|
-
a("h4",
|
|
372
|
-
a("dl",
|
|
370
|
+
}, [a("h3", G, m(t.card.title), 1), a("div", K, [
|
|
371
|
+
a("h4", q, m(t.card.channel_name), 1),
|
|
372
|
+
a("dl", J, [(d(!0), i(e, null, p(t.card.rows, (e) => (d(), i("div", {
|
|
373
373
|
key: e.label,
|
|
374
374
|
class: "seer-order-card__row"
|
|
375
|
-
}, [a("dt",
|
|
376
|
-
t.card.subsidy ? (d(), i("div",
|
|
377
|
-
a("div",
|
|
375
|
+
}, [a("dt", Y, m(e.label), 1), a("dd", { class: l(["seer-order-card__value", { "seer-order-card__value--struck": e.struck }]) }, m(e.value), 3)]))), 128)), t.card.coupon ? (d(), i("div", X, [a("dt", Z, m(t.card.coupon.label), 1), a("dd", Q, m(t.card.coupon.value), 1)])) : r("", !0)]),
|
|
376
|
+
t.card.subsidy ? (d(), i("div", $, [a("strong", null, m(t.card.subsidy.label), 1), a("span", null, m(t.card.subsidy.value) + " = " + m(t.card.subsidy.detail), 1)])) : r("", !0),
|
|
377
|
+
a("div", te, [a("span", {
|
|
378
378
|
class: "seer-order-card__label",
|
|
379
379
|
title: t.card.note
|
|
380
|
-
}, m(t.card.total.label), 9,
|
|
380
|
+
}, m(t.card.total.label), 9, ne), a("span", re, m(t.card.total.value), 1)]),
|
|
381
381
|
t.card.action ? (d(), i("button", {
|
|
382
382
|
key: 1,
|
|
383
383
|
type: "button",
|
|
384
384
|
class: "seer-order-card__submit",
|
|
385
385
|
disabled: t.disabled,
|
|
386
386
|
onClick: s[0] ||= (e) => o("submit", t.card.action.message)
|
|
387
|
-
}, m(t.card.action.label), 9,
|
|
388
|
-
])], 8,
|
|
387
|
+
}, m(t.card.action.label), 9, ie)) : t.card.blocked_reason ? (d(), i("p", ae, m(t.card.blocked_reason), 1)) : r("", !0)
|
|
388
|
+
])], 8, W));
|
|
389
389
|
}
|
|
390
|
-
}),
|
|
390
|
+
}), se = (e, t) => {
|
|
391
391
|
let n = e.__vccOpts || e;
|
|
392
392
|
for (let [e, r] of t) n[e] = r;
|
|
393
393
|
return n;
|
|
394
|
-
},
|
|
394
|
+
}, ce = /*#__PURE__*/ se(oe, [["__scopeId", "data-v-17d9e82e"]]), le = {
|
|
395
395
|
class: "seer-chat",
|
|
396
396
|
"aria-label": "多发货 AI 客服聊天"
|
|
397
|
-
},
|
|
397
|
+
}, ue = { class: "seer-chat__header" }, de = {
|
|
398
398
|
class: "seer-chat__messages",
|
|
399
399
|
"aria-live": "polite"
|
|
400
|
-
},
|
|
400
|
+
}, fe = {
|
|
401
401
|
key: 0,
|
|
402
402
|
class: "seer-chat__empty"
|
|
403
|
-
},
|
|
403
|
+
}, pe = { class: "seer-chat__role" }, me = { class: "seer-chat__body" }, he = ["href"], ge = ["aria-label", "onClick"], _e = ["src", "alt"], ve = {
|
|
404
404
|
key: 2,
|
|
405
405
|
class: "seer-chat__strong"
|
|
406
|
-
},
|
|
406
|
+
}, ye = {
|
|
407
407
|
key: 3,
|
|
408
408
|
class: "seer-chat__price"
|
|
409
|
-
},
|
|
409
|
+
}, be = {
|
|
410
410
|
key: 4,
|
|
411
411
|
class: "seer-chat__label-text"
|
|
412
|
-
},
|
|
412
|
+
}, xe = { key: 5 }, Se = {
|
|
413
413
|
key: 0,
|
|
414
414
|
class: "seer-chat__status"
|
|
415
|
-
},
|
|
415
|
+
}, Ce = {
|
|
416
416
|
key: 1,
|
|
417
417
|
class: "seer-chat__error",
|
|
418
418
|
role: "alert"
|
|
419
|
-
},
|
|
419
|
+
}, we = {
|
|
420
420
|
key: 2,
|
|
421
421
|
class: "seer-chat__handoff"
|
|
422
|
-
},
|
|
422
|
+
}, Te = {
|
|
423
423
|
key: 0,
|
|
424
424
|
class: "seer-chat__attachments",
|
|
425
425
|
"aria-label": "待发送的附件"
|
|
426
|
-
},
|
|
426
|
+
}, Ee = { class: "seer-chat__attachment-name" }, De = ["aria-label", "onClick"], Oe = [
|
|
427
427
|
"placeholder",
|
|
428
428
|
"disabled",
|
|
429
429
|
"onKeydown"
|
|
@@ -444,7 +444,7 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
444
444
|
width: "20",
|
|
445
445
|
height: "20",
|
|
446
446
|
"aria-hidden": "true"
|
|
447
|
-
}, Fe = ["disabled"], Ie = ["aria-label"], Le = ["src", "alt"], Re = ".xlsx,.xls,.csv,.png,.jpg,.jpeg,.webp,.pdf", ze = /*#__PURE__*/
|
|
447
|
+
}, Fe = ["disabled"], Ie = ["aria-label"], Le = ["src", "alt"], Re = ".xlsx,.xls,.csv,.png,.jpg,.jpeg,.webp,.pdf", ze = /*#__PURE__*/ se(/* @__PURE__ */ o({
|
|
448
448
|
__name: "SeerChat",
|
|
449
449
|
props: {
|
|
450
450
|
endpoint: {},
|
|
@@ -472,7 +472,7 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
472
472
|
maxRecordingSeconds: {}
|
|
473
473
|
},
|
|
474
474
|
setup(o) {
|
|
475
|
-
let s = o, c =
|
|
475
|
+
let s = o, c = Re.split(","), b = f(""), x = f(!1), S = f(!1), C = f(null), w = ee({
|
|
476
476
|
endpoint: s.endpoint,
|
|
477
477
|
sessionEndpoint: s.sessionEndpoint,
|
|
478
478
|
transcriptionEndpoint: s.transcriptionEndpoint,
|
|
@@ -485,85 +485,96 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
485
485
|
fetcher: s.fetcher,
|
|
486
486
|
voiceEnabled: s.voiceEnabled,
|
|
487
487
|
maxRecordingSeconds: s.maxRecordingSeconds
|
|
488
|
-
}),
|
|
489
|
-
async function
|
|
488
|
+
}), T = f(null), E = f(!1), D = f(null), O = t(() => (b.value.trim().length > 0 || w.attachments.value.length > 0) && !w.loading.value && !w.uploading.value && !x.value && !S.value);
|
|
489
|
+
async function k(e) {
|
|
490
490
|
let t = e.target, n = Array.from(t.files ?? []);
|
|
491
491
|
t.value = "";
|
|
492
|
-
for (let e of n) await
|
|
492
|
+
for (let e of n) await w.attach(e);
|
|
493
|
+
}
|
|
494
|
+
function A(e) {
|
|
495
|
+
w.uploadEnabled && e.dataTransfer?.types.includes("Files") && (e.preventDefault(), E.value = !0);
|
|
496
|
+
}
|
|
497
|
+
async function j(e) {
|
|
498
|
+
E.value = !1;
|
|
499
|
+
let t = e.dataTransfer?.files?.[0];
|
|
500
|
+
if (!w.uploadEnabled || !t) return;
|
|
501
|
+
e.preventDefault(), D.value = null;
|
|
502
|
+
let n = t.name.slice(t.name.lastIndexOf(".")).toLowerCase();
|
|
503
|
+
c.includes(n) ? w.loading.value || w.uploading.value || await w.attach(t, { replace: !0 }) : D.value = "不支持这种文件,请拖入 Excel(xlsx / xls / csv)、图片或 PDF。";
|
|
493
504
|
}
|
|
494
|
-
let
|
|
495
|
-
function
|
|
496
|
-
e.key === "Escape" &&
|
|
505
|
+
let M = t(() => w.transcriptionEnabled && typeof navigator < "u" && typeof navigator.mediaDevices?.getUserMedia == "function" && typeof MediaRecorder < "u"), N = null, P = null, F = [], I, L = !1, z = f(null);
|
|
506
|
+
function B(e) {
|
|
507
|
+
e.key === "Escape" && U();
|
|
497
508
|
}
|
|
498
|
-
function
|
|
499
|
-
|
|
509
|
+
function H(e, t) {
|
|
510
|
+
z.value = {
|
|
500
511
|
src: e,
|
|
501
512
|
alt: t
|
|
502
|
-
}, window.addEventListener("keydown",
|
|
513
|
+
}, window.addEventListener("keydown", B);
|
|
503
514
|
}
|
|
504
|
-
function
|
|
505
|
-
|
|
515
|
+
function U() {
|
|
516
|
+
z.value = null, window.removeEventListener("keydown", B);
|
|
506
517
|
}
|
|
507
518
|
u(() => {
|
|
508
|
-
|
|
519
|
+
L = !0, window.removeEventListener("keydown", B), Q(), N && N.state !== "inactive" && (N.ondataavailable = null, N.onstop = null, N.onerror = null, N.stop()), $();
|
|
509
520
|
});
|
|
510
|
-
async function
|
|
511
|
-
if (!
|
|
512
|
-
let e =
|
|
513
|
-
|
|
521
|
+
async function W() {
|
|
522
|
+
if (!O.value) return;
|
|
523
|
+
let e = b.value;
|
|
524
|
+
b.value = "", await w.send(e);
|
|
514
525
|
}
|
|
515
|
-
async function
|
|
516
|
-
|
|
526
|
+
async function G() {
|
|
527
|
+
x.value ? q() : await K();
|
|
517
528
|
}
|
|
518
|
-
async function
|
|
519
|
-
if (!(!
|
|
520
|
-
|
|
529
|
+
async function K() {
|
|
530
|
+
if (!(!M.value || S.value || w.loading.value)) {
|
|
531
|
+
C.value = null;
|
|
521
532
|
try {
|
|
522
|
-
if (
|
|
533
|
+
if (P = await navigator.mediaDevices.getUserMedia({
|
|
523
534
|
audio: {
|
|
524
535
|
echoCancellation: !0,
|
|
525
536
|
noiseSuppression: !0
|
|
526
537
|
},
|
|
527
538
|
video: !1
|
|
528
|
-
}),
|
|
529
|
-
|
|
539
|
+
}), L) {
|
|
540
|
+
$();
|
|
530
541
|
return;
|
|
531
542
|
}
|
|
532
|
-
let e =
|
|
533
|
-
|
|
543
|
+
let e = Y();
|
|
544
|
+
N = e ? new MediaRecorder(P, {
|
|
534
545
|
mimeType: e,
|
|
535
546
|
audioBitsPerSecond: 64e3
|
|
536
|
-
}) : new MediaRecorder(
|
|
537
|
-
e.data.size > 0 &&
|
|
538
|
-
},
|
|
539
|
-
|
|
540
|
-
},
|
|
541
|
-
|
|
542
|
-
},
|
|
547
|
+
}) : new MediaRecorder(P), F = [], N.ondataavailable = (e) => {
|
|
548
|
+
e.data.size > 0 && F.push(e.data);
|
|
549
|
+
}, N.onstop = () => {
|
|
550
|
+
J(N?.mimeType || e || "audio/webm");
|
|
551
|
+
}, N.onerror = () => {
|
|
552
|
+
C.value = "录音失败,请重试或用文字输入。", x.value = !1, S.value = !1, Q(), $();
|
|
553
|
+
}, N.start(), x.value = !0, I = setTimeout(q, Math.max(1, w.maxRecordingSeconds) * 1e3);
|
|
543
554
|
} catch (e) {
|
|
544
|
-
|
|
555
|
+
C.value = Z(e), $();
|
|
545
556
|
}
|
|
546
557
|
}
|
|
547
558
|
}
|
|
548
|
-
function
|
|
549
|
-
|
|
559
|
+
function q() {
|
|
560
|
+
N && N.state !== "inactive" && (x.value = !1, S.value = !0, Q(), N.stop());
|
|
550
561
|
}
|
|
551
|
-
async function
|
|
552
|
-
|
|
553
|
-
let t =
|
|
554
|
-
if (
|
|
562
|
+
async function J(e) {
|
|
563
|
+
Q(), $();
|
|
564
|
+
let t = F;
|
|
565
|
+
if (F = [], N = null, L) return;
|
|
555
566
|
let n = new Blob(t, { type: e });
|
|
556
|
-
if (n.size === 0)
|
|
567
|
+
if (n.size === 0) C.value = "没有录到声音,请重试。", S.value = !1;
|
|
557
568
|
else try {
|
|
558
|
-
let t = await
|
|
559
|
-
|
|
569
|
+
let t = await w.transcribe(n, X(e));
|
|
570
|
+
b.value = b.value.trim() ? `${b.value.trim()} ${t.text}` : t.text;
|
|
560
571
|
} catch {
|
|
561
|
-
|
|
572
|
+
C.value = "语音识别失败,请重试或用文字输入。";
|
|
562
573
|
} finally {
|
|
563
|
-
|
|
574
|
+
S.value = !1;
|
|
564
575
|
}
|
|
565
576
|
}
|
|
566
|
-
function
|
|
577
|
+
function Y() {
|
|
567
578
|
if (typeof MediaRecorder.isTypeSupported == "function") return [
|
|
568
579
|
"audio/webm;codecs=opus",
|
|
569
580
|
"audio/mp4",
|
|
@@ -571,32 +582,32 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
571
582
|
"audio/webm"
|
|
572
583
|
].find((e) => MediaRecorder.isTypeSupported(e));
|
|
573
584
|
}
|
|
574
|
-
function
|
|
585
|
+
function X(e) {
|
|
575
586
|
return `recording.${{
|
|
576
587
|
"audio/mp4": "m4a",
|
|
577
588
|
"audio/ogg": "ogg",
|
|
578
589
|
"audio/webm": "webm"
|
|
579
590
|
}[e.split(";", 1)[0].toLowerCase()] || "webm"}`;
|
|
580
591
|
}
|
|
581
|
-
function
|
|
592
|
+
function Z(e) {
|
|
582
593
|
return e instanceof DOMException && e.name === "NotAllowedError" ? "请允许浏览器使用麦克风。" : e instanceof DOMException && e.name === "NotFoundError" ? "未检测到可用的麦克风。" : "无法启动麦克风,请重试或用文字输入。";
|
|
583
594
|
}
|
|
584
|
-
function
|
|
585
|
-
|
|
595
|
+
function Q() {
|
|
596
|
+
I !== void 0 && (clearTimeout(I), I = void 0);
|
|
586
597
|
}
|
|
587
|
-
function
|
|
588
|
-
|
|
598
|
+
function $() {
|
|
599
|
+
P?.getTracks().forEach((e) => e.stop()), P = null;
|
|
589
600
|
}
|
|
590
|
-
return (t, s) => (d(), i("section",
|
|
591
|
-
a("header",
|
|
601
|
+
return (t, s) => (d(), i("section", le, [
|
|
602
|
+
a("header", ue, [a("div", null, [a("h2", null, m(o.title), 1), s[5] ||= a("p", null, "可咨询渠道报价、时效、下单资料、入仓和售后问题。", -1)]), a("button", {
|
|
592
603
|
type: "button",
|
|
593
604
|
class: "seer-chat__clear-button",
|
|
594
|
-
onClick: s[0] ||= (e) => h(
|
|
605
|
+
onClick: s[0] ||= (e) => h(w).reset()
|
|
595
606
|
}, " 清空对话 ")]),
|
|
596
|
-
a("div",
|
|
607
|
+
a("div", de, [h(w).messages.value.length === 0 ? (d(), i("p", fe, " 直接输入问题即可,复杂查单或赔付问题会提示转人工。 ")) : r("", !0), (d(!0), i(e, null, p(h(w).messages.value, (t, o) => (d(), i("article", {
|
|
597
608
|
key: `${t.role}-${o}`,
|
|
598
609
|
class: l(["seer-chat__message", `seer-chat__message--${t.role}`])
|
|
599
|
-
}, [a("span",
|
|
610
|
+
}, [a("span", pe, m(t.role === "user" ? "你" : "AI 客服"), 1), a("div", me, [(d(!0), i(e, null, p(h(R)(h(V)(t.content, t.orderCard), { complete: !(h(w).loading.value && o === h(w).messages.value.length - 1) }), (t, n) => (d(), i("p", {
|
|
600
611
|
key: n,
|
|
601
612
|
class: "seer-chat__line"
|
|
602
613
|
}, [(d(!0), i(e, null, p(t, (t, n) => (d(), i(e, { key: n }, [t.kind === "link" ? (d(), i("a", {
|
|
@@ -605,73 +616,76 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
605
616
|
href: t.href,
|
|
606
617
|
target: "_blank",
|
|
607
618
|
rel: "noopener noreferrer"
|
|
608
|
-
}, m(t.label), 9,
|
|
619
|
+
}, m(t.label), 9, he)) : t.kind === "image" ? (d(), i("button", {
|
|
609
620
|
key: 1,
|
|
610
621
|
type: "button",
|
|
611
622
|
class: "seer-chat__image-button",
|
|
612
623
|
"aria-label": `放大查看${t.alt}`,
|
|
613
|
-
onClick: (e) =>
|
|
624
|
+
onClick: (e) => H(t.href, t.alt)
|
|
614
625
|
}, [a("img", {
|
|
615
626
|
class: "seer-chat__image",
|
|
616
627
|
src: t.href,
|
|
617
628
|
alt: t.alt,
|
|
618
629
|
loading: "lazy"
|
|
619
|
-
}, null, 8,
|
|
630
|
+
}, null, 8, _e)], 8, ge)) : t.kind === "strong" ? (d(), i("strong", ve, m(t.value), 1)) : t.kind === "price" ? (d(), i("span", ye, m(t.value), 1)) : t.kind === "label" ? (d(), i("span", be, m(t.value), 1)) : (d(), i("span", xe, m(t.value), 1))], 64))), 128))]))), 128)), t.orderCard ? (d(), n(ce, {
|
|
620
631
|
key: 0,
|
|
621
632
|
card: t.orderCard,
|
|
622
|
-
disabled: h(
|
|
623
|
-
onSubmit: h(
|
|
633
|
+
disabled: h(w).loading.value || o !== h(w).messages.value.length - 1,
|
|
634
|
+
onSubmit: h(w).send
|
|
624
635
|
}, null, 8, [
|
|
625
636
|
"card",
|
|
626
637
|
"disabled",
|
|
627
638
|
"onSubmit"
|
|
628
639
|
])) : r("", !0)])], 2))), 128))]),
|
|
629
|
-
h(
|
|
630
|
-
h(
|
|
631
|
-
h(
|
|
640
|
+
h(w).loading.value ? (d(), i("p", Se, "正在回复...")) : r("", !0),
|
|
641
|
+
h(w).error.value || C.value || D.value ? (d(), i("p", Ce, m(C.value || D.value || h(w).error.value), 1)) : r("", !0),
|
|
642
|
+
h(w).handoffRequested.value ? (d(), i("p", we, " 建议转人工:请留下联系方式或等待客服接入。 ")) : r("", !0),
|
|
632
643
|
a("form", {
|
|
633
|
-
class: "seer-chat__form",
|
|
634
|
-
onSubmit: y(
|
|
644
|
+
class: l(["seer-chat__form", { "seer-chat__form--dragging": E.value }]),
|
|
645
|
+
onSubmit: y(W, ["prevent"]),
|
|
646
|
+
onDragover: A,
|
|
647
|
+
onDragleave: s[4] ||= (e) => E.value = !1,
|
|
648
|
+
onDrop: j
|
|
635
649
|
}, [
|
|
636
|
-
s[
|
|
650
|
+
s[9] ||= a("label", {
|
|
637
651
|
class: "seer-chat__label",
|
|
638
652
|
for: "seer-chat-input"
|
|
639
653
|
}, "问题", -1),
|
|
640
|
-
h(
|
|
654
|
+
h(w).attachments.value.length > 0 ? (d(), i("ul", Te, [(d(!0), i(e, null, p(h(w).attachments.value, (e) => (d(), i("li", {
|
|
641
655
|
key: e.fileId,
|
|
642
656
|
class: "seer-chat__attachment"
|
|
643
|
-
}, [a("span",
|
|
657
|
+
}, [a("span", Ee, m(e.filename), 1), a("button", {
|
|
644
658
|
type: "button",
|
|
645
659
|
class: "seer-chat__attachment-remove",
|
|
646
660
|
"aria-label": `移除附件${e.filename}`,
|
|
647
|
-
onClick: (t) => h(
|
|
648
|
-
}, " × ", 8,
|
|
661
|
+
onClick: (t) => h(w).removeAttachment(e.fileId)
|
|
662
|
+
}, " × ", 8, De)]))), 128))])) : r("", !0),
|
|
649
663
|
_(a("textarea", {
|
|
650
664
|
id: "seer-chat-input",
|
|
651
|
-
"onUpdate:modelValue": s[1] ||= (e) =>
|
|
665
|
+
"onUpdate:modelValue": s[1] ||= (e) => b.value = e,
|
|
652
666
|
placeholder: o.placeholder,
|
|
653
|
-
disabled: h(
|
|
667
|
+
disabled: h(w).loading.value || S.value,
|
|
654
668
|
rows: "3",
|
|
655
|
-
onKeydown: v(y(
|
|
656
|
-
}, null, 40,
|
|
669
|
+
onKeydown: v(y(W, ["exact", "prevent"]), ["enter"])
|
|
670
|
+
}, null, 40, Oe), [[g, b.value]]),
|
|
657
671
|
a("div", ke, [
|
|
658
|
-
a("span", Ae, m(
|
|
659
|
-
h(
|
|
672
|
+
a("span", Ae, m(x.value ? `正在录音,最长 ${h(w).maxRecordingSeconds} 秒` : S.value ? "正在识别语音..." : h(w).uploading.value ? "正在上传附件..." : E.value ? "松开即可上传(一次一个文件,会替换当前附件)" : "Enter 发送 · Shift+Enter 换行"), 1),
|
|
673
|
+
h(w).uploadEnabled ? (d(), i(e, { key: 0 }, [a("input", {
|
|
660
674
|
ref_key: "fileInput",
|
|
661
|
-
ref:
|
|
675
|
+
ref: T,
|
|
662
676
|
class: "seer-chat__file-input",
|
|
663
677
|
type: "file",
|
|
664
678
|
multiple: "",
|
|
665
679
|
accept: Re,
|
|
666
|
-
onChange:
|
|
680
|
+
onChange: k
|
|
667
681
|
}, null, 544), a("button", {
|
|
668
682
|
type: "button",
|
|
669
683
|
class: "seer-chat__attach-button",
|
|
670
|
-
disabled: h(
|
|
684
|
+
disabled: h(w).loading.value || h(w).uploading.value,
|
|
671
685
|
"aria-label": "上传附件",
|
|
672
686
|
title: "上传下单模板、实物图片等",
|
|
673
|
-
onClick: s[2] ||= (e) =>
|
|
674
|
-
}, [...s[
|
|
687
|
+
onClick: s[2] ||= (e) => T.value?.click()
|
|
688
|
+
}, [...s[6] ||= [a("svg", {
|
|
675
689
|
viewBox: "0 0 24 24",
|
|
676
690
|
width: "20",
|
|
677
691
|
height: "20",
|
|
@@ -680,49 +694,49 @@ var G = ["aria-label"], K = { class: "seer-order-card__title" }, q = { class: "s
|
|
|
680
694
|
fill: "currentColor",
|
|
681
695
|
d: "M16.5 6.5v10a4.5 4.5 0 0 1-9 0V5a3 3 0 0 1 6 0v10.5a1.5 1.5 0 0 1-3 0V6.5H9v9a3 3 0 0 0 6 0V5a4.5 4.5 0 0 0-9 0v11.5a6 6 0 0 0 12 0v-10h-1.5Z"
|
|
682
696
|
})], -1)]], 8, je)], 64)) : r("", !0),
|
|
683
|
-
|
|
697
|
+
M.value ? (d(), i("button", {
|
|
684
698
|
key: 1,
|
|
685
699
|
type: "button",
|
|
686
|
-
class: l(["seer-chat__mic-button", { "seer-chat__mic-button--recording":
|
|
687
|
-
disabled:
|
|
688
|
-
"aria-label":
|
|
689
|
-
title:
|
|
690
|
-
onClick:
|
|
691
|
-
}, [
|
|
700
|
+
class: l(["seer-chat__mic-button", { "seer-chat__mic-button--recording": x.value }]),
|
|
701
|
+
disabled: S.value || h(w).loading.value && !x.value,
|
|
702
|
+
"aria-label": x.value ? "停止录音" : "开始语音输入",
|
|
703
|
+
title: x.value ? "停止录音" : "语音输入",
|
|
704
|
+
onClick: G
|
|
705
|
+
}, [x.value ? (d(), i("span", Ne)) : (d(), i("svg", Pe, [...s[7] ||= [a("path", {
|
|
692
706
|
fill: "currentColor",
|
|
693
707
|
d: "M12 14a3 3 0 0 0 3-3V5a3 3 0 1 0-6 0v6a3 3 0 0 0 3 3Zm5-3a1 1 0 1 1 2 0 7 7 0 0 1-6 6.93V20h3a1 1 0 1 1 0 2H8a1 1 0 1 1 0-2h3v-2.07A7 7 0 0 1 5 11a1 1 0 1 1 2 0 5 5 0 0 0 10 0Z"
|
|
694
708
|
}, null, -1)]]))], 10, Me)) : r("", !0),
|
|
695
|
-
h(
|
|
709
|
+
h(w).loading.value ? (d(), i("button", {
|
|
696
710
|
key: 2,
|
|
697
711
|
type: "button",
|
|
698
712
|
class: "seer-chat__stop-button",
|
|
699
|
-
onClick: s[3] ||= (e) => h(
|
|
713
|
+
onClick: s[3] ||= (e) => h(w).abort()
|
|
700
714
|
}, " 停止 ")) : r("", !0),
|
|
701
715
|
a("button", {
|
|
702
716
|
class: "seer-chat__send-button",
|
|
703
717
|
type: "submit",
|
|
704
|
-
disabled: !
|
|
705
|
-
}, [...s[
|
|
718
|
+
disabled: !O.value
|
|
719
|
+
}, [...s[8] ||= [a("span", null, "发送", -1), a("span", { "aria-hidden": "true" }, "↵", -1)]], 8, Fe)
|
|
706
720
|
])
|
|
707
|
-
],
|
|
708
|
-
|
|
721
|
+
], 34),
|
|
722
|
+
z.value ? (d(), i("div", {
|
|
709
723
|
key: 3,
|
|
710
724
|
class: "seer-chat__lightbox",
|
|
711
725
|
role: "dialog",
|
|
712
726
|
"aria-modal": "true",
|
|
713
|
-
"aria-label":
|
|
714
|
-
onClick:
|
|
727
|
+
"aria-label": z.value.alt,
|
|
728
|
+
onClick: U
|
|
715
729
|
}, [a("button", {
|
|
716
730
|
type: "button",
|
|
717
731
|
class: "seer-chat__lightbox-close",
|
|
718
732
|
"aria-label": "关闭",
|
|
719
|
-
onClick:
|
|
733
|
+
onClick: U
|
|
720
734
|
}, " × "), a("img", {
|
|
721
735
|
class: "seer-chat__lightbox-image",
|
|
722
|
-
src:
|
|
723
|
-
alt:
|
|
736
|
+
src: z.value.src,
|
|
737
|
+
alt: z.value.alt
|
|
724
738
|
}, null, 8, Le)], 8, Ie)) : r("", !0)
|
|
725
739
|
]));
|
|
726
740
|
}
|
|
727
|
-
}), [["__scopeId", "data-v-
|
|
728
|
-
export { ze as SeerChat, U as SeerChatPlugin,
|
|
741
|
+
}), [["__scopeId", "data-v-4cdc6832"]]);
|
|
742
|
+
export { ze as SeerChat, U as SeerChatPlugin, ce as SeerOrderCard, b as createSeerClient, I as linkAnchorLabel, R as toContentLines, L as toContentSegments, ee as useSeerChat, V as withoutCardText };
|
package/dist/useSeerChat.d.ts
CHANGED
|
@@ -108,7 +108,9 @@ export declare function useSeerChat(localOptions?: UseSeerChatOptions): {
|
|
|
108
108
|
size: number;
|
|
109
109
|
}[]>;
|
|
110
110
|
uploading: import("vue").Ref<boolean, boolean>;
|
|
111
|
-
attach: (file: File
|
|
111
|
+
attach: (file: File, attachOptions?: {
|
|
112
|
+
replace?: boolean;
|
|
113
|
+
}) => Promise<void>;
|
|
112
114
|
removeAttachment: (fileId: string) => void;
|
|
113
115
|
send: (content: string) => Promise<void>;
|
|
114
116
|
reset: () => void;
|