listpage-next 0.0.268 → 0.0.270
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/features/ChatClient/ui/Bubble/Markdown.d.ts +2 -4
- package/dist/features/ChatClient/ui/Bubble/Markdown.js +5 -4
- package/dist/features/ChatClient/ui/ChatInput/index.js +1 -0
- package/dist/features/ChatClient/ui/ConversationDropdownMenu/index.d.ts +1 -0
- package/dist/features/ChatClient/ui/ConversationDropdownMenu/index.js +105 -49
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { XMarkdownProps } from '@ant-design/x-markdown';
|
|
2
2
|
import '@ant-design/x-markdown/themes/light.css';
|
|
3
|
-
export interface MarkdownProps {
|
|
4
|
-
content: string;
|
|
3
|
+
export interface MarkdownProps extends XMarkdownProps {
|
|
5
4
|
hasNextChunk?: boolean;
|
|
6
|
-
components?: XMarkdownProps['components'];
|
|
7
5
|
}
|
|
8
|
-
export declare const Markdown: (props: MarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const Markdown: ({ hasNextChunk, ...props }: MarkdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,15 +2,16 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import styled_components from "styled-components";
|
|
3
3
|
import x_markdown from "@ant-design/x-markdown";
|
|
4
4
|
import "@ant-design/x-markdown/themes/light.css";
|
|
5
|
-
const Markdown = (props)=>/*#__PURE__*/ jsx(MarkdownBody, {
|
|
5
|
+
const Markdown = ({ hasNextChunk, ...props })=>/*#__PURE__*/ jsx(MarkdownBody, {
|
|
6
|
+
...props,
|
|
6
7
|
streaming: {
|
|
7
8
|
enableAnimation: true,
|
|
8
|
-
hasNextChunk
|
|
9
|
+
hasNextChunk,
|
|
9
10
|
animationConfig: {
|
|
10
11
|
fadeDuration: 400
|
|
11
|
-
}
|
|
12
|
+
},
|
|
13
|
+
...props.streaming
|
|
12
14
|
},
|
|
13
|
-
content: props.content,
|
|
14
15
|
openLinksInNewTab: true
|
|
15
16
|
});
|
|
16
17
|
const MarkdownBody = styled_components(x_markdown)`
|
|
@@ -10,6 +10,7 @@ export interface ConversationDropdownMenuProps<T extends BaseConversation = Base
|
|
|
10
10
|
}>;
|
|
11
11
|
onSelect?: (item: T) => void;
|
|
12
12
|
onDelete?: (item: T) => void | Promise<void>;
|
|
13
|
+
onUpdate?: (title: string, item: T) => void | Promise<void>;
|
|
13
14
|
activeKey?: string;
|
|
14
15
|
}
|
|
15
16
|
export declare const ConversationDropdownMenu: <T extends BaseConversation = any>(props: ConversationDropdownMenuProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DeleteOutlined, HistoryOutlined } from "@ant-design/icons";
|
|
3
|
-
import { PageLoading } from "../../../../components/index.js";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DeleteOutlined, EditOutlined, HistoryOutlined } from "@ant-design/icons";
|
|
3
|
+
import { PageLoading, PageModal } from "../../../../components/index.js";
|
|
4
4
|
import { useRequest } from "ahooks";
|
|
5
|
-
import { Button, Dropdown, Tooltip } from "antd";
|
|
5
|
+
import { Button, Dropdown, Input, Tooltip } from "antd";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
6
7
|
import styled_components from "styled-components";
|
|
7
8
|
import { getConversationsGroup } from "./utils.js";
|
|
8
9
|
const ConversationDropdownMenu = (props)=>{
|
|
9
|
-
const { request, onSelect, onDelete, activeKey } = props;
|
|
10
|
+
const { request, onSelect, onDelete, activeKey, onUpdate } = props;
|
|
11
|
+
const [editingItem, setEditingItem] = useState(null);
|
|
10
12
|
const { data, run: refresh, loading, mutate } = useRequest(()=>request(), {
|
|
11
13
|
manual: true
|
|
12
14
|
});
|
|
@@ -17,21 +19,35 @@ const ConversationDropdownMenu = (props)=>{
|
|
|
17
19
|
/*#__PURE__*/ jsx("span", {
|
|
18
20
|
children: item.title || item
|
|
19
21
|
}),
|
|
20
|
-
/*#__PURE__*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
/*#__PURE__*/ jsxs("div", {
|
|
23
|
+
className: "action-btns",
|
|
24
|
+
children: [
|
|
25
|
+
Boolean(onUpdate) && /*#__PURE__*/ jsx(Button, {
|
|
26
|
+
type: "text",
|
|
27
|
+
size: "small",
|
|
28
|
+
icon: /*#__PURE__*/ jsx(EditOutlined, {}),
|
|
29
|
+
onClick: (e)=>{
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
setEditingItem(item);
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ jsx(Button, {
|
|
36
|
+
type: "text",
|
|
37
|
+
size: "small",
|
|
38
|
+
danger: true,
|
|
39
|
+
icon: /*#__PURE__*/ jsx(DeleteOutlined, {}),
|
|
40
|
+
onClick: async (e)=>{
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
await onDelete?.(item);
|
|
44
|
+
const list = (data?.list ?? []).filter((x)=>x.id !== item.id);
|
|
45
|
+
mutate?.({
|
|
46
|
+
list
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
]
|
|
35
51
|
})
|
|
36
52
|
]
|
|
37
53
|
}),
|
|
@@ -53,35 +69,73 @@ const ConversationDropdownMenu = (props)=>{
|
|
|
53
69
|
type: 'divider'
|
|
54
70
|
});
|
|
55
71
|
});
|
|
56
|
-
return /*#__PURE__*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
75
|
+
title: "历史会话",
|
|
76
|
+
children: /*#__PURE__*/ jsx(Dropdown, {
|
|
77
|
+
trigger: [
|
|
78
|
+
'click'
|
|
79
|
+
],
|
|
80
|
+
menu: {
|
|
81
|
+
items: menus,
|
|
82
|
+
activeKey
|
|
83
|
+
},
|
|
84
|
+
popupRender: (originNode)=>{
|
|
85
|
+
if (loading || !data?.list?.length) {
|
|
86
|
+
const content = loading ? /*#__PURE__*/ jsx(PageLoading, {}) : '暂无历史会话';
|
|
87
|
+
return /*#__PURE__*/ jsx(MenuPanelContainer, {
|
|
88
|
+
children: /*#__PURE__*/ jsx(DefaultPanelContainer, {
|
|
89
|
+
children: content
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/ jsx(MenuPanelContainer, {
|
|
94
|
+
children: originNode
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
98
|
+
onClick: refresh,
|
|
99
|
+
type: "text",
|
|
100
|
+
icon: /*#__PURE__*/ jsx(HistoryOutlined, {
|
|
101
|
+
size: 16
|
|
72
102
|
})
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
return /*#__PURE__*/ jsx(MenuPanelContainer, {
|
|
76
|
-
children: originNode
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
80
|
-
onClick: refresh,
|
|
81
|
-
type: "text",
|
|
82
|
-
icon: /*#__PURE__*/ jsx(HistoryOutlined, {
|
|
83
|
-
size: 16
|
|
103
|
+
})
|
|
84
104
|
})
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ jsx(EditModal, {
|
|
107
|
+
visible: !!editingItem,
|
|
108
|
+
record: editingItem,
|
|
109
|
+
onOk: (newTitle)=>{
|
|
110
|
+
onUpdate?.(newTitle, editingItem);
|
|
111
|
+
setEditingItem(null);
|
|
112
|
+
},
|
|
113
|
+
onClose: ()=>setEditingItem(null)
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const EditModal = ({ record, visible, onOk, onClose })=>{
|
|
119
|
+
const [editTitle, setEditTitle] = useState('');
|
|
120
|
+
useEffect(()=>{
|
|
121
|
+
setEditTitle(record?.title || '');
|
|
122
|
+
}, [
|
|
123
|
+
record
|
|
124
|
+
]);
|
|
125
|
+
return /*#__PURE__*/ jsx(PageModal, {
|
|
126
|
+
title: "编辑会话标题",
|
|
127
|
+
open: visible,
|
|
128
|
+
actionPosition: "bottom",
|
|
129
|
+
onOk: async ()=>onOk?.(editTitle),
|
|
130
|
+
onCancel: onClose,
|
|
131
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
132
|
+
style: {
|
|
133
|
+
padding: 24
|
|
134
|
+
},
|
|
135
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
136
|
+
value: editTitle,
|
|
137
|
+
onChange: (e)=>setEditTitle(e.target.value),
|
|
138
|
+
placeholder: "请输入新标题"
|
|
85
139
|
})
|
|
86
140
|
})
|
|
87
141
|
});
|
|
@@ -106,12 +160,14 @@ const MenuItemLabel = styled_components.div`
|
|
|
106
160
|
justify-content: space-between;
|
|
107
161
|
gap: 8px;
|
|
108
162
|
width: 100%;
|
|
109
|
-
.
|
|
163
|
+
.action-btns {
|
|
110
164
|
opacity: 0;
|
|
111
165
|
visibility: hidden;
|
|
112
166
|
transition: opacity 0.2s ease;
|
|
167
|
+
display: flex;
|
|
168
|
+
gap: 4px;
|
|
113
169
|
}
|
|
114
|
-
&:hover .
|
|
170
|
+
&:hover .action-btns {
|
|
115
171
|
opacity: 1;
|
|
116
172
|
visibility: visible;
|
|
117
173
|
}
|