mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 08:28:03 +08:00
feat: add db types in file tree icon
This commit is contained in:
@ -4,6 +4,7 @@ import {
|
||||
getFileExtension,
|
||||
isImageFile,
|
||||
isMarkdownFile,
|
||||
isSQLiteFile,
|
||||
isTextLikeFile,
|
||||
isVideoFile,
|
||||
} from '../utils/file-utils'
|
||||
@ -13,6 +14,7 @@ export type FileTypeInfo = {
|
||||
isCodeOrText: boolean
|
||||
isImage: boolean
|
||||
isVideo: boolean
|
||||
isSQLite: boolean
|
||||
isEditable: boolean
|
||||
isMediaFile: boolean
|
||||
}
|
||||
@ -23,6 +25,7 @@ export function useFileTypeInfo(fileNode: AppAssetTreeView | undefined): FileTyp
|
||||
const markdown = isMarkdownFile(ext)
|
||||
const image = isImageFile(ext)
|
||||
const video = isVideoFile(ext)
|
||||
const sqlite = isSQLiteFile(ext)
|
||||
const editable = isTextLikeFile(ext)
|
||||
const codeOrText = editable && !markdown
|
||||
|
||||
@ -31,6 +34,7 @@ export function useFileTypeInfo(fileNode: AppAssetTreeView | undefined): FileTyp
|
||||
isCodeOrText: codeOrText,
|
||||
isImage: image,
|
||||
isVideo: video,
|
||||
isSQLite: sqlite,
|
||||
isEditable: editable,
|
||||
isMediaFile: image || video,
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ const MARKDOWN_EXTENSIONS = ['md', 'markdown', 'mdx']
|
||||
const CODE_EXTENSIONS = ['json', 'yaml', 'yml', 'toml', 'js', 'jsx', 'ts', 'tsx', 'py', 'schema']
|
||||
const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'bmp', 'ico', 'tiff', 'psd', 'heic', 'heif', 'avif']
|
||||
const VIDEO_EXTENSIONS = ['mp4', 'mov', 'webm', 'mpeg', 'mpg', 'm4v', 'avi', 'mkv', 'flv', 'wmv', '3gp']
|
||||
const SQLITE_EXTENSIONS = ['db', 'sqlite', 'sqlite3']
|
||||
|
||||
const BINARY_EXTENSIONS = [
|
||||
'mp3',
|
||||
@ -94,6 +95,9 @@ export function getFileIconType(name: string): FileAppearanceTypeEnum {
|
||||
if (CODE_EXTENSIONS.includes(extension))
|
||||
return FileAppearanceTypeEnum.code
|
||||
|
||||
if (SQLITE_EXTENSIONS.includes(extension))
|
||||
return FileAppearanceTypeEnum.database
|
||||
|
||||
return FileAppearanceTypeEnum.document
|
||||
}
|
||||
|
||||
@ -117,6 +121,10 @@ export function isVideoFile(extension: string): boolean {
|
||||
return VIDEO_EXTENSIONS.includes(extension)
|
||||
}
|
||||
|
||||
export function isSQLiteFile(extension: string): boolean {
|
||||
return SQLITE_EXTENSIONS.includes(extension)
|
||||
}
|
||||
|
||||
export function getFileLanguage(name: string): string {
|
||||
const extension = name.split('.').pop()?.toLowerCase() ?? ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user