header.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="detail-header">
  3. <div class="header-left">
  4. <el-button type="primary" plain icon="Back" @click="handleBack" size="small">{{ t('project.management.detail.header.backToList') }}</el-button>
  5. <el-divider direction="vertical" />
  6. <span class="project-title">{{ projectName || 'Loading...' }}</span>
  7. </div>
  8. </div>
  9. </template>
  10. <script setup lang="ts">
  11. import { inject } from 'vue';
  12. import { useI18n } from 'vue-i18n';
  13. const { t } = useI18n();
  14. // Props
  15. defineProps<{
  16. projectId?: string | number | null;
  17. projectName?: string;
  18. }>();
  19. // Emit
  20. const emit = defineEmits<{
  21. back: [];
  22. }>();
  23. // 接收切换组件的方法
  24. const switchComponent = inject<any>('switchComponent');
  25. const ListComponent = inject<any>('ListComponent');
  26. // 返回列表
  27. const handleBack = () => {
  28. if (switchComponent && ListComponent) {
  29. switchComponent(ListComponent);
  30. }
  31. emit('back');
  32. }
  33. </script>
  34. <style scoped>
  35. /* Header 样式 */
  36. .detail-header {
  37. width: 100%;
  38. height: 60px;
  39. background-color: #ffffff;
  40. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  41. display: flex;
  42. align-items: center;
  43. padding: 0 24px;
  44. z-index: 10;
  45. }
  46. .header-left {
  47. display: flex;
  48. align-items: center;
  49. gap: 12px;
  50. }
  51. .project-title {
  52. font-size: 16px;
  53. font-weight: 600;
  54. color: #303133;
  55. }
  56. </style>