@zero-library/chat-agent 2.0.5 → 2.0.6
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.cjs.js +10 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +10 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -204,16 +204,7 @@ var init_IndexQuote = __esm({
|
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
206
|
const Content = /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { align: "center", gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx("a", { onClick, children: data.fileName }) }) });
|
|
207
|
-
|
|
208
|
-
react.useEffect(() => {
|
|
209
|
-
const el = rootRef.current;
|
|
210
|
-
if (!el) return;
|
|
211
|
-
const previous = el.previousElementSibling;
|
|
212
|
-
if (!previous) return;
|
|
213
|
-
console.log("previous", previous, el);
|
|
214
|
-
previous.appendChild(el);
|
|
215
|
-
}, []);
|
|
216
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: rootRef, className: "inline-block m-l-8", children: [
|
|
207
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block m-l-8", children: [
|
|
217
208
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Spin, { spinning: loading, size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Popover, { content: Content, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tag, { bordered: false, color: "processing", className: "cursor-pointer", children: data.index }) }) }),
|
|
218
209
|
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { fileUrl: data.fileUrl, title: data.fileName, open, onClose: () => setOpen(false) })
|
|
219
210
|
] });
|
|
@@ -235,16 +226,15 @@ var init_MdEdit = __esm({
|
|
|
235
226
|
const chatStore = useChatStore();
|
|
236
227
|
const [value, setValue] = react.useState("");
|
|
237
228
|
const onOk = () => {
|
|
238
|
-
console.log("value", value);
|
|
239
229
|
chatStore.sendMessage("\u5F00\u59CB\u5199\u4F5C", [], { outline: value });
|
|
240
230
|
};
|
|
241
231
|
react.useEffect(() => {
|
|
242
232
|
setValue(data.content);
|
|
243
233
|
}, [data.content]);
|
|
244
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
234
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_module_default2.mdEdit, children: [
|
|
245
235
|
/* @__PURE__ */ jsxRuntime.jsx(common.MarkdownEditor, { disabled: loading, value, onChange: setValue, showToolbar: false }),
|
|
246
236
|
!loading && /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { justify: "end", className: "m-t-16", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { color: "primary", variant: "outlined", onClick: onOk, children: "\u786E\u8BA4\u63D0\u7EB2\u601D\u8DEF\uFF0C\u5F00\u59CB\u5199\u4F5C" }) })
|
|
247
|
-
] })
|
|
237
|
+
] });
|
|
248
238
|
};
|
|
249
239
|
}
|
|
250
240
|
});
|
|
@@ -305,7 +295,7 @@ var init_QuoteList = __esm({
|
|
|
305
295
|
}
|
|
306
296
|
};
|
|
307
297
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
308
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
298
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
309
299
|
antd.Collapse,
|
|
310
300
|
{
|
|
311
301
|
className: styles_module_default2.quoteList,
|
|
@@ -316,11 +306,11 @@ var init_QuoteList = __esm({
|
|
|
316
306
|
{
|
|
317
307
|
key: "1",
|
|
318
308
|
label: "\u53C2\u8003\u8D44\u6599",
|
|
319
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx("p", { onClick: () => onClick(item), className: "cursor-pointer", children: item.title }, item.fileUrl)) })
|
|
309
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 4, children: data.list.map((item) => /* @__PURE__ */ jsxRuntime.jsx("p", { onClick: () => !loading && onClick(item), className: "cursor-pointer", children: item.title }, item.fileUrl)) })
|
|
320
310
|
}
|
|
321
311
|
]
|
|
322
312
|
}
|
|
323
|
-
)
|
|
313
|
+
),
|
|
324
314
|
open && /* @__PURE__ */ jsxRuntime.jsx(DocDrawer_default, { fileUrl: selectItem.fileUrl, title: selectItem.title, open, onClose: () => setOpen(false) })
|
|
325
315
|
] });
|
|
326
316
|
};
|
|
@@ -661,13 +651,14 @@ function createChatStore() {
|
|
|
661
651
|
const switchConversation = async (chat) => {
|
|
662
652
|
const chatKey = chat?.key || `${agent.active.id}-${DEFAULT_NEW_CONV_ID}`;
|
|
663
653
|
if (conversation.active.key === chatKey) return;
|
|
664
|
-
const
|
|
654
|
+
const isNew = !chat?.key;
|
|
655
|
+
const canProceed = await config.hooks?.onBeforeSwitchConversation?.(chatKey, isNew);
|
|
665
656
|
if (canProceed === false) return;
|
|
666
657
|
conversation.active = chat?.key ? chat : { key: chatKey };
|
|
667
658
|
if (!conversation.messages[chatKey]) {
|
|
668
659
|
setInitMessage(chatKey);
|
|
669
660
|
}
|
|
670
|
-
config.hooks?.onAfterSwitchConversation?.(chatKey);
|
|
661
|
+
config.hooks?.onAfterSwitchConversation?.(chatKey, isNew);
|
|
671
662
|
if (!chatKey.endsWith(DEFAULT_NEW_CONV_ID) && conversation.messages[chatKey].message.items.length === 0) {
|
|
672
663
|
getMessages(agent.active.id, chatKey);
|
|
673
664
|
}
|
|
@@ -1760,7 +1751,7 @@ var layouts_default = react.forwardRef(({ theme, params, hooks, layout, defaultA
|
|
|
1760
1751
|
value: configState.preview.file.content,
|
|
1761
1752
|
onQuote: (text) => {
|
|
1762
1753
|
chatStore.setReferences({
|
|
1763
|
-
type:
|
|
1754
|
+
type: 1,
|
|
1764
1755
|
content: {
|
|
1765
1756
|
name: text,
|
|
1766
1757
|
markdown: text
|