From ff4f92c6d7d097c2ef0803f3987f1fa6b4c01314 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Tue, 7 Apr 2026 14:03:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(docs):=20=E5=88=9D=E5=A7=8B=E5=8C=96=20GFr?= =?UTF-8?q?amework=20=E6=96=87=E6=A1=A3=E7=BD=91=E7=AB=99=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 VitePress 主题样式文件,自定义颜色、按钮、首页、自定义块等组件样式 - 配置深蓝色品牌色彩方案,包括文字、悬停和背景色 - 实现首页英雄区域渐变效果和响应式图像模糊滤镜 - 集成本地搜索功能,支持中文界面翻译和搜索提示 - 创建安全泛型转义插件,防止 Markdown 中的尖括号被误解析 - 设置多语言导航菜单,包含入门指南、Core、Game、Godot 等模块链接 - 构建完整的侧边栏结构,覆盖核心框架、游戏模块、源码生成器等所有功能区域 - 配置教程、最佳实践、API参考等学习资源分类 - 添加页脚版权信息、社交链接和返回顶部功能 - 优化移动端和桌面端的搜索框显示适配 --- docs/.vitepress/config.mts | 53 ++++++++++++++++++--------------- docs/.vitepress/theme/style.css | 43 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 24 deletions(-) diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index dc1a8726..b27b9445 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -1,5 +1,26 @@ import { defineConfig } from 'vitepress' +const localSearch = { + provider: 'local' as const, + options: { + translations: { + button: { + buttonText: '搜索', + buttonAriaLabel: '搜索文档' + }, + modal: { + noResultsText: '无法找到相关结果', + resetButtonTitle: '清除查询条件', + footer: { + selectText: '选择', + navigateText: '切换', + closeText: '关闭' + } + } + } + } +} + function safeGenericEscapePlugin() { return { name: 'safe-generic-escape', @@ -62,6 +83,10 @@ export default defineConfig({ chunkSizeWarningLimit: 1000 } }, + themeConfig: { + // 在顶层保留搜索配置,避免构建期只读取站点级配置时把搜索入口裁掉。 + search: localSearch + }, /** 多语言 */ locales: { root: { @@ -71,41 +96,21 @@ export default defineConfig({ themeConfig: { logo: '/logo-icon.png', - - search: { - provider: 'local', - options: { - translations: { - button: { - buttonText: '搜索文档', - buttonAriaLabel: '搜索文档' - }, - modal: { - noResultsText: '无法找到相关结果', - resetButtonTitle: '清除查询条件', - footer: { - selectText: '选择', - navigateText: '切换', - closeText: '关闭' - } - } - } - } - }, + search: localSearch, nav: [ { text: '首页', link: '/zh-CN/' }, { text: '入门指南', link: '/zh-CN/getting-started' }, { text: 'Core', link: '/zh-CN/core/' }, - { text: 'ECS', link: '/zh-CN/ecs/' }, { text: 'Game', link: '/zh-CN/game/' }, { text: 'Godot', link: '/zh-CN/godot/' }, - { text: '源码生成器', link: '/zh-CN/source-generators' }, { text: '教程', link: '/zh-CN/tutorials/' }, - { text: '最佳实践', link: '/zh-CN/best-practices/' }, { text: '更多', items: [ + { text: 'ECS', link: '/zh-CN/ecs/' }, + { text: '源码生成器', link: '/zh-CN/source-generators' }, + { text: '最佳实践', link: '/zh-CN/best-practices/' }, { text: 'API 参考', link: '/zh-CN/api-reference' }, { text: '常见问题', link: '/zh-CN/faq' }, { text: '故障排查', link: '/zh-CN/troubleshooting' }, diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 03029e0d..56ec7d14 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -132,3 +132,46 @@ --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft); } +/** + * Component: Navigation + * -------------------------------------------------------------------------- */ + +@media (min-width: 768px) and (max-width: 1279px) { + /* Keep the search entry visible on medium desktop widths where nav links are the tightest. */ + .VPNavBarSearch { + flex: 0 0 auto; + padding-left: 16px; + } + + .VPNavBarSearch .VPNavBarSearchButton { + min-width: 0; + padding: 8px 10px; + } + + .VPNavBarSearch .keys { + display: none; + } + + .VPNavBarMenu { + min-width: 0; + } + + .VPNavBarMenu .VPNavBarMenuLink, + .VPNavBarMenu .VPFlyout .button { + padding-left: 10px; + padding-right: 10px; + font-size: 13px; + } +} + +@media (min-width: 1280px) { + /* Reserve stable room for the search button before appearance and social actions appear. */ + .VPNavBarSearch { + min-width: 176px; + } + + .VPNavBarSearch .VPNavBarSearchButton { + justify-content: space-between; + min-width: 176px; + } +}