mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 01:18:05 +08:00
fix: Enhance data source handling by adding error response type and updating local file and online document slices
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import type { FileItem } from '@/models/datasets'
|
||||
import type { DocumentItem, FileItem } from '@/models/datasets'
|
||||
|
||||
export type LocalFileSliceShape = {
|
||||
localFileList: FileItem[]
|
||||
setLocalFileList: (fileList: FileItem[]) => void
|
||||
currentLocalFile: File | undefined
|
||||
setCurrentLocalFile: (file: File | undefined) => void
|
||||
previewLocalFileRef: React.MutableRefObject<DocumentItem | undefined>
|
||||
}
|
||||
|
||||
export const createLocalFileSlice: StateCreator<LocalFileSliceShape> = (set) => {
|
||||
@ -18,5 +19,6 @@ export const createLocalFileSlice: StateCreator<LocalFileSliceShape> = (set) =>
|
||||
setCurrentLocalFile: (file: File | undefined) => set(() => ({
|
||||
currentLocalFile: file,
|
||||
})),
|
||||
previewLocalFileRef: { current: undefined },
|
||||
})
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ export type OnlineDocumentSliceShape = {
|
||||
setSelectedPagesId: (selectedPagesId: Set<string>) => void
|
||||
}
|
||||
|
||||
export const createOnlineDocumentSlice: StateCreator<OnlineDocumentSliceShape> = (set, get) => {
|
||||
export const createOnlineDocumentSlice: StateCreator<OnlineDocumentSliceShape> = (set) => {
|
||||
return ({
|
||||
documentData: [],
|
||||
setDocumentData: (documentData: DataSourceNotionWorkspace[]) => set(() => ({
|
||||
@ -38,7 +38,7 @@ export const createOnlineDocumentSlice: StateCreator<OnlineDocumentSliceShape> =
|
||||
setCurrentDocument: (document: NotionPage | undefined) => set(() => ({
|
||||
currentDocument: document,
|
||||
})),
|
||||
selectedPagesId: new Set([...get().onlineDocuments.map(doc => doc.page_id)]),
|
||||
selectedPagesId: new Set(),
|
||||
setSelectedPagesId: (selectedPagesId: Set<string>) => set(() => ({
|
||||
selectedPagesId,
|
||||
})),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import { type OnlineDriveFile, OnlineDriveFileType } from '@/models/pipeline'
|
||||
import type { OnlineDriveFile } from '@/models/pipeline'
|
||||
|
||||
export type OnlineDriveSliceShape = {
|
||||
prefix: string[]
|
||||
@ -32,11 +32,7 @@ export const createOnlineDriveSlice: StateCreator<OnlineDriveSliceShape> = (set)
|
||||
setSelectedFileList: (selectedFileList: string[]) => set(() => ({
|
||||
selectedFileList,
|
||||
})),
|
||||
fileList: [{
|
||||
key: 'Bucket_1',
|
||||
size: 1024, // unit bytes
|
||||
type: OnlineDriveFileType.bucket,
|
||||
}],
|
||||
fileList: [],
|
||||
setFileList: (fileList: OnlineDriveFile[]) => set(() => ({
|
||||
fileList,
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user