<template>
  <div class="detail-header">
    <div class="header-left">
      <el-button type="primary" plain icon="Back" @click="handleBack" size="small">{{ t('project.management.detail.header.backToList') }}</el-button>
      <el-divider direction="vertical" />
      <span class="project-title">{{ projectName || 'Loading...' }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { inject } from 'vue';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

// Props
defineProps<{
  projectId?: string | number | null;
  projectName?: string;
}>();

// Emit
const emit = defineEmits<{
  back: [];
}>();

// 接收切换组件的方法
const switchComponent = inject<any>('switchComponent');
const ListComponent = inject<any>('ListComponent');

// 返回列表
const handleBack = () => {
  if (switchComponent && ListComponent) {
    switchComponent(ListComponent);
  }
  emit('back');
}
</script>

<style scoped>
/* Header 样式 */
.detail-header {
  width: 100%;
  height: 60px;
  background-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
}
</style>
