listpage-next 0.0.78 → 0.0.80
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/components/InfiniteList/index.d.ts +3 -1
- package/dist/components/InfiniteList/index.js +17 -49
- package/dist/components/InfiniteList/styles.d.ts +7 -0
- package/dist/components/InfiniteList/styles.js +44 -0
- package/dist/features/ChatClient/components/ChatSender/index.js +8 -4
- package/dist/features/ChatClient/components/ClientContent/Header.js +8 -38
- package/dist/features/ChatClient/components/ClientContent/index.d.ts +1 -1
- package/dist/features/ChatClient/components/ClientContent/index.js +1 -1
- package/dist/features/ChatClient/components/HistoryConversation/index.d.ts +3 -3
- package/dist/features/ChatClient/components/HistoryConversation/index.js +18 -5
- package/dist/features/ChatClient/components/Layout/ChatPage.d.ts +2 -2
- package/dist/features/ChatClient/context/index.d.ts +7 -3
- package/dist/features/ChatClient/context/index.js +14 -4
- package/dist/features/ChatClient/context/useConversationListRef.d.ts +7 -0
- package/dist/features/ChatClient/context/useConversationListRef.js +9 -0
- package/dist/features/ChatClient/context/useUpdateTitleModal.d.ts +4 -0
- package/dist/features/ChatClient/context/useUpdateTitleModal.js +33 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
1
2
|
export type RenderActions<DataType = any> = {
|
|
2
3
|
updateItem: (key: string, item: DataType) => void;
|
|
3
4
|
deleteItem: (key: string) => void;
|
|
@@ -17,4 +18,5 @@ export interface InfiniteListProps<DataType = any> {
|
|
|
17
18
|
pageSize?: number;
|
|
18
19
|
rowKey?: string;
|
|
19
20
|
}
|
|
20
|
-
export
|
|
21
|
+
export type InfiniteListRef<DataType = any> = Ref<RenderActions<DataType>>;
|
|
22
|
+
export declare const InfiniteList: import("react").ForwardRefExoticComponent<InfiniteListProps<Record<string, any>> & import("react").RefAttributes<RenderActions<Record<string, any>>>>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
3
|
import { useRequest } from "ahooks";
|
|
4
|
-
import {
|
|
4
|
+
import { message } from "antd";
|
|
5
5
|
import rc_virtual_list from "rc-virtual-list";
|
|
6
|
-
import
|
|
7
|
-
const InfiniteList = (props)=>{
|
|
6
|
+
import { ListContainer } from "./styles.js";
|
|
7
|
+
const InfiniteList = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
8
8
|
const { request, renderItem, pageSize, rowKey = 'id' } = props;
|
|
9
|
-
const ref = useRef(null);
|
|
10
9
|
const [pagination, setPagination] = useState({
|
|
11
10
|
current: 1,
|
|
12
11
|
pageSize: pageSize ?? 10
|
|
13
12
|
});
|
|
13
|
+
const containerRef = useRef(null);
|
|
14
14
|
const [list, setList] = useState([]);
|
|
15
15
|
const [hasMore, setHasMore] = useState(true);
|
|
16
16
|
const { loading, run: loadMoreData } = useRequest(()=>request(pagination), {
|
|
@@ -48,11 +48,20 @@ const InfiniteList = (props)=>{
|
|
|
48
48
|
pageSize: pageSize ?? 10
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
|
+
useImperativeHandle(ref, ()=>({
|
|
52
|
+
deleteItem,
|
|
53
|
+
updateItem,
|
|
54
|
+
resetPagination
|
|
55
|
+
}), [
|
|
56
|
+
deleteItem,
|
|
57
|
+
updateItem,
|
|
58
|
+
resetPagination
|
|
59
|
+
]);
|
|
51
60
|
useEffect(()=>{
|
|
52
61
|
loadMoreData();
|
|
53
62
|
}, []);
|
|
54
63
|
useEffect(()=>{
|
|
55
|
-
const innerEle =
|
|
64
|
+
const innerEle = containerRef.current?.querySelector?.(".rc-virtual-list-holder-inner");
|
|
56
65
|
const handleScroll = (e)=>{
|
|
57
66
|
const ele = e.target;
|
|
58
67
|
const isBottom = ele.scrollHeight - ele.scrollTop <= ele.clientHeight;
|
|
@@ -67,7 +76,7 @@ const InfiniteList = (props)=>{
|
|
|
67
76
|
]);
|
|
68
77
|
return /*#__PURE__*/ jsx(ListContainer, {
|
|
69
78
|
loading: loading,
|
|
70
|
-
ref:
|
|
79
|
+
ref: containerRef,
|
|
71
80
|
children: /*#__PURE__*/ jsx(rc_virtual_list, {
|
|
72
81
|
data: list ?? [],
|
|
73
82
|
itemKey: rowKey,
|
|
@@ -78,46 +87,5 @@ const InfiniteList = (props)=>{
|
|
|
78
87
|
})
|
|
79
88
|
})
|
|
80
89
|
});
|
|
81
|
-
};
|
|
82
|
-
const ListContainer = styled_components(List)`
|
|
83
|
-
&.ant-list {
|
|
84
|
-
height: 100%;
|
|
85
|
-
}
|
|
86
|
-
.ant-spin-nested-loading {
|
|
87
|
-
height: 100%;
|
|
88
|
-
& > div:first-child {
|
|
89
|
-
position: absolute;
|
|
90
|
-
left: 0;
|
|
91
|
-
top: 0;
|
|
92
|
-
height: 100%;
|
|
93
|
-
width: 100%;
|
|
94
|
-
.ant-spin-spinning {
|
|
95
|
-
height: 100%;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
.ant-spin-container {
|
|
100
|
-
height: 100%;
|
|
101
|
-
position: relative;
|
|
102
|
-
|
|
103
|
-
& > div:first-child {
|
|
104
|
-
display: none;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
.rc-virtual-list {
|
|
108
|
-
height: 100%;
|
|
109
|
-
display: block !important;
|
|
110
|
-
}
|
|
111
|
-
.rc-virtual-list-holder {
|
|
112
|
-
height: 100%;
|
|
113
|
-
|
|
114
|
-
& > div {
|
|
115
|
-
height: 100%;
|
|
116
|
-
.rc-virtual-list-holder-inner {
|
|
117
|
-
overflow: auto;
|
|
118
|
-
height: 100%;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
`;
|
|
90
|
+
});
|
|
123
91
|
export { InfiniteList };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ListContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("antd").ListProps<unknown> & {
|
|
2
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
3
|
+
}, never>> & string & Omit<(<T>(props: import("antd").ListProps<T> & {
|
|
4
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
5
|
+
}) => ReturnType<(<T_1>(props: import("antd").ListProps<T_1>, ref: React.ForwardedRef<HTMLDivElement>) => React.ReactElement<unknown, string | React.JSXElementConstructor<any>>)>) & Pick<import("react").FC<{}>, "displayName"> & {
|
|
6
|
+
Item: import("antd/es/list/Item").ListItemTypeProps;
|
|
7
|
+
}, keyof import("react").Component<any, {}, any>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { List } from "antd";
|
|
2
|
+
import { styled } from "styled-components";
|
|
3
|
+
const ListContainer = styled(List)`
|
|
4
|
+
&.ant-list {
|
|
5
|
+
height: 100%;
|
|
6
|
+
}
|
|
7
|
+
.ant-spin-nested-loading {
|
|
8
|
+
height: 100%;
|
|
9
|
+
& > div:first-child {
|
|
10
|
+
position: absolute;
|
|
11
|
+
left: 0;
|
|
12
|
+
top: 0;
|
|
13
|
+
height: 100%;
|
|
14
|
+
width: 100%;
|
|
15
|
+
.ant-spin-spinning {
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
.ant-spin-container {
|
|
21
|
+
height: 100%;
|
|
22
|
+
position: relative;
|
|
23
|
+
|
|
24
|
+
& > div:first-child {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
.rc-virtual-list {
|
|
29
|
+
height: 100%;
|
|
30
|
+
display: block !important;
|
|
31
|
+
}
|
|
32
|
+
.rc-virtual-list-holder {
|
|
33
|
+
height: 100%;
|
|
34
|
+
|
|
35
|
+
& > div {
|
|
36
|
+
height: 100%;
|
|
37
|
+
.rc-virtual-list-holder-inner {
|
|
38
|
+
overflow: auto;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export { ListContainer };
|
|
@@ -2,9 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button, Divider, Input } from "antd";
|
|
3
3
|
import { ChatInputBottom, ChatInputContent, ChatInputPanel } from "./styles.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
|
+
import { StopOutlined, ToTopOutlined } from "@ant-design/icons";
|
|
5
6
|
const ChatSender = (props)=>{
|
|
6
7
|
const { placeholder, value, onChange, onSubmit, extra, disabled, style, className } = props;
|
|
7
|
-
const [
|
|
8
|
+
const [loading, setLoading] = useState(false);
|
|
8
9
|
return /*#__PURE__*/ jsxs(ChatInputPanel, {
|
|
9
10
|
style: style,
|
|
10
11
|
className: className,
|
|
@@ -26,8 +27,12 @@ const ChatSender = (props)=>{
|
|
|
26
27
|
type: "vertical"
|
|
27
28
|
}),
|
|
28
29
|
/*#__PURE__*/ jsx(Button, {
|
|
29
|
-
disabled:
|
|
30
|
+
disabled: loading || disabled,
|
|
31
|
+
loading: loading,
|
|
32
|
+
shape: "circle",
|
|
33
|
+
icon: loading ? /*#__PURE__*/ jsx(StopOutlined, {}) : /*#__PURE__*/ jsx(ToTopOutlined, {}),
|
|
30
34
|
type: "primary",
|
|
35
|
+
variant: "filled",
|
|
31
36
|
onClick: async ()=>{
|
|
32
37
|
setLoading(true);
|
|
33
38
|
try {
|
|
@@ -35,8 +40,7 @@ const ChatSender = (props)=>{
|
|
|
35
40
|
} finally{
|
|
36
41
|
setLoading(false);
|
|
37
42
|
}
|
|
38
|
-
}
|
|
39
|
-
children: "发送"
|
|
43
|
+
}
|
|
40
44
|
})
|
|
41
45
|
]
|
|
42
46
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { EditOutlined, MenuUnfoldOutlined } from "@ant-design/icons";
|
|
4
|
-
import { Button, Divider
|
|
4
|
+
import { Button, Divider } from "antd";
|
|
5
5
|
import { styled } from "styled-components";
|
|
6
6
|
import { useChatClientContext } from "../../context/index.js";
|
|
7
7
|
const Header = (props)=>{
|
|
@@ -19,12 +19,15 @@ const Header = (props)=>{
|
|
|
19
19
|
};
|
|
20
20
|
const HeaderLeft = (props)=>{
|
|
21
21
|
const { onClickNewConversation, onTitleChange } = props;
|
|
22
|
-
const { collapsed, setCollapsed } = useChatClientContext();
|
|
23
|
-
const [open, setOpen] = useState(false);
|
|
22
|
+
const { collapsed, setCollapsed, showUpdateTitleModal } = useChatClientContext();
|
|
24
23
|
const [title, setTitle] = useState(props.defaultTitle);
|
|
25
24
|
const onCollapsed = ()=>{
|
|
26
25
|
setCollapsed(!collapsed);
|
|
27
26
|
};
|
|
27
|
+
const onSubmitTitleChange = async (newTitle)=>{
|
|
28
|
+
await onTitleChange?.(newTitle);
|
|
29
|
+
setTitle(newTitle);
|
|
30
|
+
};
|
|
28
31
|
const showActions = !!collapsed;
|
|
29
32
|
const showTitle = !!title;
|
|
30
33
|
return /*#__PURE__*/ jsxs(Left, {
|
|
@@ -58,7 +61,7 @@ const HeaderLeft = (props)=>{
|
|
|
58
61
|
children: [
|
|
59
62
|
/*#__PURE__*/ jsx(NameText, {
|
|
60
63
|
children: /*#__PURE__*/ jsx(Button, {
|
|
61
|
-
onClick: ()=>
|
|
64
|
+
onClick: ()=>showUpdateTitleModal(title, onSubmitTitleChange),
|
|
62
65
|
size: "small",
|
|
63
66
|
type: "text",
|
|
64
67
|
iconPosition: "end",
|
|
@@ -70,43 +73,10 @@ const HeaderLeft = (props)=>{
|
|
|
70
73
|
children: "内容由 AI 生成"
|
|
71
74
|
})
|
|
72
75
|
]
|
|
73
|
-
}),
|
|
74
|
-
/*#__PURE__*/ jsx(UpdateTitleModal, {
|
|
75
|
-
defaultName: title,
|
|
76
|
-
open: open,
|
|
77
|
-
onClose: ()=>setOpen(false),
|
|
78
|
-
onSubmit: async (value)=>{
|
|
79
|
-
await onTitleChange?.(value);
|
|
80
|
-
setTitle(value);
|
|
81
|
-
}
|
|
82
76
|
})
|
|
83
77
|
]
|
|
84
78
|
});
|
|
85
79
|
};
|
|
86
|
-
const UpdateTitleModal = (props)=>{
|
|
87
|
-
const { defaultName, open, onSubmit, onClose } = props;
|
|
88
|
-
const [name, setName] = useState(defaultName);
|
|
89
|
-
useEffect(()=>{
|
|
90
|
-
if (open) setName(defaultName);
|
|
91
|
-
}, [
|
|
92
|
-
open
|
|
93
|
-
]);
|
|
94
|
-
return /*#__PURE__*/ jsx(Modal, {
|
|
95
|
-
title: "编辑对话名称",
|
|
96
|
-
open: open,
|
|
97
|
-
okText: "确定",
|
|
98
|
-
cancelText: "取消",
|
|
99
|
-
onCancel: ()=>onClose?.(),
|
|
100
|
-
onOk: async ()=>{
|
|
101
|
-
await onSubmit?.(name);
|
|
102
|
-
onClose?.();
|
|
103
|
-
},
|
|
104
|
-
children: /*#__PURE__*/ jsx(Input, {
|
|
105
|
-
value: name,
|
|
106
|
-
onChange: (e)=>setName(e.target.value)
|
|
107
|
-
})
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
80
|
const ActionContainer = styled.div`
|
|
111
81
|
display: flex;
|
|
112
82
|
align-items: center;
|
|
@@ -2,8 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Spin } from "antd";
|
|
3
3
|
import { Footer } from "./Footer.js";
|
|
4
4
|
import { Header } from "./Header.js";
|
|
5
|
-
import { Container } from "./styles.js";
|
|
6
5
|
import { Content } from "./Content.js";
|
|
6
|
+
import { Container } from "./styles.js";
|
|
7
7
|
const ClientContent = (props)=>{
|
|
8
8
|
const { style, className, children, headerProps, footerProps, loading } = props;
|
|
9
9
|
if (loading) return /*#__PURE__*/ jsx(Container, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { InfiniteListProps
|
|
1
|
+
import { InfiniteListProps } from "../../../../components/InfiniteList";
|
|
2
2
|
export interface HistoryConversationProps<T = any> {
|
|
3
3
|
rowKey?: string;
|
|
4
4
|
request: InfiniteListProps<T>['request'];
|
|
5
5
|
activeKey?: string;
|
|
6
|
-
onDelete?: (key: string, item: T
|
|
7
|
-
onRename?: (key: string, item: T
|
|
6
|
+
onDelete?: (key: string, item: T) => Promise<void>;
|
|
7
|
+
onRename?: (key: string, item: T) => Promise<void>;
|
|
8
8
|
onSelect?: (key: string, item: T) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const HistoryConversation: <T extends ItemData = any>(props: HistoryConversationProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,16 +4,17 @@ import { Avatar, Button, Dropdown, Tooltip, Typography } from "antd";
|
|
|
4
4
|
import { useHover } from "ahooks";
|
|
5
5
|
import { ClockCircleOutlined, MessageOutlined, MoreOutlined } from "@ant-design/icons";
|
|
6
6
|
import { InfiniteList } from "../../../../components/InfiniteList/index.js";
|
|
7
|
+
import { useChatClientContext } from "../../context/index.js";
|
|
7
8
|
import { HeaderContainer, HeaderTitle, HistoryConversationContainer, ListContainer, ListItemContainer, ListText } from "./styles.js";
|
|
8
9
|
const HistoryConversation = (props)=>{
|
|
9
|
-
const {
|
|
10
|
-
const
|
|
10
|
+
const { rowKey = "id", request, activeKey, onDelete, onRename, onSelect } = props;
|
|
11
|
+
const { showUpdateTitleModal, conversationListRef } = useChatClientContext();
|
|
11
12
|
return /*#__PURE__*/ jsxs(HistoryConversationContainer, {
|
|
12
|
-
ref: ref,
|
|
13
13
|
children: [
|
|
14
14
|
/*#__PURE__*/ jsx(Header, {}),
|
|
15
15
|
/*#__PURE__*/ jsx(ListContainer, {
|
|
16
16
|
children: /*#__PURE__*/ jsx(InfiniteList, {
|
|
17
|
+
ref: conversationListRef,
|
|
17
18
|
request: request,
|
|
18
19
|
rowKey: rowKey,
|
|
19
20
|
pageSize: 10,
|
|
@@ -23,13 +24,25 @@ const HistoryConversation = (props)=>{
|
|
|
23
24
|
{
|
|
24
25
|
key: 'rename',
|
|
25
26
|
label: '重命名',
|
|
26
|
-
onClick: ()=>
|
|
27
|
+
onClick: ()=>{
|
|
28
|
+
showUpdateTitleModal(item.title, async (newTitle)=>{
|
|
29
|
+
const newItem = {
|
|
30
|
+
...item,
|
|
31
|
+
title: newTitle
|
|
32
|
+
};
|
|
33
|
+
await onRename?.(key, newItem);
|
|
34
|
+
actions.updateItem(key, newItem);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
27
37
|
},
|
|
28
38
|
{
|
|
29
39
|
key: 'delete',
|
|
30
40
|
danger: true,
|
|
31
41
|
label: '删除',
|
|
32
|
-
onClick: ()=>
|
|
42
|
+
onClick: async ()=>{
|
|
43
|
+
await onDelete?.(key, item);
|
|
44
|
+
actions.deleteItem(key);
|
|
45
|
+
}
|
|
33
46
|
}
|
|
34
47
|
];
|
|
35
48
|
return /*#__PURE__*/ jsxs(ListItemContainer, {
|
|
@@ -8,7 +8,7 @@ export interface ChatPageProps<T = any> {
|
|
|
8
8
|
onClickConversation?: (key: string, item: T) => void;
|
|
9
9
|
onClickNewConversation?: () => void;
|
|
10
10
|
onClickMoreAgent?: () => void;
|
|
11
|
-
onRenameConversation?: (key: string, item: T
|
|
12
|
-
onDeleteConversation?: (key: string, item: T
|
|
11
|
+
onRenameConversation?: (key: string, item: T) => Promise<void>;
|
|
12
|
+
onDeleteConversation?: (key: string, item: T) => Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export declare const ChatPage: (props: ChatPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { InfiniteListRef, RenderActions } from "../../../components/InfiniteList";
|
|
3
|
+
export interface ChatClientContextProps<ConversationItemData = any> {
|
|
3
4
|
collapsed: boolean;
|
|
4
5
|
setCollapsed: (collapsed: boolean) => void;
|
|
6
|
+
showUpdateTitleModal: (title: string, onSubmit?: (title: string) => any) => void;
|
|
7
|
+
conversationListRef: InfiniteListRef<ConversationItemData>;
|
|
8
|
+
conversationAction: Partial<RenderActions<ConversationItemData>>;
|
|
5
9
|
}
|
|
6
10
|
export interface ChatClientProviderProps {
|
|
7
11
|
children: ReactNode;
|
|
8
12
|
}
|
|
9
|
-
export declare const ChatClientContext: import("react").Context<ChatClientContextProps
|
|
13
|
+
export declare const ChatClientContext: import("react").Context<ChatClientContextProps<any>>;
|
|
10
14
|
export declare const ChatClientProvider: (props: ChatClientProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export declare function useChatClientContext(): ChatClientContextProps
|
|
15
|
+
export declare function useChatClientContext(): ChatClientContextProps<any>;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { useUpdateTitleModal } from "./useUpdateTitleModal.js";
|
|
4
|
+
import { useConversationListRef } from "./useConversationListRef.js";
|
|
3
5
|
const ChatClientContext = /*#__PURE__*/ createContext({});
|
|
4
6
|
const ChatClientProvider = (props)=>{
|
|
5
7
|
const { children } = props;
|
|
8
|
+
const { updateTitleModalEle, showUpdateTitleModal } = useUpdateTitleModal();
|
|
6
9
|
const [collapsed, setCollapsed] = useState(false);
|
|
7
|
-
|
|
10
|
+
const { conversationListRef, ...conversationActions } = useConversationListRef();
|
|
11
|
+
return /*#__PURE__*/ jsxs(ChatClientContext.Provider, {
|
|
8
12
|
value: {
|
|
9
13
|
collapsed,
|
|
10
|
-
setCollapsed
|
|
14
|
+
setCollapsed,
|
|
15
|
+
showUpdateTitleModal,
|
|
16
|
+
conversationListRef,
|
|
17
|
+
conversationAction: conversationActions
|
|
11
18
|
},
|
|
12
|
-
children:
|
|
19
|
+
children: [
|
|
20
|
+
children,
|
|
21
|
+
updateTitleModalEle
|
|
22
|
+
]
|
|
13
23
|
});
|
|
14
24
|
};
|
|
15
25
|
function useChatClientContext() {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderActions } from "../../../components/InfiniteList";
|
|
2
|
+
export declare function useConversationListRef<DataType = any>(): {
|
|
3
|
+
updateItem?: ((key: string, item: DataType) => void) | undefined;
|
|
4
|
+
deleteItem?: ((key: string) => void) | undefined;
|
|
5
|
+
resetPagination?: (() => void) | undefined;
|
|
6
|
+
conversationListRef: import("react").RefObject<RenderActions<DataType> | null>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input, Modal } from "antd";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
function useUpdateTitleModal() {
|
|
5
|
+
const [open, setOpen] = useState(false);
|
|
6
|
+
const [title, setTitle] = useState("");
|
|
7
|
+
const callbackRef = useRef((title)=>{});
|
|
8
|
+
const updateTitleModalEle = /*#__PURE__*/ jsx(Modal, {
|
|
9
|
+
title: "编辑对话名称",
|
|
10
|
+
open: open,
|
|
11
|
+
okText: "确定",
|
|
12
|
+
cancelText: "取消",
|
|
13
|
+
onCancel: ()=>setOpen(false),
|
|
14
|
+
onOk: async ()=>{
|
|
15
|
+
await callbackRef.current(title);
|
|
16
|
+
setOpen(false);
|
|
17
|
+
},
|
|
18
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
19
|
+
value: title,
|
|
20
|
+
onChange: (e)=>setTitle(e.target.value)
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
const showUpdateTitleModal = (title, onSubmit)=>{
|
|
24
|
+
setTitle(title);
|
|
25
|
+
setOpen(true);
|
|
26
|
+
callbackRef.current = onSubmit || (()=>{});
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
updateTitleModalEle,
|
|
30
|
+
showUpdateTitleModal
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export { useUpdateTitleModal };
|