初始版本

This commit is contained in:
2026-04-23 16:30:57 +08:00
commit 0d0683a6e6
538 changed files with 113042 additions and 0 deletions

View File

@@ -0,0 +1,567 @@
<template>
<div class="docs-page">
<!-- 面包屑 -->
<div class="breadcrumb-bar">
<div class="breadcrumb-inner">
<a-breadcrumb>
<a-breadcrumb-item>
<a href="/developer">开发者中心</a>
</a-breadcrumb-item>
<a-breadcrumb-item>
<NuxtLink to="/developer/docs">开发文档</NuxtLink>
</a-breadcrumb-item>
<a-breadcrumb-item v-if="page">{{ page.title }}</a-breadcrumb-item>
</a-breadcrumb>
</div>
</div>
<div class="docs-layout">
<!-- 左侧导航 -->
<aside class="docs-sidebar">
<div class="sidebar-inner">
<div class="sidebar-back">
<NuxtLink to="/developer/docs" class="back-link">
返回文档中心
</NuxtLink>
</div>
<!-- 导航树 -->
<nav class="sidebar-nav">
<div v-for="cat in navCategories" :key="cat.key" class="nav-group">
<div class="nav-group-title" @click="toggleGroup(cat.key)">
<span>{{ cat.icon }}</span>
<span class="nav-group-label">{{ cat.label }}</span>
<span class="nav-group-arrow" :class="{ collapsed: !expandedGroups[cat.key] }"></span>
</div>
<div v-show="expandedGroups[cat.key]" class="nav-group-items">
<NuxtLink
v-for="doc in cat.items"
:key="doc.stem?.path"
:to="toPageUrl(doc.stem?.path)"
class="nav-item"
:class="{ active: isActive(doc) }"
>
{{ doc.title }}
</NuxtLink>
</div>
</div>
</nav>
</div>
</aside>
<!-- 右侧内容 -->
<main class="docs-main">
<div v-if="page" class="docs-content">
<h1 class="docs-title">{{ page.title }}</h1>
<p v-if="page.description" class="docs-desc">{{ page.description }}</p>
<ContentRenderer :value="page" />
<!-- 上下篇导航 -->
<div class="docs-nav-footer">
<div v-if="prevDoc" class="nav-footer-item prev" @click="navigateToDoc(prevDoc)">
<span class="nav-footer-dir"> 上一篇</span>
<span class="nav-footer-title">{{ prevDoc.title }}</span>
</div>
<div v-else />
<div v-if="nextDoc" class="nav-footer-item next" @click="navigateToDoc(nextDoc)">
<span class="nav-footer-dir">下一篇 </span>
<span class="nav-footer-title">{{ nextDoc.title }}</span>
</div>
</div>
</div>
<!-- 404 -->
<div v-else class="docs-not-found">
<div class="not-found-icon">📄</div>
<h2>文档未找到</h2>
<p>你访问的文档不存在或已被移除</p>
<NuxtLink to="/developer/docs" class="back-to-docs">
返回文档中心
</NuxtLink>
</div>
</main>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({ layout: 'developer' })
const route = useRoute()
const router = useRouter()
// 将 /developer/docs/xxx 转换为 /docs/xxx 用于 Nuxt Content 查询
const contentPath = computed(() => {
return '/docs/' + (route.params.slug as string[]).join('/')
})
// 查询当前文档
const { data: page } = await useAsyncData(contentPath.value, () =>
queryCollection('docs').path(contentPath.value).first()
)
// 设置页面标题
watchEffect(() => {
if (page.value) {
useHead({ title: `${page.value.title} - 开发文档 - 开发者中心` })
}
})
// 查询所有文档
const { data: allDocs } = await useAsyncData('docs-nav', () =>
queryCollection('docs')
.order('order', 'ASC')
.all()
)
// 分类定义
const categoryMap: Record<string, { label: string; icon: string }> = {
'getting-started': { label: '快速开始', icon: '🚀' },
'api': { label: 'API 参考', icon: '🔌' },
'ai': { label: 'AI 功能', icon: '🤖' },
'deploy': { label: '部署运维', icon: '🚢' },
}
// 构建导航分类
const navCategories = computed(() => {
const docs = allDocs.value || []
const groups: { key: string; label: string; icon: string; items: any[] }[] = []
for (const [key, val] of Object.entries(categoryMap)) {
const items = docs.filter((d: any) => d.category === key)
if (items.length) {
groups.push({ key, label: val.label, icon: val.icon, items })
}
}
return groups
})
// 分组展开状态
const expandedGroups = reactive<Record<string, boolean>>({})
for (const cat of navCategories.value) {
expandedGroups[cat.key] = true
}
function toggleGroup(key: string) {
expandedGroups[key] = !expandedGroups[key]
}
// 判断是否为当前活动项
function isActive(doc: any) {
return doc.stem?.path === contentPath.value
}
// 路径转换:/docs/xxx → /developer/docs/xxx
function toPageUrl(path?: string) {
if (!path) return ''
return path.replace(/^\/docs/, '/developer/docs')
}
// 上/下篇文档
const currentIndex = computed(() => {
const docs = allDocs.value || []
return docs.findIndex((d: any) => d.stem?.path === contentPath.value)
})
const prevDoc = computed(() => {
const idx = currentIndex.value
return idx > 0 ? (allDocs.value as any[])?.[idx - 1] : null
})
const nextDoc = computed(() => {
const docs = allDocs.value || []
const idx = currentIndex.value
return idx < docs.length - 1 ? docs[idx + 1] : null
})
function navigateToDoc(doc: any) {
if (doc?.stem?.path) {
router.push(toPageUrl(doc.stem.path))
}
}
// 滚动到顶部
onMounted(() => {
window.scrollTo(0, 0)
})
</script>
<style scoped>
.docs-page {
min-height: 100%;
background: #f9fafb;
}
/* 面包屑 */
.breadcrumb-bar {
background: #fff;
border-bottom: 1px solid #f0f0f0;
}
.breadcrumb-inner {
max-width: 100%;
padding: 12px 28px;
}
/* 布局 */
.docs-layout {
display: flex;
min-height: calc(100vh - 160px);
}
/* 左侧导航 */
.docs-sidebar {
width: 260px;
flex-shrink: 0;
border-right: 1px solid #f0f0f0;
background: #fff;
overflow-y: auto;
height: calc(100vh - 160px);
position: sticky;
top: 0;
}
.sidebar-inner {
padding: 16px 0;
}
.sidebar-back {
padding: 0 16px 12px;
border-bottom: 1px solid #f5f5f5;
margin-bottom: 8px;
}
.back-link {
font-size: 13px;
color: #4f46e5;
text-decoration: none;
display: block;
}
.back-link:hover {
color: #3730a3;
}
/* 导航树 */
.sidebar-nav {
padding: 4px 0;
}
.nav-group {
margin-bottom: 4px;
}
.nav-group-title {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
font-size: 12px;
font-weight: 600;
color: rgba(0, 0, 0, 0.45);
text-transform: uppercase;
letter-spacing: 0.05em;
cursor: pointer;
user-select: none;
transition: color 0.15s;
}
.nav-group-title:hover {
color: rgba(0, 0, 0, 0.65);
}
.nav-group-label { flex: 1; }
.nav-group-arrow {
font-size: 10px;
transition: transform 0.2s;
color: rgba(0, 0, 0, 0.3);
}
.nav-group-arrow.collapsed {
transform: rotate(-90deg);
}
.nav-group-items {
padding: 2px 0;
}
.nav-item {
display: block;
padding: 7px 16px 7px 36px;
font-size: 13px;
color: rgba(0, 0, 0, 0.6);
text-decoration: none;
transition: all 0.15s;
border-left: 2px solid transparent;
line-height: 1.5;
}
.nav-item:hover {
color: #4f46e5;
background: #f5f7ff;
}
.nav-item.active {
color: #4f46e5;
font-weight: 500;
background: #eef2ff;
border-left-color: #4f46e5;
}
/* 主内容区 */
.docs-main {
flex: 1;
min-width: 0;
}
.docs-content {
max-width: 800px;
margin: 0 auto;
padding: 32px 40px 60px;
}
.docs-title {
font-size: 28px;
font-weight: 700;
color: rgba(0, 0, 0, 0.88);
margin: 0 0 8px;
line-height: 1.3;
}
.docs-desc {
font-size: 15px;
color: rgba(0, 0, 0, 0.45);
margin: 0 0 32px;
line-height: 1.6;
}
/* Nuxt Content 渲染的 Markdown 内容样式 */
.docs-content :deep(h2) {
font-size: 22px;
font-weight: 600;
color: rgba(0, 0, 0, 0.85);
margin: 36px 0 16px;
padding-bottom: 10px;
border-bottom: 1px solid #f0f0f0;
}
.docs-content :deep(h3) {
font-size: 18px;
font-weight: 600;
color: rgba(0, 0, 0, 0.82);
margin: 28px 0 12px;
}
.docs-content :deep(h4) {
font-size: 15px;
font-weight: 600;
color: rgba(0, 0, 0, 0.78);
margin: 20px 0 10px;
}
.docs-content :deep(p) {
font-size: 14px;
line-height: 1.75;
color: rgba(0, 0, 0, 0.72);
margin: 0 0 16px;
}
.docs-content :deep(blockquote) {
margin: 16px 0;
padding: 12px 16px;
border-left: 3px solid #4f46e5;
background: #f5f7ff;
border-radius: 0 8px 8px 0;
}
.docs-content :deep(blockquote p) {
margin: 0;
color: rgba(0, 0, 0, 0.6);
}
.docs-content :deep(ul),
.docs-content :deep(ol) {
padding-left: 24px;
margin: 12px 0 20px;
}
.docs-content :deep(li) {
font-size: 14px;
line-height: 1.75;
color: rgba(0, 0, 0, 0.72);
margin-bottom: 4px;
}
.docs-content :deep(code) {
font-size: 13px;
padding: 2px 6px;
background: #f3f4f6;
border-radius: 4px;
font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
color: #e11d48;
}
.docs-content :deep(pre) {
margin: 16px 0;
padding: 16px 20px;
background: #1e1e2e;
border-radius: 10px;
overflow-x: auto;
}
.docs-content :deep(pre code) {
background: transparent;
padding: 0;
color: #cdd6f4;
font-size: 13px;
line-height: 1.6;
}
.docs-content :deep(table) {
width: 100%;
border-collapse: collapse;
margin: 16px 0;
font-size: 13px;
}
.docs-content :deep(th) {
background: #f9fafb;
padding: 10px 14px;
text-align: left;
font-weight: 600;
color: rgba(0, 0, 0, 0.72);
border-bottom: 2px solid #e5e7eb;
}
.docs-content :deep(td) {
padding: 10px 14px;
border-bottom: 1px solid #f0f0f0;
color: rgba(0, 0, 0, 0.65);
}
.docs-content :deep(tr:hover td) {
background: #fafbff;
}
.docs-content :deep(a) {
color: #4f46e5;
text-decoration: none;
}
.docs-content :deep(a:hover) {
text-decoration: underline;
}
.docs-content :deep(hr) {
border: none;
border-top: 1px solid #f0f0f0;
margin: 28px 0;
}
.docs-content :deep(strong) {
color: rgba(0, 0, 0, 0.85);
font-weight: 600;
}
/* 上下篇导航 */
.docs-nav-footer {
display: flex;
justify-content: space-between;
gap: 16px;
margin-top: 48px;
padding-top: 24px;
border-top: 1px solid #f0f0f0;
}
.nav-footer-item {
flex: 1;
max-width: 50%;
padding: 14px 16px;
border-radius: 10px;
border: 1px solid #f0f0f0;
background: #fff;
cursor: pointer;
transition: all 0.2s;
}
.nav-footer-item:hover {
border-color: #c7d2fe;
box-shadow: 0 2px 12px rgba(79, 70, 229, 0.08);
}
.nav-footer-item.next {
text-align: right;
margin-left: auto;
}
.nav-footer-dir {
display: block;
font-size: 12px;
color: rgba(0, 0, 0, 0.4);
margin-bottom: 4px;
}
.nav-footer-title {
font-size: 13px;
font-weight: 500;
color: #4f46e5;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 404 */
.docs-not-found {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 80px 24px;
min-height: 50vh;
}
.not-found-icon {
font-size: 56px;
margin-bottom: 16px;
}
.docs-not-found h2 {
font-size: 20px;
font-weight: 600;
color: rgba(0, 0, 0, 0.72);
margin: 0 0 8px;
}
.docs-not-found p {
font-size: 14px;
color: rgba(0, 0, 0, 0.4);
margin: 0 0 20px;
}
.back-to-docs {
color: #4f46e5;
font-size: 14px;
text-decoration: none;
padding: 8px 16px;
border-radius: 8px;
border: 1px solid #e0e7ff;
transition: all 0.15s;
}
.back-to-docs:hover {
background: #eef2ff;
}
/* 响应式 */
@media (max-width: 1024px) {
.docs-sidebar {
display: none;
}
.docs-content {
padding: 24px 20px 48px;
}
}
</style>

View File

@@ -0,0 +1,422 @@
<template>
<div class="dev-page">
<div class="page-header">
<div>
<h2 class="page-title">📚 开发文档</h2>
<p class="page-desc">从快速上手到深度定制全面的开发指引与 API 参考</p>
</div>
<a-input-search
v-model:value="searchKeyword"
placeholder="搜索文档..."
style="width: 240px"
allow-clear
/>
</div>
<div class="page-body">
<!-- 精选文档 -->
<div class="featured-section">
<div class="section-label">🚀 推荐开始</div>
<a-row :gutter="[16, 16]">
<a-col :xs="24" :md="8" v-for="item in featuredDocs" :key="item.title">
<div class="featured-card" @click="navigateTo(item.to)">
<div class="featured-badge" :class="item.badgeColor">{{ item.badge }}</div>
<div class="featured-icon">{{ item.icon }}</div>
<h3 class="featured-title">{{ item.title }}</h3>
<p class="featured-desc">{{ item.desc }}</p>
</div>
</a-col>
</a-row>
</div>
<a-row :gutter="[16, 0]" class="mt-5">
<!-- 左侧分类目录 -->
<a-col :xs="24" :lg="6">
<div class="toc-panel">
<div class="toc-header">📂 文档分类</div>
<div
v-for="cat in categories"
:key="cat.key"
class="toc-category"
:class="{ active: activeCategory === cat.key }"
@click="activeCategory = cat.key"
>
<span class="toc-icon">{{ cat.icon }}</span>
<span class="toc-label">{{ cat.label }}</span>
<span class="toc-count">{{ cat.count }}</span>
</div>
</div>
</a-col>
<!-- 右侧文档列表 -->
<a-col :xs="24" :lg="18">
<div class="doc-list">
<div
v-for="doc in filteredDocs"
:key="doc.stem?.path || doc.title"
class="doc-item"
@click="navigateTo(doc.stem?.path || '')"
>
<div class="doc-icon">{{ getCategoryIcon(doc.category) }}</div>
<div class="doc-content">
<div class="doc-title-row">
<span class="doc-title">{{ doc.title }}</span>
</div>
<div class="doc-desc">{{ doc.description }}</div>
<div class="doc-meta">
<span>{{ getCategoryLabel(doc.category) }}</span>
</div>
</div>
<div class="doc-arrow"></div>
</div>
<div v-if="filteredDocs.length === 0" class="empty-state">
<div class="empty-icon">🔍</div>
<div class="empty-title">没有找到相关文档</div>
<div class="empty-desc">换个关键词试试吧</div>
</div>
</div>
</a-col>
</a-row>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({ layout: 'developer' })
useHead({ title: '开发文档 - 开发者中心' })
const searchKeyword = ref('')
const activeCategory = ref('all')
const router = useRouter()
// 查询所有文档
const { data: docs } = await useAsyncData('docs-list', () =>
queryCollection('docs')
.order('order', 'ASC')
.all()
)
// 分类定义
const categoryMap: Record<string, { label: string; icon: string }> = {
'getting-started': { label: '快速开始', icon: '⚡' },
'api': { label: 'API 参考', icon: '🔌' },
'ai': { label: 'AI 功能', icon: '🤖' },
'deploy': { label: '部署运维', icon: '🚢' },
}
function getCategoryLabel(cat: string) {
return categoryMap[cat]?.label || cat
}
function getCategoryIcon(cat: string) {
return categoryMap[cat]?.icon || '📄'
}
// 分类列表(带数量)
const categories = computed(() => {
const cats: { key: string; icon: string; label: string; count: number }[] = [
{ key: 'all', icon: '🌐', label: '全部文档', count: docs.value?.length || 0 },
]
for (const [key, val] of Object.entries(categoryMap)) {
const count = docs.value?.filter((d: any) => d.category === key).length || 0
cats.push({ key, icon: val.icon, label: val.label, count })
}
return cats
})
// 精选文档
const featuredDocs = [
{
icon: '⚡',
badge: '入门必读',
badgeColor: 'blue',
title: '5 分钟快速上手',
desc: '安装 SDK获取 API Key发送第一个请求立即体验平台能力。',
to: '/developer/docs/getting-started/quickstart',
},
{
icon: '🤖',
badge: 'AI 推荐',
badgeColor: 'purple',
title: 'AI 智能体接入',
desc: '集成 AI Agent实现知识库问答、工作流触发与多模型切换。',
to: '/developer/docs/ai/agent',
},
{
icon: '🚢',
badge: '生产就绪',
badgeColor: 'green',
title: '私有化部署指南',
desc: 'Docker Compose 一键部署HTTPS 配置、备份策略与版本升级。',
to: '/developer/docs/deploy/private-deploy',
},
]
// 过滤文档
const filteredDocs = computed(() => {
let list = docs.value || []
if (activeCategory.value !== 'all') {
list = list.filter((d: any) => d.category === activeCategory.value)
}
const kw = searchKeyword.value.trim().toLowerCase()
if (kw) {
list = list.filter(
(d: any) =>
(d.title as string)?.toLowerCase().includes(kw) ||
(d.description as string)?.toLowerCase().includes(kw)
)
}
return list
})
function navigateTo(path: string) {
// Nuxt Content 的 path 是 /docs/xxx需要转换为 /developer/docs/xxx
const target = path.replace(/^\/docs/, '/developer/docs')
router.push(target)
}
</script>
<style scoped>
.dev-page { min-height: 100%; }
.page-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24px 28px 16px;
border-bottom: 1px solid #f0f0f0;
gap: 16px;
}
.page-title {
font-size: 20px;
font-weight: 700;
color: rgba(0, 0, 0, 0.88);
margin: 0 0 4px;
}
.page-desc {
font-size: 14px;
color: rgba(0, 0, 0, 0.45);
margin: 0;
}
.page-body {
padding: 20px 24px 28px;
}
/* 精选文档 */
.featured-section { margin-bottom: 0; }
.section-label {
font-size: 13px;
font-weight: 600;
color: rgba(0, 0, 0, 0.5);
margin-bottom: 12px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.featured-card {
padding: 20px;
border-radius: 12px;
border: 1px solid #f0f0f0;
background: #fff;
cursor: pointer;
transition: all 0.2s;
position: relative;
overflow: hidden;
}
.featured-card:hover {
border-color: #c7d2fe;
box-shadow: 0 4px 20px rgba(79, 70, 229, 0.1);
transform: translateY(-2px);
}
.featured-badge {
position: absolute;
top: 0;
right: 0;
padding: 4px 10px;
font-size: 11px;
font-weight: 600;
border-radius: 0 12px 0 10px;
}
.featured-badge.blue { background: #eff6ff; color: #3b82f6; }
.featured-badge.purple { background: #f5f3ff; color: #7c3aed; }
.featured-badge.green { background: #f0fdf4; color: #16a34a; }
.featured-icon {
font-size: 32px;
margin-bottom: 12px;
}
.featured-title {
font-size: 15px;
font-weight: 700;
color: rgba(0, 0, 0, 0.85);
margin: 0 0 8px;
}
.featured-desc {
font-size: 13px;
color: rgba(0, 0, 0, 0.5);
line-height: 1.6;
margin: 0 0 12px;
}
/* 目录面板 */
.toc-panel {
background: #fff;
border: 1px solid #f0f0f0;
border-radius: 12px;
overflow: hidden;
}
.toc-header {
padding: 14px 16px;
font-size: 13px;
font-weight: 600;
color: rgba(0, 0, 0, 0.55);
text-transform: uppercase;
letter-spacing: 0.05em;
border-bottom: 1px solid #f5f5f5;
}
.toc-category {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 16px;
cursor: pointer;
transition: all 0.15s;
border-bottom: 1px solid #f9f9f9;
}
.toc-category:last-child { border-bottom: none; }
.toc-category:hover { background: #f5f7ff; }
.toc-category.active {
background: #f0f0ff;
color: #4f46e5;
}
.toc-icon { font-size: 16px; flex-shrink: 0; }
.toc-label {
flex: 1;
font-size: 13px;
color: rgba(0, 0, 0, 0.72);
}
.toc-category.active .toc-label {
color: #4f46e5;
font-weight: 500;
}
.toc-count {
font-size: 11px;
background: #f0f0f0;
color: rgba(0, 0, 0, 0.45);
padding: 1px 7px;
border-radius: 20px;
}
.toc-category.active .toc-count {
background: #e0e7ff;
color: #4f46e5;
}
/* 文档列表 */
.doc-list {
background: #fff;
border: 1px solid #f0f0f0;
border-radius: 12px;
overflow: hidden;
}
.doc-item {
display: flex;
align-items: center;
gap: 14px;
padding: 16px 18px;
border-bottom: 1px solid #f9f9f9;
cursor: pointer;
transition: all 0.15s;
}
.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: #f9faff; }
.doc-icon {
font-size: 24px;
flex-shrink: 0;
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
background: #f5f5f5;
border-radius: 10px;
}
.doc-content { flex: 1; min-width: 0; }
.doc-title-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.doc-title {
font-size: 14px;
font-weight: 500;
color: rgba(0, 0, 0, 0.85);
}
.doc-desc {
font-size: 12px;
color: rgba(0, 0, 0, 0.4);
margin-bottom: 6px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.doc-meta {
display: flex;
align-items: center;
gap: 6px;
font-size: 11px;
color: rgba(0, 0, 0, 0.35);
}
.doc-arrow {
font-size: 20px;
color: rgba(0, 0, 0, 0.2);
flex-shrink: 0;
transition: all 0.15s;
}
.doc-item:hover .doc-arrow {
color: #4f46e5;
transform: translateX(3px);
}
/* 空状态 */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 48px 24px;
text-align: center;
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: rgba(0, 0, 0, 0.7); }
.empty-desc { font-size: 13px; color: rgba(0, 0, 0, 0.4); margin-top: 4px; }
</style>