<template>
  <div class="publish-work-container">
    <!-- 类别切换按钮 -->
    <div class="upload-type-selector">
      <el-button-group>
        <el-button 
          :type="activeTab === 'video' ? 'primary' : 'default'"
          @click="switchTab('video')"
          class="upload-type-btn"
        >
          视频上传
        </el-button>
        <el-button 
          :type="activeTab === 'workflow' ? 'primary' : 'default'"
          @click="switchTab('workflow')"
          class="upload-type-btn"
        >
          工作流上传
        </el-button>
        <el-button 
          :type="activeTab === 'course' ? 'primary' : 'default'"
          @click="switchTab('course')"
          class="upload-type-btn"
        >
          课程上传
        </el-button>
      </el-button-group>
    </div>
    
    <!-- 内容区域 -->
    <div class="content-area">
      <div v-if="activeTab === 'video'">
        <video-upload-component :active-tab-prop="activeTab" @switch-tab="switchTab" />
      </div>
      <div v-else-if="activeTab === 'workflow'">
        <workflow-upload-component />
      </div>
      <div v-else-if="activeTab === 'course'">
        <course-upload-component @switch-tab="switchTab" />
      </div>
    </div>
  </div>
</template>

<script>
import { defineComponent, ref } from 'vue'
import VideoUploadComponent from './upload/VideoUploadComponent.vue'
import WorkflowUploadComponent from './upload/WorkflowUploadComponent.vue'
import CourseUploadComponent from './upload/CourseUploadComponent.vue'

export default defineComponent({
  name: 'PublishWork',
  components: {
    VideoUploadComponent,
    WorkflowUploadComponent,
    CourseUploadComponent
  },
  setup() {
    const activeTab = ref('video')
    
    // 切换标签页
    const switchTab = (tab) => {
      activeTab.value = tab
    }

    return {
      activeTab,
      switchTab
    }
  }
})
</script>

<style scoped>
.publish-work-container {
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.upload-type-selector {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
  background: #f8f9fa;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

:deep(.upload-type-btn) {
  min-width: 120px !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  padding: 10px 24px !important;
  border-radius: 8px !important;
  border: none !important;
  background: transparent !important;
  color: #666 !important;
  transition: all 0.3s ease !important;
  margin: 0 !important;
}

:deep(.upload-type-btn:hover) {
  background: #fff !important;
  color: #333 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

:deep(.upload-type-btn.el-button--primary) {
  background: #333 !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  border-color: #333 !important;
}

:deep(.upload-type-btn.el-button--primary:hover) {
  background: #222 !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  border-color: #222 !important;
}

.content-area {
  margin-top: 20px;
}
</style>
