import { ScrollView, View, Image } from "@tarojs/components";
import IconFileLink from "@/components/icon/IconFileLink";
import IconFileTxt from "@/components/icon/IconFileDOC";
import IconFilePDF from "@/components/icon/IconFilePDF";
import IconFileXLSX from "@/components/icon/IconFileXLSX";
import { TKnowledgeItem } from "@/types/knowledge";
export interface IProps {
  data?: TKnowledgeItem | null
}
const KnowledgeIcon = ({data}:IProps) => {
  if(!data){
    return <></>
  }

  // todo: 更多类型
  const renderIcon = ()=> {
    const type = data.type
    if(type === 'image'){
      return <Image src={data.picUrl || data.icon} mode="widthFix" style={{width: '36px', height: '36px'}}></Image>
    }
    if(type === 'text'){
      return <IconFileTxt/>
    }
    if(type === 'web'){
      return <IconFileLink/>
    }
    if(type === 'video'){
      return <IconFileLink/>
    }

    // 默认使用 doc 
    return <IconFileTxt />

  }

  return <View className="w-36 h-36 overflow-hidden">
    {renderIcon()}
  </View>
}

export default KnowledgeIcon
