mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 22:14:50 +00:00
feat(webui): add chatbot layout and drag-drop context store
This commit is contained in:
@@ -9,6 +9,7 @@ import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import type { DragEndEvent, DragStartEvent } from '@dnd-kit/react'
|
||||
import type { DragState } from './dnd-types'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
|
||||
interface UseFileSystemDndProps {
|
||||
teamId: string
|
||||
@@ -188,6 +189,24 @@ export function useFileSystemDnd({
|
||||
const targetId = (target.id as string).split(':').pop()!
|
||||
const targetData = target.data as { type: string; item: AssetInfo } | undefined
|
||||
|
||||
if (targetData?.type === 'chatbot-sidebar') {
|
||||
const draggedItems = [...folders, ...files].filter((item) =>
|
||||
dragState.draggedIds.has(item.id!),
|
||||
)
|
||||
|
||||
const chatAssets = draggedItems.map((item) => ({
|
||||
id: item.id!,
|
||||
name: item.name || 'Unnamed',
|
||||
type: item.type as 'file' | 'folder',
|
||||
}))
|
||||
|
||||
useChatbotStore.getState().addAssets(chatAssets)
|
||||
toast.success(`Added ${chatAssets.length} item(s) to chatbot context`)
|
||||
onClearSelection()
|
||||
setDragState(undefined)
|
||||
return
|
||||
}
|
||||
|
||||
if (targetData?.type === 'share-link') {
|
||||
const shareId = targetId
|
||||
const assetIds = Array.from(dragState.draggedIds)
|
||||
|
||||
Reference in New Issue
Block a user