chore: 初始化仓库,导入项目基线代码

Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
runny committed 2026-11-16 18:12:23 +08:00
commit 7ec21f35b0
5767 files changed
+1436788

No files matched your search

+221
View File
@@ -0,0 +1,221 @@
import { readFileSync, readdirSync } from 'node:fs'
import { createRequire } from 'node:module'
import { resolve } from 'node:path'
import { defineConfig, type DefaultTheme } from 'vitepress'
import { withMermaid } from 'vitepress-plugin-mermaid'
import './theme-config.d.ts'
import { repoVersionLabel } from './version'
import { readScreenshotSizes } from './screenshot-sizes.mjs'
const root = resolve(import.meta.dirname, '..')
const require = createRequire(import.meta.url)
/** 当前安装能解析到该模块时返回 true。缺失的包不能写进 optimizeDeps.include。 */
function installedDep(id: string): boolean {
try {
require.resolve(id)
return true
} catch {
return false
}
}
const sections: { dir: string; label: string; newestFirst?: boolean }[] = [
{ dir: '01-getting-started', label: '快速开始' },
{ dir: '02-architecture', label: '架构' },
{ dir: '03-features', label: '功能模块' },
{ dir: '04-api', label: 'API 参考' },
{ dir: '05-clients', label: '客户端' },
{ dir: '06-development', label: '开发指南' },
// 每个版本一页(v0.8.2.md),最新版本排在最前
{ dir: '07-releases', label: '版本发布', newestFirst: true },
]
/** 侧边栏条目文字:取正文一级标题,去掉冗余前后缀 */
function itemText(dir: string, file: string): string {
const raw = readFileSync(resolve(root, dir, file), 'utf-8')
const heading = raw.match(/^#\s+(.+)$/m)?.[1] ?? file.replace(/\.md$/, '')
return heading
.replace(/^API 参考[::]\s*/, '')
.replace(/\s*[((][^(())]*[))]\s*/g, ' ')
.replace(/\s{2,}/g, ' ')
.trim()
}
/** 版本号按数字比较,v0.10.0 排在 v0.9.0 之后 */
function compareVersions(a: string, b: string): number {
const parts = (f: string) => f.replace(/^v|\.md$/g, '').split('.').map(Number)
const [x, y] = [parts(a), parts(b)]
for (let i = 0; i < Math.max(x.length, y.length); i++) {
if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) - (y[i] ?? 0)
}
return 0
}
function itemsOf(dir: string, newestFirst = false): DefaultTheme.SidebarItem[] {
const files = readdirSync(resolve(root, dir)).filter((f) => f.endsWith('.md'))
return (newestFirst ? files.sort(compareVersions).reverse() : files.sort())
.map((f) => ({
text: itemText(dir, f),
link: `/${dir}/${f.replace(/\.md$/, '')}`,
}))
}
const sidebar: DefaultTheme.SidebarItem[] = sections.map((s) => ({
text: s.label,
collapsed: false,
items: itemsOf(s.dir, s.newestFirst),
}))
/** 本地搜索默认按空白分词,中文整段会被当作一个词,这里退化为字粒度切分 */
function tokenize(text: string): string[] {
const tokens: string[] = []
for (const part of text.split(/[\s\n\r#%*,=/:;?[\]{}()&+\-!'"$·、,。:;?!()【】《》…—]+/)) {
if (!part) continue
if (/[\u4e00-\u9fa5]/.test(part)) {
tokens.push(part, ...part.split(''))
} else {
tokens.push(part)
}
}
return tokens
}
const repo = 'https://github.com/Tencent/WeKnora'
export default withMermaid(
defineConfig({
title: 'Academy',
titleTemplate: ':title · Academy 文档',
description: 'Academy(维娜拉)官方文档:部署、配置、功能说明、API 参考与二次开发',
lang: 'zh-CN',
base: '/docs/',
cleanUrls: true,
appearance: { storageKey: 'vitepress-theme-appearance' },
lastUpdated: true,
srcExclude: ['README.md', 'MIGRATION.md', 'homepage/**', 'shared/**', 'scripts/**', 'deploy/**', 'static-site/**', 'releases/**'],
metaChunk: true,
transformPageData(pageData) {
// The shared masthead replaces the default documentation navbar.
pageData.frontmatter.navbar = false
},
head: [
['link', { rel: 'icon', href: '/docs/favicon.ico', type: 'image/x-icon' }],
['meta', { name: 'theme-color', content: '#101f38' }],
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:title', content: 'Academy 文档' }],
[
'meta',
{
property: 'og:description',
content: '把 PDF、Word、网页与飞书 / Notion / 语雀的资料收进知识库,做成答案带出处的问答系统',
},
],
],
markdown: {
theme: { light: 'github-light', dark: 'github-dark' },
lineNumbers: false,
toc: { level: [2, 3] },
config(md) {
// 表格外面包一层滚动容器。默认主题把 <table> 本身设成 display:block 来做
// 横向滚动,副作用是表格按内容收缩——列少的表比正文列窄一截,页面里宽窄不一。
// 把滚动交给包裹层后,表格可以恢复 display:table + width:100%,统一撑满正文列。
md.renderer.rules.table_open = () => '<div class="wk-table">\n<table>\n'
md.renderer.rules.table_close = () => '</table>\n</div>\n'
},
},
themeConfig: {
logoLink: { link: '/', target: '_self' },
siteTitle: 'Academy',
nav: [],
academyVersion: repoVersionLabel,
academyScreenshotSizes: readScreenshotSizes(resolve(root, 'public/screenshots')),
sidebar,
socialLinks: [{ icon: 'github', link: repo }],
outline: { level: [2, 3], label: '本页目录' },
docFooter: { prev: '上一篇', next: '下一篇' },
returnToTopLabel: '回到顶部',
sidebarMenuLabel: '目录',
darkModeSwitchLabel: '外观',
lightModeSwitchTitle: '切换到浅色',
darkModeSwitchTitle: '切换到深色',
lastUpdated: {
text: '最后更新',
formatOptions: { dateStyle: 'medium', timeStyle: undefined },
},
editLink: {
pattern: `${repo}/edit/main/website-docs/:path`,
text: '在 GitHub 上编辑此页',
},
search: {
provider: 'local',
options: {
translations: {
button: { buttonText: '搜索文档', buttonAriaLabel: '搜索文档' },
modal: {
displayDetails: '展开详情',
resetButtonTitle: '清除',
backButtonTitle: '返回',
noResultsText: '没有找到结果',
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
},
},
},
miniSearch: {
options: { tokenize },
searchOptions: {
fuzzy: 0.2,
prefix: true,
boost: { title: 4, text: 2, titles: 1 },
},
},
},
},
footer: {
message: `基于 Academy ${repoVersionLabel} 源码整理 · MIT License`,
copyright: '© Tencent Academy',
},
},
// mermaid >= 11.17 会动态 import UMD 包 fastdom。Vite 启动时扫不到这次导入,
// 浏览器直接加载原始 fastdom.js,报 does not provide an export named 'default'
//(vitepress-plugin-mermaid#98)。只在能解析到这两个包时才预构建:lockfile 里的
// mermaid 11.16.0 没有 fastdom,无条件 include 会报 Failed to resolve dependency。
vite: {
optimizeDeps: {
include: ['fastdom', 'fastdom/extensions/fastdom-promised.js'].filter(installedDep),
},
},
mermaid: {
theme: 'base',
fontFamily:
'"PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, sans-serif',
themeVariables: {
primaryColor: '#eef1f6',
primaryTextColor: '#101f38',
primaryBorderColor: '#9aa8bd',
lineColor: '#7d8ba1',
secondaryColor: '#faf7ef',
tertiaryColor: '#f6f7f9',
fontSize: '14px',
},
},
}),
)
@@ -0,0 +1,27 @@
import { closeSync, openSync, readSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
// Read intrinsic sizes before rendering HTML so anchor positions do not depend
// on when the screenshot requests finish. Product screenshots are PNG files.
export function readScreenshotSizes(directory) {
const sizes = {};
for (const entry of readdirSync(directory, { withFileTypes: true })) {
if (!entry.isFile() || !entry.name.endsWith('.png')) continue;
const file = openSync(join(directory, entry.name), 'r');
const header = Buffer.alloc(24);
try {
if (readSync(file, header, 0, 24, 0) !== 24
|| !header.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))
|| header.toString('ascii', 12, 16) !== 'IHDR') {
throw new Error(`Invalid PNG screenshot: ${entry.name}`);
}
const width = header.readUInt32BE(16);
const height = header.readUInt32BE(20);
if (!width || !height) throw new Error(`Invalid screenshot dimensions: ${entry.name}`);
sizes[`/screenshots/${entry.name}`] = { width, height };
} finally {
closeSync(file);
}
}
return sizes;
}
+10
View File
@@ -0,0 +1,10 @@
import 'vitepress'
declare module 'vitepress/dist/client/theme-default/config' {
export interface ThemeConfig {
/** 文档站点展示的 Academy 发布版本(来自仓库根 VERSION) */
academyVersion?: string
/** Intrinsic screenshot dimensions used to reserve layout before image loading. */
academyScreenshotSizes?: Record<string, { width: number; height: number }>
}
}
@@ -0,0 +1,232 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, ref } from 'vue'
const MIN = 0.3
const MAX = 8
const open = ref(false)
const scale = ref(1)
const tx = ref(0)
const ty = ref(0)
const stage = ref<HTMLElement>()
let dragging = false
let originX = 0
let originY = 0
function reset() {
scale.value = 1
tx.value = 0
ty.value = 0
}
function close() {
open.value = false
document.documentElement.style.removeProperty('overflow')
}
async function show(source: SVGElement) {
reset()
open.value = true
document.documentElement.style.overflow = 'hidden'
await nextTick()
const host = stage.value
if (!host) return
host.replaceChildren()
// mermaid 的 svg 内联样式以 #id 作用域,且插件会对同 id 元素重新渲染,
// 因此副本必须换一个 id 并同步改写内部样式表
const clone = source.cloneNode(true) as SVGElement
const oldId = source.id
if (oldId) {
const newId = `${oldId}-zoom`
clone.id = newId
clone.querySelectorAll('style').forEach((s) => {
s.textContent = (s.textContent ?? '').split(`#${oldId}`).join(`#${newId}`)
})
}
clone.removeAttribute('width')
clone.removeAttribute('height')
clone.style.maxWidth = 'none'
clone.style.width = '100%'
clone.style.height = '100%'
host.appendChild(clone)
}
function onDocClick(e: MouseEvent) {
const block = (e.target as HTMLElement | null)?.closest?.('.vp-doc .mermaid')
if (!block) return
const svg = block.querySelector('svg')
if (svg) show(svg as SVGElement)
}
function onKey(e: KeyboardEvent) {
if (!open.value) return
if (e.key === 'Escape') close()
if (e.key === '0') reset()
}
function zoomBy(factor: number) {
scale.value = Math.min(MAX, Math.max(MIN, scale.value * factor))
}
function onWheel(e: WheelEvent) {
e.preventDefault()
zoomBy(e.deltaY < 0 ? 1.12 : 1 / 1.12)
}
function onDown(e: MouseEvent) {
dragging = true
originX = e.clientX - tx.value
originY = e.clientY - ty.value
}
function onMove(e: MouseEvent) {
if (!dragging) return
tx.value = e.clientX - originX
ty.value = e.clientY - originY
}
function onUp() {
dragging = false
}
onMounted(() => {
document.addEventListener('click', onDocClick)
document.addEventListener('keydown', onKey)
window.addEventListener('mousemove', onMove)
window.addEventListener('mouseup', onUp)
})
onUnmounted(() => {
document.removeEventListener('click', onDocClick)
document.removeEventListener('keydown', onKey)
window.removeEventListener('mousemove', onMove)
window.removeEventListener('mouseup', onUp)
document.documentElement.style.removeProperty('overflow')
})
</script>
<template>
<Teleport to="body">
<Transition name="zoom-fade">
<div v-if="open" class="zoom" @wheel="onWheel" @mousedown.self="close">
<div
ref="stage"
class="zoom-stage"
:style="{ transform: `translate(${tx}px, ${ty}px) scale(${scale})` }"
@mousedown.stop="onDown"
/>
<div class="zoom-bar" @mousedown.stop>
<button title="缩小" @click="zoomBy(1 / 1.35)">−</button>
<span class="zoom-level">{{ Math.round(scale * 100) }}%</span>
<button title="放大" @click="zoomBy(1.35)">+</button>
<span class="zoom-sep" />
<button class="zoom-word" @click="reset">重置</button>
<button class="zoom-word" @click="close">关闭</button>
</div>
<p class="zoom-hint">滚轮缩放 · 拖拽平移 · Esc 关闭</p>
</div>
</Transition>
</Teleport>
</template>
<style scoped>
.zoom {
position: fixed;
inset: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
background: var(--wk-paper);
cursor: zoom-out;
overscroll-behavior: contain;
}
.zoom-stage {
width: min(1400px, 88vw);
height: 82vh;
cursor: grab;
transform-origin: center center;
}
.zoom-stage:active {
cursor: grabbing;
}
.zoom-bar {
position: fixed;
bottom: 28px;
left: 50%;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 4px;
padding: 6px 8px;
border: 1px solid var(--wk-rule);
border-radius: 3px;
background: var(--wk-paper);
box-shadow: 0 6px 22px rgba(16, 31, 56, 0.08);
cursor: default;
}
.zoom-bar button {
min-width: 30px;
height: 28px;
padding: 0 8px;
border-radius: 2px;
font-size: 15px;
line-height: 1;
color: var(--wk-ink-soft);
transition: background-color 0.18s ease, color 0.18s ease;
}
.zoom-bar button:hover {
background: var(--wk-paper-2);
color: var(--wk-ink);
}
.zoom-word {
font-size: 12.5px !important;
}
.zoom-level {
min-width: 46px;
text-align: center;
font-family: var(--wk-font-mono);
font-size: 11px;
color: var(--wk-ink-mute);
}
.zoom-sep {
width: 1px;
height: 16px;
margin: 0 4px;
background: var(--wk-rule);
}
.zoom-hint {
position: fixed;
top: 26px;
left: 50%;
transform: translateX(-50%);
margin: 0;
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.14em;
color: var(--wk-ink-mute);
}
.zoom-fade-enter-active,
.zoom-fade-leave-active {
transition: opacity 0.18s ease;
}
.zoom-fade-enter-from,
.zoom-fade-leave-to {
opacity: 0;
}
</style>
@@ -0,0 +1,113 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { useData, withBase } from 'vitepress'
const props = defineProps<{
/** 相对站点根的图片路径,约定放在 public/screenshots/ 下 */
src: string
/** 图注:说明这张图展示的是什么 */
caption: string
/** 补充说明:截图应覆盖哪些界面元素,供补图的人参考 */
hint?: string
}>()
const { theme } = useData()
const size = computed(() => theme.value.academyScreenshotSizes?.[props.src])
const failed = ref(false)
const resolved = computed(() => withBase(props.src))
watch(resolved, () => { failed.value = false })
</script>
<template>
<figure class="wk-shot">
<div class="wk-shot-media" :style="size ? { aspectRatio: `${size.width} / ${size.height}` } : undefined">
<img
v-if="size && !failed"
class="wk-shot-img"
:src="resolved"
:alt="caption"
:width="size.width"
:height="size.height"
@error="failed = true"
/>
<div v-else class="wk-shot-placeholder" :class="{ 'wk-shot-placeholder-sized': size }">
<div class="wk-shot-placeholder-badge">{{ failed ? '图片加载失败' : '截图待补充' }}</div>
<div class="wk-shot-placeholder-caption">{{ caption }}</div>
<p v-if="hint" class="wk-shot-placeholder-hint">{{ hint }}</p>
<code class="wk-shot-placeholder-path">website-docs/public{{ src }}</code>
</div>
</div>
<figcaption class="wk-shot-caption">{{ caption }}</figcaption>
</figure>
</template>
<style scoped>
.wk-shot {
margin: 24px 0;
}
.wk-shot-media { position: relative; }
.wk-shot-placeholder-sized {
position: absolute;
inset: 0;
justify-content: center;
overflow: auto;
}
.wk-shot-img {
display: block;
width: 100%;
height: auto;
border: 1px solid var(--vp-c-divider);
border-radius: 10px;
}
.wk-shot-placeholder {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
padding: 32px 24px;
text-align: center;
border: 1px dashed var(--vp-c-divider);
border-radius: 10px;
background: var(--vp-c-bg-soft);
}
.wk-shot-placeholder-badge {
padding: 2px 10px;
border-radius: 999px;
font-size: 12px;
line-height: 20px;
color: var(--vp-c-text-2);
background: var(--vp-c-default-soft);
}
.wk-shot-placeholder-caption {
font-size: 15px;
font-weight: 600;
color: var(--vp-c-text-1);
}
.wk-shot-placeholder-hint {
max-width: 46em;
margin: 0;
font-size: 13px;
line-height: 1.7;
color: var(--vp-c-text-2);
}
.wk-shot-placeholder-path {
font-size: 12px;
color: var(--vp-c-text-3);
}
.wk-shot-caption {
margin-top: 8px;
font-size: 13px;
line-height: 1.6;
text-align: center;
color: var(--vp-c-text-2);
}
</style>
@@ -0,0 +1,32 @@
<script setup lang="ts">
import { nextTick, onMounted, ref, watch } from 'vue'
import { useData } from 'vitepress'
const { page } = useData()
const label = ref<HTMLElement>()
async function revealCurrentPage() {
// Wait for VitePress to mark the current link and expand its section.
await nextTick()
const sidebar = label.value?.closest<HTMLElement>('.VPSidebar')
const active = sidebar?.querySelector<HTMLElement>('.VPSidebarItem.is-active > .item > a')
if (!sidebar || !active) return
const bounds = sidebar.getBoundingClientRect()
const item = active.getBoundingClientRect()
const curtain = sidebar.querySelector<HTMLElement>('.curtain')?.getBoundingClientRect()
const top = Math.max(bounds.top, curtain?.bottom ?? bounds.top) + 16
const bottom = bounds.bottom - 16
if (item.top >= top && item.bottom <= bottom) return
// Move only the sidebar; scrollIntoView could also move the document body.
sidebar.scrollTop += item.top - (top + (bottom - top - item.height) / 2)
}
onMounted(revealCurrentPage)
watch(() => page.value.relativePath, revealCurrentPage, { flush: 'post' })
</script>
<template>
<p ref="label" class="wk-docs-label">使用文档</p>
</template>
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { computed, h, ref, watch, onMounted, onUnmounted } from 'vue'
import { useData, useRoute } from 'vitepress'
import Search from 'vitepress/dist/client/theme-default/components/VPNavBarSearch.vue'
import { repositoryUrl, headerIcons, homeAssets } from '../../shared/header'
const { isDark } = useData()
const route = useRoute()
const docsNavigation = [
{ label: '快速开始', href: '/docs/01-getting-started/03-quickstart', section: '/docs/01-getting-started/' },
{ label: '架构', href: '/docs/02-architecture/01-overview', section: '/docs/02-architecture/' },
{ label: '功能', href: '/docs/03-features/01-tenant-auth', section: '/docs/03-features/' },
{ label: 'API', href: '/docs/04-api/01-api-overview', section: '/docs/04-api/' },
{ label: '客户端', href: '/docs/05-clients/01-frontend', section: '/docs/05-clients/' },
{ label: '开发', href: '/docs/06-development/01-dev-guide', section: '/docs/06-development/' },
{ label: '版本', href: '/docs/07-releases/v0.8.3', section: '/docs/07-releases/' },
]
const open = ref(false)
watch(() => route.path, () => open.value = false)
const menu = ref<HTMLButtonElement>()
const label = computed(() => isDark.value ? '切换到浅色' : '切换到深色')
const HeaderIcon = (props: { name: string }) => h('svg', { viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': 1.4, 'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true' }, [h('path', { d: headerIcons[props.name] })])
function closeMenu(event: KeyboardEvent) {
if (event.key === 'Escape' && open.value) { open.value = false; menu.value?.focus() }
}
onMounted(() => document.addEventListener('keydown', closeMenu))
onUnmounted(() => document.removeEventListener('keydown', closeMenu))
</script>
<template>
<header class="wk-header wk-docs-header">
<div class="wk-header-inner">
<a class="wk-brand" href="/" target="_self" aria-label="Academy 首页"><span class="wk-logo"><img :src="`${homeAssets}/brand/academy-original.png`" alt="Academy" width="945" height="650"></span></a>
<nav id="main-navigation" class="wk-navigation" :class="{ 'is-open': open }" aria-label="文档导航">
<a v-for="item in docsNavigation" :key="item.href" :href="item.href" :aria-current="route.path.startsWith(item.section) ? 'page' : undefined" @click="open = false">{{ item.label }}</a>
<div class="wk-header-search"><Search /></div>
<a class="wk-mobile-github" :href="repositoryUrl" target="_blank" rel="noreferrer">GitHub <HeaderIcon name="external" /></a>
</nav>
<button class="wk-theme-toggle" type="button" role="switch" :aria-checked="isDark" :aria-label="label" :title="label" @click="isDark = !isDark"><HeaderIcon :name="isDark ? 'moon' : 'sun'" /></button>
<a class="wk-header-github" :href="repositoryUrl" target="_blank" rel="noreferrer"><HeaderIcon name="github" /><span>GitHub</span></a>
<button ref="menu" class="wk-menu-toggle" type="button" :aria-label="open ? '关闭导航' : '打开导航'" :aria-expanded="open" aria-controls="main-navigation" @click="open = !open"><HeaderIcon :name="open ? 'close' : 'menu'" /></button>
</div>
</header>
</template>
+20
View File
@@ -0,0 +1,20 @@
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme-without-fonts'
import SiteHeader from './SiteHeader.vue'
import SidebarNavigationSync from './SidebarNavigationSync.vue'
import MermaidZoom from './MermaidZoom.vue'
import Screenshot from './Screenshot.vue'
import './style.css'
export default {
extends: DefaultTheme,
Layout: () => h(DefaultTheme.Layout, null, {
'layout-bottom': () => h(MermaidZoom),
'layout-top': () => h(SiteHeader),
'sidebar-nav-before': () => h(SidebarNavigationSync),
}),
enhanceApp({ app }) {
app.component('Screenshot', Screenshot)
},
} satisfies Theme
+662
View File
@@ -0,0 +1,662 @@
@import '../../shared/brand.css';
@import '../../shared/header.css';
/* ==========================================================================
Academy 文档站主题
墨蓝(logo 主色)· 纸白 · 鎏金(帆浪点缀)
========================================================================== */
:root {
/* —— 覆盖 VitePress 默认变量 —— */
--vp-font-family-base: var(--wk-font-sans);
--vp-font-family-mono: var(--wk-font-mono);
--vp-c-brand-1: var(--wk-ink);
--vp-c-brand-2: #24395a;
--vp-c-brand-3: var(--wk-gold);
--vp-c-brand-soft: rgba(184, 134, 59, 0.14);
--vp-c-bg: var(--wk-paper);
--vp-c-bg-alt: var(--wk-paper-2);
--vp-c-bg-soft: var(--wk-paper-2);
--vp-c-bg-elv: #ffffff;
--vp-c-text-1: var(--wk-ink);
--vp-c-text-2: var(--wk-ink-soft);
--vp-c-text-3: var(--wk-ink-mute);
--vp-c-divider: var(--wk-rule);
--vp-c-gutter: var(--wk-rule);
--vp-c-border: var(--wk-rule);
/* 铺满视口。默认主题用这个值给 .VPContent 算左右内边距
(padding-right: (100vw - max-width) / 2),任何小于视口的定值都会在两侧留出
大片空白;给一个大于视口的定值又会让左内边距被钳到 0、正文钻到侧栏底下。
取 100vw 时右侧内边距为 0、左侧正好等于侧栏宽度。 */
--vp-layout-max-width: 100vw;
--vp-nav-height: 64px;
--vp-sidebar-width: 288px;
--vp-code-block-bg: #fbf9f5;
--vp-home-hero-name-color: var(--wk-ink);
--vp-code-copy-copied-text-content: "已复制";
}
.dark {
--vp-c-brand-1: #e6ecf5;
--vp-c-brand-2: #c3d0e2;
--vp-c-brand-3: var(--wk-gold);
--vp-c-bg-elv: #101a2b;
--vp-code-block-bg: #0d1626;
}
body {
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-feature-settings: "kern" 1, "liga" 1, "cv05" 1;
}
::selection {
background: rgba(184, 134, 59, 0.22);
}
/* --------------------------------------------------------------------------
侧边栏
-------------------------------------------------------------------------- */
/* 默认公式在视口窄于 layout-max-width 时会把侧栏压窄,这里给它一个下限 */
@media (min-width: 1440px) {
.VPSidebar {
width: calc(
max(0px, (100vw - (var(--vp-layout-max-width) - 64px)) / 2) + var(--vp-sidebar-width) - 32px
) !important;
}
}
.VPSidebar {
border-right: 1px solid var(--wk-rule-soft);
}
/* 桌面侧栏透明,让正文背景贯通;窄屏抽屉必须不透明,否则会透出正文 */
@media (min-width: 960px) {
.VPSidebar {
/* 与默认主题一致:正好让出顶栏高度,首组标题紧贴顶栏下沿 */
padding-top: var(--vp-nav-height) !important;
background: transparent !important;
}
}
@media (max-width: 959px) {
.VPSidebar {
padding-top: 18px !important;
background: var(--wk-paper) !important;
border-right: none;
}
.dark .VPSidebar {
background: var(--wk-paper) !important;
}
/* 移动端不需要顶部 curtain */
.VPSidebar .curtain {
display: none;
}
}
/* 默认主题的 curtain 用负 margin 铺满侧栏宽度,会盖住滚动条顶部 */
@media (min-width: 960px) {
.VPSidebar .curtain {
/* Keep the sidebar curtain aligned with the shared masthead. */
top: calc(var(--vp-nav-height) * -1);
margin-right: 0;
width: calc(100% + 32px);
/* 叠加滚动条画在内容区右侧,需裁掉一条竖向通道 */
clip-path: inset(0 14px 0 0);
background-color: color-mix(in srgb, var(--wk-paper) 82%, transparent);
backdrop-filter: saturate(140%) blur(14px);
}
.dark .VPSidebar .curtain {
background-color: color-mix(in srgb, var(--wk-paper) 82%, transparent);
}
}
/* --------------------------------------------------------------------------
中等屏「本页目录」条(960–1279px)
默认通栏 + 底边会横穿侧栏,看起来像多余的线
-------------------------------------------------------------------------- */
@media (min-width: 960px) and (max-width: 1279px) {
.VPLocalNav.has-sidebar {
width: calc(100% - var(--vp-sidebar-width));
margin-left: var(--vp-sidebar-width);
/* 盖过默认主题 scoped 的 padding-left: sidebar-width,否则会双重偏移居中 */
padding-left: 0 !important;
background-color: color-mix(in srgb, var(--wk-paper) 82%, transparent);
backdrop-filter: saturate(140%) blur(14px);
border-bottom-color: var(--wk-rule-soft);
}
.VPLocalNav.has-sidebar .container {
justify-content: flex-start;
padding-left: 32px;
padding-right: 32px;
}
.VPLocalNav.has-sidebar .VPLocalNavOutlineDropdown {
padding-left: 0;
}
/* 默认 left 按通栏算了 sidebar+32;LocalNav 已右移,再加一次会落到中间 */
.VPLocalNav.has-sidebar .VPLocalNavOutlineDropdown .items {
left: 32px;
right: auto;
}
}
.VPSidebarItem.level-0 > .item > .text {
font-family: var(--wk-font-mono);
font-size: 11px !important;
font-weight: 500 !important;
letter-spacing: 0.16em;
text-transform: uppercase;
color: var(--wk-ink-mute) !important;
}
.VPSidebarItem.level-0 {
padding-bottom: 22px;
}
.VPSidebarItem.level-0:not(:first-child) {
border-top: 1px solid var(--wk-rule-soft);
padding-top: 20px;
}
.VPSidebarItem.level-1 .link .text {
font-size: 13.5px;
line-height: 1.6;
color: var(--wk-ink-soft);
transition: color 0.2s ease;
}
.VPSidebarItem.level-1 .link:hover .text {
color: var(--wk-ink);
}
.VPSidebarItem.level-1 > .item {
margin-left: -10px;
padding: 0 10px;
width: calc(100% + 10px);
border-radius: 5px;
}
.VPSidebarItem.level-1.is-active .link .text {
color: var(--wk-accent-text) !important;
font-weight: 700;
}
.VPSidebarItem.level-1.is-active > .item {
position: relative;
background: color-mix(in srgb, var(--wk-gold) 16%, var(--wk-paper));
}
.VPSidebarItem.level-1.is-active > .item::before {
content: "";
position: absolute;
left: 0;
top: 6px;
bottom: 6px;
width: 3px;
border-radius: 2px;
background: var(--wk-gold);
}
/* --------------------------------------------------------------------------
正文排版
-------------------------------------------------------------------------- */
.VPDoc {
padding-top: 44px !important;
}
/* 默认主题用 scoped 选择器把正文锁死在 688px,覆盖它需要 !important。
这里让正文列吃满侧栏与右侧目录之间的空间,只在超宽屏留一个上限,
免得一行拉到两千像素。 */
@media (min-width: 1280px) {
.VPDoc .content-container,
.VPDoc.has-aside .content-container {
max-width: 1600px !important;
}
}
.vp-doc {
font-size: 15.5px;
line-height: 1.82;
color: var(--wk-ink-soft);
}
.vp-doc h1,
.vp-doc h2,
.vp-doc h3,
.vp-doc h4 {
color: var(--wk-ink);
letter-spacing: -0.01em;
}
.vp-doc h1 {
font-family: var(--wk-font-serif);
font-size: 42px;
line-height: 1.22;
font-weight: 500;
letter-spacing: -0.02em;
margin-bottom: 28px;
}
.vp-doc h2 {
font-family: var(--wk-font-serif);
font-size: 27px;
font-weight: 500;
line-height: 1.35;
margin-top: 66px;
padding-top: 26px;
border-top: 1px solid var(--wk-rule-soft);
}
.vp-doc h3 {
font-size: 18.5px;
font-weight: 650;
margin-top: 42px;
letter-spacing: 0;
}
.vp-doc h4 {
font-size: 15.5px;
font-weight: 650;
margin-top: 30px;
}
.vp-doc h2 .header-anchor,
.vp-doc h3 .header-anchor {
color: var(--wk-gold);
font-weight: 400;
}
.vp-doc p,
.vp-doc li {
color: var(--wk-ink-soft);
}
.vp-doc strong {
color: var(--wk-ink);
font-weight: 650;
}
.vp-doc a {
color: var(--wk-ink);
font-weight: 500;
text-decoration: none;
border-bottom: 1px solid color-mix(in srgb, var(--wk-gold) 55%, transparent);
padding-bottom: 1px;
transition: border-color 0.2s ease, background-color 0.2s ease;
}
.vp-doc a:hover {
border-bottom-color: var(--wk-gold);
background: rgba(184, 134, 59, 0.08);
}
.vp-doc ul,
.vp-doc ol {
padding-left: 1.3em;
}
.vp-doc li + li {
margin-top: 6px;
}
.vp-doc li::marker {
color: var(--wk-ink-mute);
}
.vp-doc blockquote {
border-left: 2px solid var(--wk-gold);
background: transparent;
padding: 2px 0 2px 20px;
margin: 26px 0;
}
.vp-doc blockquote > p {
font-size: 14.5px;
color: var(--wk-ink-mute);
margin: 0;
}
.vp-doc hr {
border-top: 1px solid var(--wk-rule-soft);
margin: 52px 0;
}
/* 代码 */
.vp-doc :not(pre) > code {
font-size: 0.86em;
font-family: var(--wk-font-mono);
background: var(--wk-paper-2);
border: 1px solid var(--wk-rule-soft);
border-radius: 3px;
padding: 2px 5px;
color: var(--wk-ink);
}
.vp-doc div[class*="language-"] {
border-radius: 4px;
border: 1px solid var(--wk-rule-soft);
background: var(--vp-code-block-bg);
margin: 26px 0;
}
.vp-doc div[class*="language-"] pre {
padding: 20px 0;
}
.vp-doc [class*="language-"] code {
font-size: 13px;
line-height: 1.72;
}
/* 复制按钮:默认隐形,悬停时才出现的细线方钮 */
.vp-doc [class*="language-"] > button.copy {
top: 9px;
right: 9px;
width: 28px;
height: 28px;
border: 1px solid var(--wk-rule-soft);
border-radius: 2px;
background-color: transparent;
background-size: 14px;
background-position: 50%;
opacity: 0;
transform: translateY(-2px);
transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease,
background-color 0.2s ease;
}
.vp-doc [class*="language-"]:hover > button.copy,
.vp-doc [class*="language-"] > button.copy:focus-visible {
opacity: 1;
transform: none;
}
.vp-doc [class*="language-"] > button.copy:hover {
border-color: var(--wk-gold);
background-color: var(--wk-paper);
}
.vp-doc [class*="language-"] > button.copy.copied,
.vp-doc [class*="language-"] > button.copy:hover.copied {
border-color: var(--wk-gold);
background-color: var(--wk-paper);
}
.vp-doc [class*="language-"] > button.copy.copied::before,
.vp-doc [class*="language-"] > button.copy:hover.copied::before {
top: -1px;
height: 28px;
padding: 0 12px;
border: 1px solid var(--wk-rule-soft);
border-radius: 2px;
background-color: var(--wk-paper);
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.1em;
color: var(--wk-ink-mute);
line-height: 26px;
}
.vp-doc [class*="language-"] > span.lang {
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--wk-ink-mute);
}
/* 表格 */
/* 滚动交给包裹层(见 config.mts 的 table_open 规则),表格本身保持
display:table + width:100%,所有表格宽度一致地撑满正文列 */
.vp-doc .wk-table {
overflow-x: auto;
margin: 28px 0;
max-width: 100%;
}
.vp-doc .wk-table > table {
display: table;
width: 100%;
/* 窄屏下宁可横向滚动,也不要把列挤成一字一行 */
min-width: 420px;
margin: 0;
font-size: 13.5px;
border-collapse: collapse;
}
.vp-doc .wk-table::-webkit-scrollbar {
height: 6px;
}
.vp-doc .wk-table::-webkit-scrollbar-thumb {
background: var(--wk-rule);
border-radius: 3px;
}
.vp-doc th {
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.12em;
text-transform: uppercase;
font-weight: 500;
color: var(--wk-ink-mute);
background: transparent;
border: none;
border-bottom: 1px solid var(--wk-rule);
padding: 10px 14px 10px 0;
text-align: left;
white-space: nowrap;
}
.vp-doc td {
border: none;
border-bottom: 1px solid var(--wk-rule-soft);
padding: 12px 14px 12px 0;
vertical-align: top;
line-height: 1.7;
}
.vp-doc tr {
background: transparent !important;
border: none;
}
.vp-doc th:last-child,
.vp-doc td:last-child {
padding-right: 0;
}
/* 自定义容器 */
.vp-doc .custom-block {
border-radius: 3px;
border: 1px solid var(--wk-rule);
border-left-width: 2px;
background: var(--wk-paper-2);
font-size: 14px;
padding: 16px 20px;
}
.vp-doc .custom-block.tip {
border-left-color: var(--wk-gold);
}
.vp-doc .custom-block-title {
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
/* Mermaid 图 */
.vp-doc .mermaid {
position: relative;
margin: 34px 0;
padding: 28px 20px;
border: 1px solid var(--wk-rule-soft);
border-radius: 4px;
background: var(--wk-paper-2);
text-align: center;
overflow-x: auto;
cursor: zoom-in;
transition: border-color 0.2s ease;
}
.vp-doc .mermaid:hover {
border-color: var(--wk-rule);
}
.vp-doc .mermaid::after {
content: "点击放大";
position: absolute;
right: 12px;
bottom: 10px;
font-family: var(--wk-font-mono);
font-size: 10px;
letter-spacing: 0.14em;
color: var(--wk-ink-mute);
opacity: 0;
transition: opacity 0.2s ease;
}
.vp-doc .mermaid:hover::after {
opacity: 1;
}
/* 页脚区 */
.VPDocFooter {
margin-top: 72px;
padding-top: 26px;
border-top: 1px solid var(--wk-rule-soft);
}
.VPDocFooter .prev-link .desc,
.VPDocFooter .next-link .desc {
font-family: var(--wk-font-mono);
font-size: 10.5px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.VPDocFooter .pager-link {
border: 1px solid var(--wk-rule-soft);
border-radius: 3px;
background: transparent;
}
.VPDocFooter .pager-link:hover {
border-color: var(--wk-gold);
}
.VPDocFooter .pager-link .title {
font-weight: 550;
color: var(--wk-ink);
}
.VPDocAsideOutline .outline-title,
.VPDocOutlineItem .outline-title {
font-family: var(--wk-font-mono);
font-size: 10.5px !important;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--wk-ink-mute);
}
.VPDocAside .outline-link {
font-size: 12.8px;
line-height: 1.65;
padding: 6px 0;
color: var(--wk-ink-mute);
}
.VPDocAside .outline-link.nested {
padding-inline-start: 16px;
}
.VPDocAside .VPDocAsideOutline .root {
padding-inline-start: 2px;
}
.VPDocAside .outline-link.active {
color: var(--wk-ink);
}
.VPDocAsideOutline .outline-marker {
background-color: var(--wk-gold) !important;
}
.VPFooter {
border-top: 1px solid var(--wk-rule-soft);
background: transparent !important;
padding: 34px 24px;
}
.VPFooter .message,
.VPFooter .copyright {
font-size: 12.5px;
color: var(--wk-ink-mute);
letter-spacing: 0.02em;
}
.VPLastUpdated {
font-family: var(--wk-font-mono);
font-size: 11px !important;
letter-spacing: 0.06em;
}
@media (max-width: 640px) {
.vp-doc h1 {
font-size: 32px;
}
.vp-doc h2 {
font-size: 23px;
margin-top: 52px;
}
}
/* Reserve the same masthead space in the default documentation layout. */
:root, .hide-nav, .hide-nav .VPSidebar { --vp-nav-height: 64px; }
.wk-docs-header { position: fixed; left: 0; top: 0; }
.VPLocalNav { top: var(--vp-nav-height); }
.wk-docs-label { margin: 0; padding: 24px 0 16px; color: var(--wk-ink-mute); font-size: 12px; letter-spacing: .08em; }
.wk-header-search .VPNavBarSearch { padding: 0; }
.wk-header-search .DocSearch-Button { width: 160px; height: 36px; padding: 0 10px; justify-content: space-between; border: 1px solid var(--wk-rule); border-radius: 4px; background: var(--wk-paper-2); }
.wk-header-search .DocSearch-Button-Placeholder { display: inline-block; padding: 0 8px; font-size: 12px; }
.wk-header-search .DocSearch-Button-Keys { display: flex; }
@media (min-width: 801px) and (max-width: 1280px) {
.wk-header-search .DocSearch-Button { width: 36px; justify-content: center; }
.wk-header-search .DocSearch-Button-Placeholder, .wk-header-search .DocSearch-Button-Keys { display: none; }
.wk-header-search .DocSearch-Search-Icon { margin: 0; }
}
@media (max-width: 800px) {
.wk-header-search { order: -1; margin-bottom: 10px; }
.wk-header-search, .wk-header-search #local-search, .wk-header-search .DocSearch-Button { width: 100%; }
}
@media (max-width: 959px) {
.Layout { padding-top: var(--vp-nav-height); }
.VPSidebar { top: var(--vp-nav-height); }
.wk-docs-label { padding-top: 0; }
}
@media (max-width: 800px) { :root, .hide-nav, .hide-nav .VPSidebar { --vp-nav-height: 64px; } }
+15
View File
@@ -0,0 +1,15 @@
import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
const versionFile = resolve(import.meta.dirname, '../VERSION')
/** website-docs/VERSION 中的站点发布版本,独立构建时无需读取父目录 */
export function getRepoVersion(): string {
if (!existsSync(versionFile)) return 'unknown'
return readFileSync(versionFile, 'utf-8').trim() || 'unknown'
}
export const repoVersion = getRepoVersion()
export const repoVersionLabel =
repoVersion === 'unknown' || repoVersion.startsWith('v') ? repoVersion : `v${repoVersion}`