<template>
  <div class="course-card list_item_animation box_shadow_card" >
    <div class="bg_color_f5 coverImg" @click.stop.prevent="goWorkflowDetail">
      <img :src="info.coverImage" alt="" class="coverImg" />
    </div>
    <div class="course-card-bottom-height"></div>
    <div class="padding16 course-card-bottom">
      <div class="gap10">
        <img :src="riliIcon" alt="" style="width: 16px; height: 16px;">
        <div class="font_size13">{{info.createTime || ''}}</div>
      </div>
      <div style="min-height: 82px;" @click.stop.prevent="goWorkflowDetail">
        <div class="line2 font_size18 line_height26 bold mt10">
          {{info.workflowTitle || ''}}
        </div>
        <div class="mt10 line1 gray font_size13">
          {{info.description || ''}}
        </div>
      </div>
      <div class="mt10 flex-center-between">
        <div class="gap10">
          <el-avatar :size="24" :src="info.userAvatar || appStore.avatarDefault" />
          <div class="font_size14">{{info.nickName || ''}}</div>
        </div>
        <div class="gap10 contactInfo_bg border_radius_4">
          <img :src="yunIcon" alt="" style="width: 16px; height: 16px;" />
          <div class="font_size13">{{info.categoryName1}} {{$t('common.platform')}}</div>
        </div>
      </div>
      <div class="gap10 mt16 button-container">
        <el-button type="primary" class="flex_1" size="large" style="background: #EAF1FF;border-color: #EAF1FF;color: #2D71FF;" @click.stop.prevent="goWorkflowDetail">
          <el-icon class="mr10"><Document /></el-icon>
          {{$t('common.viewDetails')}}
        </el-button>
        <el-button type="primary" class="flex_1 gradient" size="large" @click.stop.prevent="startUsing">
          <el-icon class="mr10"><VideoPlay /></el-icon>
          {{$t('common.startUsing')}}
        </el-button>
      </div>
    </div>
    <!-- <div class="flex-center-between">
      <img :src="n8Icon" alt="" style="width: 50px; height: 50px;" class="mr10">
      <div class="line2 font_size18 line_height22 font_weight400">
        【Linux】【操作】Linux操作集锦系列之十五——如何破解pdf如何破解pdf如何破解pdf如何破解pdf如何破解pdf
      </div>
    </div>
    <div class="mt16 gap10">
      <img :src="yunIcon" alt="" style="width: 16px; height: 16px;">
      <div class="font_size13">n8n平台</div>
      <img :src="riliIcon" alt="" style="width: 16px; height: 16px;">
      <div class="font_size13">2023-10-15</div>
    </div>
    <div class="mt16 line3 gray font_size13">
      - 本文介绍两款开源的密码破解工具John the Ripper和PDFCrack，用于破解PDF、Word、Excel、ZIP、RAR等文件的密码。John the Ripper支持字典和暴力破解两种模
    </div>
    <div class="gap10 mt16">
      <el-button type="primary" class="flex_1" size="large" plain>
        <el-icon class="mr10"><Document /></el-icon>
        查看详情
      </el-button>
      <el-button type="primary" class="flex_1 gradient" size="large">
        <el-icon class="mr10"><VideoPlay /></el-icon>
        开始使用
      </el-button>
    </div> -->
  </div>
</template>
<script setup>
import n8Icon from '@/assets/imgs/8n8.png'
import yunIcon from '@/assets/imgs/yun.png'
import riliIcon from '@/assets/imgs/rili.png'
import { useAppStore } from '@/pinia/appStore'
import { inject } from 'vue'
import { isLogin, openNewTab } from '@/utils/util.js'
import { useI18n } from 'vue-i18n' 
const { t } = useI18n()

const appStore = useAppStore();
import { useRouter } from 'vue-router'
const router = useRouter()


const props = defineProps({
  info: {
    type: Object,
    default: () => ({})
  },
  fromPage: {
    type: String,
    default: () => ''
  }
});
const goWorkflowDetail = () => {
  //判断是否登录
  if(!isLogin({callback: openLoginDialog,t})){
    return;
  }
  let path = `/search-platform/workflow-detail`
  if(props.fromPage === 'home'){
    path = `/workflow-detail`
  }
  //增加参数名称
  router.push({
    path: path,
    query: {
      publishId:props.info.publishId,
      metaTitle: 'route.WorkflowDetail'
    }
  })
};
const openLoginDialog = inject('openLoginDialog')
const startUsing = () => {
  //判断是否登录
  if(!isLogin({callback: openLoginDialog,t})){
    return;
  }
  openNewTab(props.info.categoryUrl);
};
</script>

<style scoped lang="scss">
.course-card {
  width: 345px;
  border: 1px solid #ffffff;
  // background-color: rgba(255, 255, 255, 0.5);
  background-color: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative; // 添加相对定位
  // transition: transform 0.3s;
  
  // &:hover {
    // transform: translateY(-5px);
    // box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  // }
  .line2{
    //hover 显示下划线
    text-decoration: none;
    &:hover{
      text-decoration: underline;
    }
  }
  .coverImg{
    width: 100%;
    height: 204px;
  }
  .course-card-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px;
    background: rgba(255, 255, 255, 0.9); // 确保背景色
    transform: translateY(60px); // 初始完全在下方隐藏
    transition: transform 0.3s ease;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    //高斯模糊
    // filter: blur(0px);
  }
  
  &:hover {
    .course-card-bottom {
      transform: translateY(0); // 悬浮时上移显示
    }
  }
  .course-card-bottom-height{
    height: 175.6px;
  }
}
</style>
