@matechat/core 0.0.2-alpha.1 → 1.1.0-alpha.0

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/List/index.js ADDED
@@ -0,0 +1,143 @@
1
+ import "./index.css";
2
+ import { ref as E, onMounted as L, computed as p, defineComponent as w, openBlock as u, createElementBlock as f, normalizeClass as g, unref as c, Fragment as b, renderList as z, renderSlot as h, createTextVNode as C, toDisplayString as T } from "vue";
3
+ var v = /* @__PURE__ */ ((e) => (e.Horizontal = "horizontal", e.Vertical = "vertical", e))(v || {}), k = /* @__PURE__ */ ((e) => (e.Transparent = "transparent", e.Filled = "filled", e.Bordered = "bordered", e.None = "none", e))(k || {});
4
+ const A = {
5
+ direction: {
6
+ type: String,
7
+ default: "vertical"
8
+ /* Vertical */
9
+ },
10
+ autoWrap: {
11
+ type: Boolean,
12
+ default: !0
13
+ },
14
+ variant: {
15
+ type: String,
16
+ default: "transparent"
17
+ /* Transparent */
18
+ },
19
+ enableLazyLoad: {
20
+ type: Boolean,
21
+ default: !1
22
+ },
23
+ data: {
24
+ type: Array,
25
+ default: () => []
26
+ },
27
+ enableShortKey: {
28
+ type: Boolean,
29
+ default: !1
30
+ },
31
+ inputEl: {
32
+ type: Object
33
+ },
34
+ selectable: {
35
+ type: Boolean,
36
+ default: !0
37
+ }
38
+ }, B = 50, H = ["TEXTAREA", "INPUT"], I = "ArrowUp", _ = "ArrowDown", N = "Enter";
39
+ function M(e, o) {
40
+ const n = E(e.enableShortKey ? 0 : -1), i = (t) => {
41
+ if (!t.disabled) {
42
+ if (e.selectable)
43
+ for (let l = 0; l < e.data.length; l++)
44
+ e.data[l].active = e.data[l].value === t.value;
45
+ o("select", { ...t });
46
+ }
47
+ }, s = (t) => {
48
+ if (!e.enableLazyLoad || e.direction !== v.Vertical)
49
+ return;
50
+ const l = t.target, r = l.scrollHeight, d = l.clientHeight, a = l.scrollTop;
51
+ r - d - a < B && o("loadMore", t);
52
+ }, m = (t) => {
53
+ t.code === I && (n.value = n.value === 0 ? e.data.length - 1 : n.value - 1), t.code === _ && (n.value = n.value === e.data.length - 1 ? 0 : n.value + 1), t.code === N && (e.selectable && (e.data[n.value].active = !0), o("select", { ...e.data[n.value] }));
54
+ };
55
+ return L(() => {
56
+ let t;
57
+ if (e.inputEl) {
58
+ const l = e.inputEl.$el ?? e.inputEl;
59
+ H.includes(l.tagName) ? t = l : t = l.querySelector("textarea") || l.querySelector("input") || document;
60
+ } else
61
+ t = document;
62
+ e.enableShortKey && t.addEventListener("keydown", m);
63
+ }), { preSelectIndex: n, onItemClick: i, onListScroll: s };
64
+ }
65
+ function D(e) {
66
+ return { listClasses: p(() => ({
67
+ "mc-list": !0,
68
+ "mc-list-horizontal": e.direction === v.Horizontal,
69
+ "mc-list-nowrap": e.direction === v.Horizontal && !e.autoWrap
70
+ })) };
71
+ }
72
+ const K = ["onClick"], U = /* @__PURE__ */ w({
73
+ __name: "List",
74
+ props: A,
75
+ emits: ["select", "loadMore"],
76
+ setup(e, { emit: o }) {
77
+ const n = e, i = o, { listClasses: s } = D(n), { preSelectIndex: m, onItemClick: t, onListScroll: l } = M(n, i);
78
+ return (r, d) => (u(), f(
79
+ "div",
80
+ {
81
+ class: g(c(s)),
82
+ onScroll: d[0] || (d[0] = //@ts-ignore
83
+ (...a) => c(l) && c(l)(...a))
84
+ },
85
+ [
86
+ (u(!0), f(
87
+ b,
88
+ null,
89
+ z(r.data, (a, y) => (u(), f(
90
+ b,
91
+ { key: y },
92
+ [
93
+ r.variant === c(k).None ? h(r.$slots, "item", {
94
+ key: 0,
95
+ item: a
96
+ }, void 0, !0) : (u(), f("div", {
97
+ key: 1,
98
+ class: g([
99
+ "mc-list-item",
100
+ {
101
+ "mc-list-item-disabled": a.disabled,
102
+ "mc-list-item-active": a.active,
103
+ "mc-list-item-pre-selection": y === c(m)
104
+ },
105
+ r.variant
106
+ ]),
107
+ onClick: () => c(t)(a)
108
+ }, [
109
+ h(r.$slots, "item", { item: a }, () => [
110
+ C(
111
+ T(a.label),
112
+ 1
113
+ /* TEXT */
114
+ )
115
+ ], !0)
116
+ ], 10, K))
117
+ ],
118
+ 64
119
+ /* STABLE_FRAGMENT */
120
+ ))),
121
+ 128
122
+ /* KEYED_FRAGMENT */
123
+ ))
124
+ ],
125
+ 34
126
+ /* CLASS, NEED_HYDRATION */
127
+ ));
128
+ }
129
+ }), $ = (e, o) => {
130
+ const n = e.__vccOpts || e;
131
+ for (const [i, s] of o)
132
+ n[i] = s;
133
+ return n;
134
+ }, S = /* @__PURE__ */ $(U, [["__scopeId", "data-v-adad50a4"]]);
135
+ S.install = (e) => {
136
+ e.component("McList", S);
137
+ };
138
+ export {
139
+ v as ListDirection,
140
+ k as ListVariant,
141
+ S as McList,
142
+ A as listProps
143
+ };
@@ -0,0 +1 @@
1
+ .mc-mention[data-v-4ce5ce76]{position:fixed;max-height:300px;border-radius:var(--devui-border-radius, 2px);background-color:var(--devui-connected-overlay-bg, #ffffff);box-shadow:var(--devui-shadow-length-connected-overlay, 0 2px 12px 0) var(--devui-shadow, rgba(37, 43, 58, .24));transform-origin:0% 100%;z-index:1000}.mc-mention-fade-enter-from[data-v-4ce5ce76],.mc-mention-fade-leave-to[data-v-4ce5ce76]{opacity:.8;transform:scaleY(.8) translateY(4px)}.mc-mention-fade-enter-to[data-v-4ce5ce76],.mc-mention-fade-leave-from[data-v-4ce5ce76]{opacity:1;transform:scaleY(.9999) translateY(0)}.mc-mention-fade-enter-active[data-v-4ce5ce76]{transition:transform .2s cubic-bezier(.16,.75,.5,1),opacity .2s cubic-bezier(.16,.75,.5,1)}.mc-mention-fade-leave-active[data-v-4ce5ce76]{transition:transform .2s cubic-bezier(.5,0,.84,.25),opacity .2s cubic-bezier(.5,0,.84,.25)}
@@ -0,0 +1,172 @@
1
+ import "./index.css";
2
+ import { ref as T, reactive as F, watch as K, nextTick as U, onMounted as G, onBeforeUnmount as J, defineComponent as Q, openBlock as C, createElementBlock as O, Fragment as X, createVNode as P, unref as A, withCtx as $, renderSlot as R, createBlock as Y, Teleport as Z, Transition as ee, normalizeClass as te, normalizeStyle as ne, createCommentVNode as oe } from "vue";
3
+ import { PopperTrigger as re } from "@matechat/core/PopperTrigger";
4
+ import { computePosition as ie, offset as le } from "@floating-ui/dom";
5
+ import { debounce as se, isObject as ae } from "lodash-es";
6
+ const ce = {
7
+ modelValue: {
8
+ type: Boolean,
9
+ default: !1
10
+ },
11
+ prefix: {
12
+ type: Array,
13
+ default: () => []
14
+ },
15
+ fitHostWidth: {
16
+ type: Boolean,
17
+ default: !0
18
+ },
19
+ menuClass: {
20
+ type: String
21
+ }
22
+ }, ue = ["update:modelValue", "searchChange", "toggleChange"], M = " ", de = "ArrowLeft", fe = "ArrowRight", me = "Escape";
23
+ function pe(r, l) {
24
+ const s = T(), t = T(), a = T(), c = F({ top: "0px", left: "0px", width: "" });
25
+ let o, i, v, w, h = "", y, d;
26
+ const E = async () => {
27
+ if (!t.value || !a.value)
28
+ return;
29
+ const { x: e, y: n } = await ie(t.value, a.value, {
30
+ strategy: "fixed",
31
+ placement: "top-start",
32
+ middleware: [le(4)]
33
+ });
34
+ c.top = `${n}px`, c.left = `${e}px`;
35
+ }, D = () => {
36
+ const { width: e } = t.value.getBoundingClientRect();
37
+ c.width = `${e}px`, E();
38
+ }, W = () => {
39
+ r.fitHostWidth && typeof window < "u" && t.value && (d = new window.ResizeObserver(D), d.observe(t.value));
40
+ }, _ = () => {
41
+ t.value && (d == null || d.unobserve(t.value));
42
+ };
43
+ K(
44
+ () => r.modelValue,
45
+ (e, n) => {
46
+ e ? (U(E), W(), typeof window < "u" && window.addEventListener("scroll", x, !0)) : (_(), typeof window < "u" && window.removeEventListener("scroll", x, !0)), n !== void 0 && l("toggleChange", e);
47
+ },
48
+ { immediate: !0 }
49
+ );
50
+ const L = () => {
51
+ i = null, v = -1, w = -1, h = "";
52
+ }, f = (e) => {
53
+ l("update:modelValue", e);
54
+ }, q = () => {
55
+ if (!o)
56
+ return;
57
+ const e = o.value.replace(/[\r\n]/g, M) || "", n = o.selectionStart;
58
+ if (!e.trim() || !n) {
59
+ L();
60
+ return;
61
+ }
62
+ for (let u = 0; u < r.prefix.length; u++) {
63
+ const m = r.prefix[u];
64
+ let p = "", I = !1;
65
+ if (typeof m == "string")
66
+ p = m;
67
+ else if (ae(m))
68
+ p = m.key, I = !!m.onlyInputStart;
69
+ else
70
+ continue;
71
+ const g = e.lastIndexOf(p, n), N = e.lastIndexOf(M, n), S = e.substring(g, n), j = S.charAt(S.length - 1);
72
+ if (g < 0 || g > 0 && I || g < N || j === M)
73
+ L();
74
+ else {
75
+ i = p, v = g, w = n, h = S.slice(p.length);
76
+ return;
77
+ }
78
+ }
79
+ }, k = () => {
80
+ if (q(), !i) {
81
+ f(!1);
82
+ return;
83
+ }
84
+ l("searchChange", { value: h, trigger: i, triggerIndex: v, cursorIndex: w }), f(!0);
85
+ }, V = se(k, 300), b = (e) => {
86
+ (e.code === de || e.code === fe) && (y = setTimeout(() => {
87
+ k(), y && (y = void 0, clearTimeout(y));
88
+ })), e.code === me && f(!1);
89
+ }, B = (e) => {
90
+ var n, u;
91
+ r.modelValue ? (n = t.value) != null && n.contains(e.target) || f(!1) : (u = t.value) != null && u.contains(e.target) && k();
92
+ };
93
+ function x(e) {
94
+ const n = e.target;
95
+ n != null && n.contains(t.value) && E();
96
+ }
97
+ const H = () => {
98
+ t.value && (o = t.value.querySelector("textarea") || t.value.querySelector("input"), o && (o.addEventListener("input", V), o.addEventListener("keydown", b))), document.addEventListener("click", B);
99
+ };
100
+ return G(() => {
101
+ const e = s.value.triggerEl;
102
+ t.value = e.$el ?? e, H();
103
+ }), J(() => {
104
+ f(!1), o == null || o.removeEventListener("input", V), o == null || o.removeEventListener("keydown", b), document.removeEventListener("click", B), typeof window < "u" && window.removeEventListener("scroll", x, !0), _();
105
+ }), { popperTriggerEl: s, overlayEl: a, overlayStyle: c };
106
+ }
107
+ const ge = /* @__PURE__ */ Q({
108
+ __name: "Mention",
109
+ props: ce,
110
+ emits: ue,
111
+ setup(r, { emit: l }) {
112
+ const s = r, t = l, { popperTriggerEl: a, overlayEl: c, overlayStyle: o } = pe(s, t);
113
+ return (i, v) => (C(), O(
114
+ X,
115
+ null,
116
+ [
117
+ P(
118
+ A(re),
119
+ {
120
+ ref_key: "popperTriggerEl",
121
+ ref: a
122
+ },
123
+ {
124
+ default: $(() => [
125
+ R(i.$slots, "default", {}, void 0, !0)
126
+ ]),
127
+ _: 3
128
+ /* FORWARDED */
129
+ },
130
+ 512
131
+ /* NEED_PATCH */
132
+ ),
133
+ (C(), Y(Z, { to: "body" }, [
134
+ P(ee, { name: "mc-mention-fade" }, {
135
+ default: $(() => [
136
+ i.modelValue ? (C(), O(
137
+ "div",
138
+ {
139
+ key: 0,
140
+ ref_key: "overlayEl",
141
+ ref: c,
142
+ class: te(["mc-mention", i.menuClass]),
143
+ style: ne(A(o))
144
+ },
145
+ [
146
+ R(i.$slots, "menu", {}, void 0, !0)
147
+ ],
148
+ 6
149
+ /* CLASS, STYLE */
150
+ )) : oe("v-if", !0)
151
+ ]),
152
+ _: 3
153
+ /* FORWARDED */
154
+ })
155
+ ]))
156
+ ],
157
+ 64
158
+ /* STABLE_FRAGMENT */
159
+ ));
160
+ }
161
+ }), ve = (r, l) => {
162
+ const s = r.__vccOpts || r;
163
+ for (const [t, a] of l)
164
+ s[t] = a;
165
+ return s;
166
+ }, z = /* @__PURE__ */ ve(ge, [["__scopeId", "data-v-4ce5ce76"]]);
167
+ z.install = (r) => {
168
+ r.component("McMention", z);
169
+ };
170
+ export {
171
+ z as McMention
172
+ };
@@ -0,0 +1,48 @@
1
+ import { Comment as s, Text as a, Fragment as m, h as g, defineComponent as h, ref as v, withDirectives as C, cloneVNode as y } from "vue";
2
+ import { isObject as x } from "@vue/shared";
3
+ function p(e) {
4
+ return g("span", {}, e);
5
+ }
6
+ function c(e) {
7
+ for (const t of e) {
8
+ if (x(t)) {
9
+ if (t.type === s)
10
+ continue;
11
+ return t.type === "svg" || t.type === a ? p(t) : t.type === m ? c(t.children) : t;
12
+ }
13
+ return p(t);
14
+ }
15
+ return null;
16
+ }
17
+ const F = /* @__PURE__ */ h({
18
+ setup(e, t) {
19
+ const {
20
+ slots: r,
21
+ attrs: i,
22
+ expose: d
23
+ } = t, n = v();
24
+ return d({
25
+ triggerEl: n
26
+ }), () => {
27
+ var f;
28
+ const o = (f = r.default) == null ? void 0 : f.call(r, i);
29
+ if (!o)
30
+ return null;
31
+ const l = c(o);
32
+ return l ? C(y(l, i), [[{
33
+ mounted(u) {
34
+ n.value = u;
35
+ },
36
+ updated(u) {
37
+ n.value = u;
38
+ },
39
+ unmounted() {
40
+ n.value = null;
41
+ }
42
+ }]]) : null;
43
+ };
44
+ }
45
+ });
46
+ export {
47
+ F as PopperTrigger
48
+ };
@@ -0,0 +1 @@
1
+ .mc-prompt-item[data-v-5f016595]{display:flex;gap:8px}.mc-prompt-item .mc-prompt-item-icon.no-description[data-v-5f016595]{display:flex;align-items:center}.mc-prompt-item .mc-prompt-item-content[data-v-5f016595]{display:flex;flex-direction:column;gap:4px}.mc-prompt-item .mc-prompt-item-content .mc-prompt-item-label[data-v-5f016595]{font-weight:700}.mc-prompt-item .mc-prompt-item-content .mc-prompt-item-description[data-v-5f016595]{color:var(--devui-aide-text, #71757f)}
@@ -0,0 +1,110 @@
1
+ import "./index.css";
2
+ import { defineComponent as y, openBlock as r, createElementBlock as s, createElementVNode as P, normalizeClass as h, createBlock as g, unref as C, normalizeProps as b, mergeProps as I, createCommentVNode as c, toDisplayString as v, createVNode as u, withCtx as V } from "vue";
3
+ import { ListDirection as B, ListVariant as L, McList as M } from "@matechat/core/List";
4
+ import { Icon as N } from "vue-devui/icon";
5
+ import "vue-devui/icon/style.css";
6
+ const S = {
7
+ direction: {
8
+ type: String,
9
+ default: B.Vertical
10
+ },
11
+ list: {
12
+ type: Array,
13
+ default: () => []
14
+ },
15
+ variant: {
16
+ type: String,
17
+ default: L.Filled
18
+ }
19
+ }, $ = {
20
+ prompt: {
21
+ type: Object
22
+ }
23
+ }, z = { class: "mc-prompt-item" }, D = {
24
+ key: 0,
25
+ class: "mc-prompt-item-content"
26
+ }, E = {
27
+ key: 0,
28
+ class: "mc-prompt-item-label"
29
+ }, O = {
30
+ key: 1,
31
+ class: "mc-prompt-item-description"
32
+ }, j = /* @__PURE__ */ y({
33
+ __name: "PromptItem",
34
+ props: $,
35
+ setup(o) {
36
+ return (t, p) => {
37
+ var e, i, m, n, a, l, d, _, f;
38
+ return r(), s("div", z, [
39
+ P(
40
+ "div",
41
+ {
42
+ class: h(["mc-prompt-item-icon", { "no-description": !((e = t.prompt) != null && e.desc) }])
43
+ },
44
+ [
45
+ (i = t.prompt) != null && i.iconConfig ? (r(), g(
46
+ C(N),
47
+ b(I({ key: 0 }, (m = t.prompt) == null ? void 0 : m.iconConfig)),
48
+ null,
49
+ 16
50
+ /* FULL_PROPS */
51
+ )) : c("v-if", !0)
52
+ ],
53
+ 2
54
+ /* CLASS */
55
+ ),
56
+ (n = t.prompt) != null && n.label || (a = t.prompt) != null && a.desc ? (r(), s("div", D, [
57
+ (l = t.prompt) != null && l.label ? (r(), s(
58
+ "div",
59
+ E,
60
+ v((d = t.prompt) == null ? void 0 : d.label),
61
+ 1
62
+ /* TEXT */
63
+ )) : c("v-if", !0),
64
+ (_ = t.prompt) != null && _.desc ? (r(), s(
65
+ "div",
66
+ O,
67
+ v((f = t.prompt) == null ? void 0 : f.desc),
68
+ 1
69
+ /* TEXT */
70
+ )) : c("v-if", !0)
71
+ ])) : c("v-if", !0)
72
+ ]);
73
+ };
74
+ }
75
+ }), w = (o, t) => {
76
+ const p = o.__vccOpts || o;
77
+ for (const [e, i] of t)
78
+ p[e] = i;
79
+ return p;
80
+ }, A = /* @__PURE__ */ w(j, [["__scopeId", "data-v-5f016595"]]), F = { class: "mc-prompt" }, k = /* @__PURE__ */ y({
81
+ __name: "Prompt",
82
+ props: S,
83
+ emits: ["itemClick"],
84
+ setup(o, { emit: t }) {
85
+ const p = t, e = o;
86
+ return (i, m) => (r(), s("div", F, [
87
+ u(C(M), {
88
+ data: e.list,
89
+ direction: e.direction,
90
+ variant: e.variant,
91
+ selectable: !1
92
+ }, {
93
+ item: V(({ item: n }) => [
94
+ u(A, {
95
+ prompt: n,
96
+ onClick: (a) => p("itemClick", n)
97
+ }, null, 8, ["prompt", "onClick"])
98
+ ]),
99
+ _: 1
100
+ /* STABLE */
101
+ }, 8, ["data", "direction", "variant"])
102
+ ]));
103
+ }
104
+ });
105
+ k.install = (o) => {
106
+ o.component("McPrompt", k);
107
+ };
108
+ export {
109
+ k as McPrompt
110
+ };
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  </a>
5
5
  </p>
6
6
  <h1 align="center">MateChat</h1>
7
- <p align="center">前端智能化场景解决方案UI库,轻松构建你的AI应用。已服务于内部多个应用智能化改造,并助力InsCode AI IDE智能化助手搭建。</p>
7
+ <p align="center">前端智能化场景解决方案UI库,轻松构建你的AI应用。已服务于华为内部多个应用智能化改造,并助力CodeArts、InsCode AI IDE等智能化助手搭建。</p>
8
8
 
9
9
  ![example](https://matechat.gitcode.com/example1.png)
10
10
 
@@ -34,20 +34,17 @@ $ npm i vue-devui @matechat/core @devui-design/icons
34
34
 
35
35
  ### 2. 引入
36
36
 
37
- 在`main.ts`文件中引入`matechat`, `vue-devui` 以及 `图标库` 样式文件
37
+ 在`main.ts`文件中引入`matechat`, `图标库` 样式文件
38
38
 
39
39
  ```ts
40
40
  import { createApp } from 'vue';
41
41
  import App from './App.vue';
42
42
 
43
- // matechat基于vue-devui组件
44
- import DevUI from 'vue-devui';
45
43
  import MateChat from '@matechat/core';
46
44
 
47
- import 'vue-devui/style.css';
48
45
  import '@devui-design/icons/icomoon/devui-icon.css';
49
46
 
50
- createApp(App).use(DevUI).use(MateChat).mount('#app');
47
+ createApp(App).use(MateChat).mount('#app');
51
48
  ```
52
49
 
53
50
  ### 3. 使用
@@ -56,7 +53,7 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
56
53
 
57
54
  ```html
58
55
  <template>
59
- <McBubble :avatarConfig="{ name: 'matechat' }">
56
+ <McBubble :content="'Hello, MateChat'" :avatarConfig="{ name: 'matechat' }"></McBubble>
60
57
  </template>
61
58
  ```
62
59
 
@@ -109,16 +106,13 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
109
106
  style="flex: 1"
110
107
  @itemClick="onSubmit($event.label)"
111
108
  ></McPrompt>
112
- <d-button
109
+ <Button
113
110
  style="margin-left: auto"
114
111
  icon="add"
115
112
  shape="circle"
116
113
  title="新建对话"
117
114
  size="sm"
118
- @click="
119
- startPage = true;
120
- messages = [];
121
- "
115
+ @click="newConversation"
122
116
  />
123
117
  </div>
124
118
  <McLayoutSender>
@@ -134,7 +128,7 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
134
128
  <span class="input-foot-maxlength">{{ inputValue.length }}/2000</span>
135
129
  </div>
136
130
  <div class="input-foot-right">
137
- <d-button icon="op-clearup" shape="round" :disabled="!inputValue" @click="inputValue = ''">清空输入</d-button>
131
+ <Button icon="op-clearup" shape="round" :disabled="!inputValue" @click="inputValue = ''">清空输入</Button>
138
132
  </div>
139
133
  </div>
140
134
  </template>
@@ -145,6 +139,8 @@ createApp(App).use(DevUI).use(MateChat).mount('#app');
145
139
 
146
140
  <script setup lang="ts">
147
141
  import { ref } from 'vue';
142
+ import Button from 'vue-devui/button';
143
+ import 'vue-devui/button/style.css';
148
144
 
149
145
  const description = [
150
146
  'MateChat 可以辅助研发人员编码、查询知识和相关作业信息、编写文档等。',
@@ -205,7 +201,13 @@ const messages = ref<any[]>([
205
201
  },
206
202
  ]);
207
203
 
204
+ const newConversation = () => {
205
+ startPage.value = true;
206
+ messages.value = [];
207
+ }
208
+
208
209
  const onSubmit = (evt) => {
210
+ inputValue.value='';
209
211
  startPage.value = false;
210
212
  // 用户发送消息
211
213
  messages.value.push({
@@ -225,11 +227,13 @@ const onSubmit = (evt) => {
225
227
  <style>
226
228
  .container {
227
229
  width: 1000px;
228
- margin: 0 auto;
229
- height: 100vh;
230
+ margin: 20px auto;
231
+ height: calc(100vh - 40px);
230
232
  padding: 20px;
231
233
  gap: 8px;
232
234
  background: #fff;
235
+ border: 1px solid #ddd;
236
+ border-radius: 16px;
233
237
  }
234
238
 
235
239
  .content-container {
@@ -308,7 +312,7 @@ client.value = new OpenAI({
308
312
 
309
313
  const fetchData = (ques) => {
310
314
  const completion = await client.value!.chat.completions.create({
311
- model: 'my-model', //
315
+ model: 'my-model', // 替换为自己的model名称
312
316
  messages: [
313
317
  { role: 'user', content: ques },
314
318
  ],
@@ -325,8 +329,10 @@ const fetchData = (ques) => {
325
329
  那么参考以上步骤,【快速开始】中示例可调整下代码。
326
330
 
327
331
  将以下代码:
332
+
328
333
  ```ts
329
334
  const onSubmit = (evt) => {
335
+ inputValue.value = '';
330
336
  startPage.value = false;
331
337
  // 用户发送消息
332
338
  messages.value.push({
@@ -340,9 +346,11 @@ const onSubmit = (evt) => {
340
346
  content: evt,
341
347
  });
342
348
  }, 200);
349
+ };
343
350
  ```
344
351
 
345
352
  修改为:
353
+
346
354
  ```ts
347
355
  import OpenAI from 'openai';
348
356
 
@@ -355,13 +363,15 @@ client.value = new OpenAI({
355
363
  });
356
364
 
357
365
  const onSubmit = (evt) => {
366
+ inputValue.value = '';
367
+ startPage.value = false;
358
368
  // 用户发送消息
359
369
  messages.value.push({
360
370
  from: 'user',
361
371
  content: evt,
362
372
  avatarConfig: { name: 'user' },
363
373
  });
364
-
374
+
365
375
  fetchData(evt);
366
376
  };
367
377
 
@@ -374,7 +384,7 @@ const fetchData = async (ques) => {
374
384
  loading: true,
375
385
  });
376
386
  const completion = await client.value!.chat.completions.create({
377
- model: 'my-model', //
387
+ model: 'my-model', // 替换为自己的model名称
378
388
  messages: [{ role: 'user', content: ques }],
379
389
  stream: true, // 为 true 则开启接口的流式返回
380
390
  });
@@ -387,7 +397,8 @@ const fetchData = async (ques) => {
387
397
  }
388
398
  };
389
399
  ```
390
- 完成模型API地址与APIKey填充后,即拥有了一个对接大模型的简单应用。
400
+
401
+ 完成模型API地址与APIKey填充后,即拥有了一个对接大模型的简单应用。如果你想要参考更完整的页面示例,可参考[演示场景](https://matechat.gitcode.com/playground/playground.html)。
391
402
 
392
403
  ## 📝 提出意见&建议
393
404
 
@@ -412,6 +423,8 @@ MateChat 在不断的演进中,你可在这里了解我们的计划:[MateCha
412
423
 
413
424
  ## 谁在使用
414
425
 
426
+ [CodeArts盘古助手](https://www.huaweicloud.com/product/codeartside/snap.html)
427
+
415
428
  [InsCode AI IDE](https://inscode.csdn.net/)
416
429
 
417
430
  ## License
@@ -420,4 +433,4 @@ MateChat 在不断的演进中,你可在这里了解我们的计划:[MateCha
420
433
 
421
434
  ## 联系方式
422
435
 
423
- 欢迎加入我们的开源社区,关注DevUI微信公众号:DevUI
436
+ 欢迎加入我们的开源社区,关注DevUI微信公众号:DevUI
package/index.d.ts CHANGED
@@ -2,6 +2,5 @@ import type { App } from 'vue';
2
2
  declare function install(app: App): void
3
3
  declare const _default: {
4
4
  install: typeof install;
5
- version: string;
6
5
  };
7
6
  export default _default;