<template>
  <div class="about-page">
    <div class="page-header">
      <div class="page-title-group">
        <h1 class="page-title">关于</h1>
        <span class="page-subtitle">系统信息与说明</span>
      </div>
    </div>

    <div class="about-card">
      <div v-if="loading" class="about-loading">
        <div class="spin-ring"></div>
      </div>
      <div v-else-if="content" class="markdown-body" v-html="renderedContent"></div>
      <div v-else class="about-empty">暂无内容</div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { marked } from 'marked'
import request from '../utils/request'

const content = ref('')
const loading = ref(true)

const renderedContent = computed(() => {
  if (!content.value) return ''
  return marked.parse(content.value)
})

onMounted(async () => {
  try {
    const { data } = await request.get('/settings/about')
    content.value = data.content || ''
  } catch {}
  loading.value = false
})
</script>

<style scoped>
.about-page {
  padding: 24px 28px;
  max-width: 1100px;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 28px 32px;
  min-height: 200px;
}

.about-loading {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.spin-ring {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.about-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 0;
}

/* Markdown 渲染样式 */
.markdown-body {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.8;
}

.markdown-body :deep(h1),
.markdown-body :deep(h2),
.markdown-body :deep(h3),
.markdown-body :deep(h4) {
  color: var(--text-primary);
  font-weight: 600;
  margin: 1.4em 0 0.6em;
  line-height: 1.4;
}

.markdown-body :deep(h1) { font-size: 1.5em; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.3em; }
.markdown-body :deep(h2) { font-size: 1.25em; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.2em; }
.markdown-body :deep(h3) { font-size: 1.1em; }

.markdown-body :deep(p) { margin: 0.8em 0; }

.markdown-body :deep(a) {
  color: var(--accent);
  text-decoration: none;
}
.markdown-body :deep(a:hover) { text-decoration: underline; }

.markdown-body :deep(code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
}

.markdown-body :deep(pre) {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1em 0;
}

.markdown-body :deep(pre code) {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
}

.markdown-body :deep(ul),
.markdown-body :deep(ol) {
  padding-left: 1.6em;
  margin: 0.6em 0;
}

.markdown-body :deep(li) { margin: 0.3em 0; }

.markdown-body :deep(blockquote) {
  border-left: 3px solid var(--accent);
  margin: 1em 0;
  padding: 6px 16px;
  color: var(--text-secondary);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body :deep(table) {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
}

.markdown-body :deep(th),
.markdown-body :deep(td) {
  border: 1px solid var(--border-default);
  padding: 8px 12px;
  text-align: left;
}

.markdown-body :deep(th) {
  background: var(--bg-elevated);
  font-weight: 600;
}

.markdown-body :deep(tr:nth-child(even) td) {
  background: var(--bg-elevated);
}

.markdown-body :deep(hr) {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 1.5em 0;
}

@media (max-width: 767px) {
  .about-page { padding: 16px 12px; }
  .about-card { padding: 20px 16px; }
}
</style>
