<template>
  <section class="code-preview">
    <div class="preview-head">
      <span>{{ fileName || '代码预览' }}</span>
    </div>
    <el-empty v-if="!code" description="请选择左侧文件查看代码" />
    <pre v-else><code>{{ code }}</code></pre>
  </section>
</template>

<script setup>
defineProps({
  fileName: {
    type: String,
    default: ''
  },
  code: {
    type: String,
    default: ''
  }
})
</script>

<style scoped lang="scss">
.code-preview {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 560px;
  border-left: 1px solid #e3e8f0;
  background: #0f172a;
}

.preview-head {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid #243044;
  color: #dbe4f0;
  font-weight: 700;
}

pre {
  min-width: 0;
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #d8dee9;
  font-size: 13px;
  line-height: 1.7;
}

:deep(.el-empty__description p) {
  color: #cbd5e1;
}
</style>
