<template>
  <div class="ant-upload-list ant-upload-list-text">
    <div class="ant-upload-list-text-container">
      <div class="ant-upload-list-item ant-upload-list-item-done ant-upload-list-item-list-type-text" v-if="getFilePath()">
        <div class="ant-upload-list-item-info">
          <span class="ant-upload-span">
            <div class="ant-upload-text-icon">
              <Icon icon="ant-design:paper-clip-outlined"/>
            </div>
            <a target="_blank" rel="noopener noreferrer" class="ant-upload-list-item-name" :title="getFileName()" :href="getFilePath()">{{ getFileName() }}</a>
          </span>
        </div>
        <div class="ant-upload-list-item-progress" style="display: none;"></div>
      </div>
      <a-empty v-else/>
    </div>
  </div>

</template>
<script lang="ts" name="jiaoXueDanYuanNeiRongIndexDownload" setup>
  import { getFileAccessHttpUrl } from '/@/utils/common/compUtils'
  const props = defineProps({
    filePath: { type: String },
    fileName: { type: String },
  });

  function getFileName(){
    if(props.fileName){
      return props.fileName;
    }else{
      if(!props.filePath) return '';
      let pathList = props.filePath?.replaceAll('\\','/').split('/');
      if(pathList.length){
        return pathList[pathList.length-1] || '';
      }
      return '';
    }
  }

  function getFilePath(){
    if(!props.filePath) return null;
    return getFileAccessHttpUrl(props.filePath);
  }
</script>