mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
add
This commit is contained in:
parent
1d04796ca0
commit
ae518a2f36
@ -5,6 +5,7 @@ import {
|
|||||||
Droppable,
|
Droppable,
|
||||||
Draggable,
|
Draggable,
|
||||||
OnDragEndResponder,
|
OnDragEndResponder,
|
||||||
|
DraggableProvided,
|
||||||
} from "@hello-pangea/dnd";
|
} from "@hello-pangea/dnd";
|
||||||
|
|
||||||
import { useChatStore } from "../store";
|
import { useChatStore } from "../store";
|
||||||
@ -32,7 +33,7 @@ export function ChatItem(props: {
|
|||||||
index: number;
|
index: number;
|
||||||
narrow?: boolean;
|
narrow?: boolean;
|
||||||
mask: Mask;
|
mask: Mask;
|
||||||
provided;
|
provided: DraggableProvided;
|
||||||
}) {
|
}) {
|
||||||
const draggableRef = useRef<HTMLDivElement | null>(null);
|
const draggableRef = useRef<HTMLDivElement | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -108,7 +109,6 @@ export function ChatList(props: { narrow?: boolean }) {
|
|||||||
const chatStore = useChatStore();
|
const chatStore = useChatStore();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isMobileScreen = useMobileScreen();
|
const isMobileScreen = useMobileScreen();
|
||||||
|
|
||||||
const onDragEnd: OnDragEndResponder = (result) => {
|
const onDragEnd: OnDragEndResponder = (result) => {
|
||||||
const { destination, source } = result;
|
const { destination, source } = result;
|
||||||
if (!destination) {
|
if (!destination) {
|
||||||
@ -125,6 +125,30 @@ export function ChatList(props: { narrow?: boolean }) {
|
|||||||
moveSession(source.index, destination.index);
|
moveSession(source.index, destination.index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onAdd = () => {
|
||||||
|
const { data } = this.state;
|
||||||
|
const i = Math.floor(Math.random() * this.data.length);
|
||||||
|
data.unshift({
|
||||||
|
key: Date.now(),
|
||||||
|
name: this.data[i].name,
|
||||||
|
age: this.data[i].age,
|
||||||
|
address: this.data[i].address,
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
data,
|
||||||
|
isPageTween: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDelete = (
|
||||||
|
key: number,
|
||||||
|
e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
|
||||||
|
) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const data = this.state.data.filter((item) => item.key !== key);
|
||||||
|
this.setState({ data, isPageTween: false });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DragDropContext onDragEnd={onDragEnd}>
|
<DragDropContext onDragEnd={onDragEnd}>
|
||||||
<Droppable
|
<Droppable
|
||||||
@ -174,6 +198,7 @@ export function ChatList(props: { narrow?: boolean }) {
|
|||||||
]}
|
]}
|
||||||
key={sessions.length}
|
key={sessions.length}
|
||||||
// interval={150}
|
// interval={150}
|
||||||
|
// TODO: 目前有一个问题,下面是遍历的所以每次元素变动都会重新全部渲染
|
||||||
>
|
>
|
||||||
{sessions.map((item, i) => (
|
{sessions.map((item, i) => (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
|
Loading…
Reference in New Issue
Block a user