mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 13:33:28 +08:00
refactor(docs): 优化文档站点配置和404页面实现多语言支持
- 更新VitePress配置移除不必要的服务器中间件 - 实现404页面的中英文国际化显示 - 为404页面添加倒计时自动跳转功能 - 重构404页面样式并添加返回首页按钮 - 优化依赖缓存哈希值更新构建配置
This commit is contained in:
parent
b835d3af67
commit
6f4bbd6d06
12
docs/.vitepress/cache/deps/_metadata.json
vendored
12
docs/.vitepress/cache/deps/_metadata.json
vendored
@ -1,25 +1,25 @@
|
|||||||
{
|
{
|
||||||
"hash": "f04df328",
|
"hash": "74ecdc37",
|
||||||
"configHash": "15e8eca7",
|
"configHash": "1c302118",
|
||||||
"lockfileHash": "42b6a898",
|
"lockfileHash": "42b6a898",
|
||||||
"browserHash": "342224e2",
|
"browserHash": "b3e735e5",
|
||||||
"optimized": {
|
"optimized": {
|
||||||
"vue": {
|
"vue": {
|
||||||
"src": "../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
|
"src": "../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
|
||||||
"file": "vue.js",
|
"file": "vue.js",
|
||||||
"fileHash": "c87f1bc4",
|
"fileHash": "5c6400c6",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
},
|
},
|
||||||
"vitepress > @vue/devtools-api": {
|
"vitepress > @vue/devtools-api": {
|
||||||
"src": "../../../node_modules/@vue/devtools-api/dist/index.js",
|
"src": "../../../node_modules/@vue/devtools-api/dist/index.js",
|
||||||
"file": "vitepress___@vue_devtools-api.js",
|
"file": "vitepress___@vue_devtools-api.js",
|
||||||
"fileHash": "4ddc9988",
|
"fileHash": "673694b5",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
},
|
},
|
||||||
"vitepress > @vueuse/core": {
|
"vitepress > @vueuse/core": {
|
||||||
"src": "../../../node_modules/@vueuse/core/dist/index.js",
|
"src": "../../../node_modules/@vueuse/core/dist/index.js",
|
||||||
"file": "vitepress___@vueuse_core.js",
|
"file": "vitepress___@vueuse_core.js",
|
||||||
"fileHash": "3d4a475e",
|
"fileHash": "7fde5c45",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,53 +1,19 @@
|
|||||||
import { defineConfig } from 'vitepress'
|
import { defineConfig } from 'vitepress'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
title: "GFramework",
|
title: 'GFramework',
|
||||||
description: "面向游戏开发场景的模块化 C# 框架",
|
description: '面向游戏开发场景的模块化 C# 框架',
|
||||||
base: "/GFramework/",
|
|
||||||
vite: {
|
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
name: 'catch-all-404',
|
|
||||||
configureServer(server) {
|
|
||||||
return () => {
|
|
||||||
server.middlewares.use((req, res, next) => {
|
|
||||||
const url = req.url || ''
|
|
||||||
|
|
||||||
// 排除这些路径
|
/** GitHub Pages / 子路径部署 */
|
||||||
const excludePaths = [
|
base: '/GFramework/',
|
||||||
'/@vite',
|
|
||||||
'/@fs',
|
|
||||||
'/node_modules',
|
|
||||||
'/__vite',
|
|
||||||
'/public'
|
|
||||||
]
|
|
||||||
|
|
||||||
// 如果是资源文件或特殊路径,跳过
|
/** 多语言 */
|
||||||
if (excludePaths.some(path => url.startsWith(path)) ||
|
|
||||||
url.includes('.') ||
|
|
||||||
url.startsWith('/GFramework/')) {
|
|
||||||
return next()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 其他路径重定向到 404
|
|
||||||
res.writeHead(302, { Location: '/GFramework/404' })
|
|
||||||
res.end()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
server: {
|
|
||||||
strictPort: false,
|
|
||||||
// 添加中间件处理不带斜杠的情况
|
|
||||||
proxy: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
locales: {
|
locales: {
|
||||||
root: {
|
root: {
|
||||||
label: '简体中文',
|
label: '简体中文',
|
||||||
lang: 'zh-CN',
|
lang: 'zh-CN',
|
||||||
link: '/zh-CN/',
|
link: '/zh-CN/',
|
||||||
|
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
logo: '/logo-icon.png',
|
logo: '/logo-icon.png',
|
||||||
|
|
||||||
@ -94,6 +60,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/core/': [
|
'/zh-CN/core/': [
|
||||||
{
|
{
|
||||||
text: 'Core 核心框架',
|
text: 'Core 核心框架',
|
||||||
@ -107,6 +74,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/game/': [
|
'/zh-CN/game/': [
|
||||||
{
|
{
|
||||||
text: 'Game 游戏模块',
|
text: 'Game 游戏模块',
|
||||||
@ -119,6 +87,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/godot/': [
|
'/zh-CN/godot/': [
|
||||||
{
|
{
|
||||||
text: 'Godot 集成',
|
text: 'Godot 集成',
|
||||||
@ -131,6 +100,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/source-generators/': [
|
'/zh-CN/source-generators/': [
|
||||||
{
|
{
|
||||||
text: '源码生成器',
|
text: '源码生成器',
|
||||||
@ -142,6 +112,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/tutorials/': [
|
'/zh-CN/tutorials/': [
|
||||||
{
|
{
|
||||||
text: '教程',
|
text: '教程',
|
||||||
@ -152,6 +123,7 @@ export default defineConfig({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
'/zh-CN/api-reference/': [
|
'/zh-CN/api-reference/': [
|
||||||
{
|
{
|
||||||
text: 'API 参考',
|
text: 'API 参考',
|
||||||
@ -185,56 +157,6 @@ export default defineConfig({
|
|||||||
next: '下一页'
|
next: '下一页'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
// 未来添加英文版本时取消注释
|
|
||||||
/*
|
|
||||||
en: {
|
|
||||||
label: 'English',
|
|
||||||
lang: 'en-US',
|
|
||||||
link: '/en/',
|
|
||||||
themeConfig: {
|
|
||||||
logo: '/logo-icon.png',
|
|
||||||
|
|
||||||
search: {
|
|
||||||
provider: 'local'
|
|
||||||
},
|
|
||||||
|
|
||||||
nav: [
|
|
||||||
{ text: 'Home', link: '/en/' },
|
|
||||||
{ text: 'Getting Started', link: '/en/getting-started/installation' },
|
|
||||||
{ text: 'Core', link: '/en/core/overview' },
|
|
||||||
{ text: 'Game', link: '/en/game/overview' },
|
|
||||||
{ text: 'Godot', link: '/en/godot/overview' },
|
|
||||||
{ text: 'Source Generators', link: '/en/source-generators/overview' },
|
|
||||||
{ text: 'Tutorials', link: '/en/tutorials/basic-tutorial' },
|
|
||||||
{ text: 'API Reference', link: '/en/api-reference/core-api' }
|
|
||||||
],
|
|
||||||
|
|
||||||
sidebar: {
|
|
||||||
'/en/getting-started/': [
|
|
||||||
{
|
|
||||||
text: 'Getting Started',
|
|
||||||
items: [
|
|
||||||
{ text: 'Installation', link: '/en/getting-started/installation' },
|
|
||||||
{ text: 'Quick Start', link: '/en/getting-started/quick-start' },
|
|
||||||
{ text: 'Architecture Overview', link: '/en/getting-started/architecture-overview' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
|
||||||
// ... 其他英文侧边栏配置
|
|
||||||
},
|
|
||||||
|
|
||||||
socialLinks: [
|
|
||||||
{ icon: 'github', link: 'https://github.com/GeWuYou/GFramework' }
|
|
||||||
],
|
|
||||||
|
|
||||||
footer: {
|
|
||||||
message: 'Released under the Apache 2.0 License',
|
|
||||||
copyright: 'Copyright © 2026 GeWuYou'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
92
docs/404.md
92
docs/404.md
@ -2,34 +2,37 @@
|
|||||||
layout: page
|
layout: page
|
||||||
---
|
---
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, onUnmounted } from 'vue'
|
import { ref, onMounted, onUnmounted, computed } from 'vue'
|
||||||
|
import { useData, useRouter, withBase } from 'vitepress'
|
||||||
|
|
||||||
|
const { lang } = useData()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
/** 是否中文 */
|
||||||
|
const isZh = computed(() => lang.value === 'zh-CN')
|
||||||
|
|
||||||
|
/** 倒计时 */
|
||||||
const countdown = ref(5)
|
const countdown = ref(5)
|
||||||
let timer = null
|
let timer: number | null = null
|
||||||
|
|
||||||
|
const goHome = () => {
|
||||||
|
if (timer) clearInterval(timer)
|
||||||
|
router.go(withBase(isZh.value ? '/zh-CN/' : '/en/'))
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
timer = setInterval(() => {
|
timer = window.setInterval(() => {
|
||||||
countdown.value--
|
countdown.value--
|
||||||
if (countdown.value <= 0) {
|
if (countdown.value <= 0) {
|
||||||
clearInterval(timer)
|
goHome()
|
||||||
window.location.href = '/GFramework/zh-CN/'
|
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (timer) {
|
if (timer) clearInterval(timer)
|
||||||
clearInterval(timer)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const goHome = () => {
|
|
||||||
if (timer) {
|
|
||||||
clearInterval(timer)
|
|
||||||
}
|
|
||||||
window.location.href = '/GFramework/zh-CN/'
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -104,30 +107,65 @@ const goHome = () => {
|
|||||||
background: #2841a0;
|
background: #2841a0;
|
||||||
transform: translateY(-2px);
|
transform: translateY(-2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.suggestions {
|
||||||
|
margin-top: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suggestions ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.suggestions li {
|
||||||
|
margin: 6px 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="not-found-container">
|
<div class="not-found-container">
|
||||||
<h1 class="error-code">404</h1>
|
<h1 class="error-code">404</h1>
|
||||||
<h2 class="error-title">Page Not Found / 页面未找到</h2>
|
|
||||||
<p class="error-message">The page you are looking for does not exist.<br>您访问的页面不存在。</p>
|
<h2 class="error-title">
|
||||||
|
{{ isZh ? '页面未找到' : 'Page Not Found' }}
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p class="error-message">
|
||||||
|
<template v-if="isZh">
|
||||||
|
您访问的页面不存在。
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
The page you are looking for does not exist.
|
||||||
|
</template>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p class="countdown-text">
|
<p class="countdown-text">
|
||||||
Auto redirecting in <span class="countdown-number">{{ countdown }}</span> seconds<br>
|
<template v-if="isZh">
|
||||||
<span class="countdown-number">{{ countdown }}</span> 秒后自动跳转
|
<span class="countdown-number">{{ countdown }}</span> 秒后自动跳转
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
Auto redirecting in <span class="countdown-number">{{ countdown }}</span> seconds
|
||||||
|
</template>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="suggestions">
|
<div class="suggestions">
|
||||||
<h3>📚 您可能想访问:</h3>
|
<h3>📚 {{ isZh ? '您可能想访问:' : 'You might be looking for:' }}</h3>
|
||||||
<ul>
|
<ul v-if="isZh">
|
||||||
<li>→ <a href="/GFramework/zh-CN/getting-started/installation">安装配置</a></li>
|
<li>→ <a :href="withBase('/zh-CN/getting-started/installation')">安装配置</a></li>
|
||||||
<li>→ <a href="/GFramework/zh-CN/getting-started/quick-start">快速开始</a></li>
|
<li>→ <a :href="withBase('/zh-CN/getting-started/quick-start')">快速开始</a></li>
|
||||||
<li>→ <a href="/GFramework/zh-CN/core/overview">Core 核心框架</a></li>
|
<li>→ <a :href="withBase('/zh-CN/core/overview')">Core 核心框架</a></li>
|
||||||
<li>→ <a href="/GFramework/zh-CN/tutorials/basic-tutorial">基础教程</a></li>
|
<li>→ <a :href="withBase('/zh-CN/tutorials/basic-tutorial')">基础教程</a></li>
|
||||||
|
</ul>
|
||||||
|
<ul v-else>
|
||||||
|
<li>→ <a :href="withBase('/en/getting-started/installation')">Installation</a></li>
|
||||||
|
<li>→ <a :href="withBase('/en/getting-started/quick-start')">Quick Start</a></li>
|
||||||
|
<li>→ <a :href="withBase('/en/core/overview')">Core Overview</a></li>
|
||||||
|
<li>→ <a :href="withBase('/en/tutorials/basic-tutorial')">Basic Tutorial</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button class="btn btn-primary" @click="goHome">
|
<button class="btn btn-primary" @click="goHome">
|
||||||
Go to Homepage / 返回首页
|
{{ isZh ? '返回首页' : 'Go to Homepage' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
```
|
|
||||||
Loading…
x
Reference in New Issue
Block a user