feat(sandbox): use extension field for file icon type mapping

Enhance getFileIconType to accept an extension parameter and cover all
13 FileAppearanceTypeEnum types using an O(1) Map lookup. Update all
call sites to pass the API-provided extension for accurate icon display.
This commit is contained in:
yyh
2026-01-27 16:21:03 +08:00
parent 85ecf1a198
commit ab52550abe
10 changed files with 41 additions and 16 deletions

View File

@ -24,7 +24,7 @@ const FilePickerTreeNode: FC<FilePickerTreeNodeProps> = ({ node, style, dragHand
const { t } = useTranslation('workflow')
const isFolder = node.data.node_type === 'folder'
const isSelected = node.isSelected
const fileIconType = !isFolder ? getFileIconType(node.data.name) : null
const fileIconType = !isFolder ? getFileIconType(node.data.name, node.data.extension) : null
const handleClick = useCallback((e: React.MouseEvent) => {
e.stopPropagation()

View File

@ -33,7 +33,7 @@ const FileReferenceBlock: FC<FileReferenceBlockProps> = ({ nodeKey, resourceId }
const currentNode = useMemo(() => nodeMap?.get(resourceId), [nodeMap, resourceId])
const isFolder = currentNode?.node_type === 'folder'
const displayName = currentNode?.name ?? resourceId
const iconType = !isFolder && currentNode ? getFileIconType(currentNode.name) : null
const iconType = !isFolder && currentNode ? getFileIconType(currentNode.name, currentNode.extension) : null
const title = currentNode?.path ?? displayName
const handleSelect = useCallback((node: TreeNodeData) => {