feat: update documentation content and rebuild static assets for VitePress project

This commit is contained in:
2026-04-01 15:27:24 +08:00
commit f2cd87c42c
518 changed files with 18646 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
import { defineConfig } from 'vitepress'
import fs from 'node:fs'
import path from 'node:path'
// 递归获取目录下所有 markdown 文件作为侧边栏项
function getSidebarItems(dir: string, base: string) {
const items: any[] = []
const fullPath = path.resolve(__dirname, '..', dir)
if (!fs.existsSync(fullPath)) return []
const files = fs.readdirSync(fullPath)
files.forEach(file => {
const filePath = path.join(fullPath, file)
const stat = fs.statSync(filePath)
if (stat.isDirectory()) {
if (file === 'img' || file === 'image') return
const subItems = getSidebarItems(path.join(dir, file), base)
if (subItems.length > 0) {
items.push({
text: file,
collapsed: true,
items: subItems
})
}
} else if (file.endsWith('.md')) {
const name = file.replace('.md', '')
if (name.toLowerCase() === 'index') return
items.push({
text: name,
link: `/${dir}/${name}`.replace(/\\/g, '/')
})
}
})
// 排序:按文件名中的数字排序(如 1.登录,2.管理)
return items.sort((a, b) => {
const getNum = (s: string) => {
const m = s.match(/^(\d+)/)
return m ? parseInt(m[1]) : 999
}
return getNum(a.text) - getNum(b.text)
})
}
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "回乡知识中心", // 修改为更具品牌感的名称
description: "探索编程与业务系统的魅力",
head: [
['script', { src: 'https://cdn.jsdelivr.net/npm/opencc-js@1.0.5/dist/umd/full.js' }]
],
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '首页', link: '/' },
{ text: '编程', link: '/programming/' },
{
text: '业务系统',
items: [
{ text: 'CRM 系统', link: '/crm/1.登录系统' },
{ text: 'ERP 系统', link: '/erp/1.登录系统' },
{ text: 'Odoo 系统', link: '/odoo/1.Odoo简介' },
{ text: '回乡甄选', link: '/hxzx/1.登录后台' },
{ text: '移动 APP', link: '/app/1.移动APP介绍' },
{ text: '回乡BPM', link: '/bxg/1.一心回乡小程序后台' },
{ text: 'POS', link: '/zsw/1.引言' }
]
}
],
sidebar: {
'/programming/': [
{
text: '编程',
items: [
{ text: '编程知识库', link: '/programming/' }
]
}
],
// 自动生成的业务系统侧边栏
'/crm/': [{ text: 'CRM 系统', items: getSidebarItems('crm', 'crm') }],
'/erp/': [{ text: 'ERP 系统', items: getSidebarItems('erp', 'erp') }],
'/hxzx/': [{ text: '回乡甄选', items: getSidebarItems('hxzx', 'hxzx') }],
'/app/': [{ text: '移动 APP', items: getSidebarItems('app', 'app') }],
'/bxg/': [{ text: '回乡BPM', items: getSidebarItems('bxg', 'bxg') }],
'/odoo/': [{ text: 'Odoo 系统', items: getSidebarItems('odoo', 'odoo') }],
'/zsw/': [{ text: 'POS', items: getSidebarItems('zsw', 'zsw') }]
},
socialLinks: [
{ icon: { svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M12.914 2.622C12.33 2.152 11.666 2 11 2s-1.33.152-1.914.622L2.344 8.21C1.865 8.592 1.5 9.172 1.5 9.778v10.3c0 .878.718 1.59 1.601 1.59h5.183c.121 0 .219-.098.219-.22v-6.326c0-.528.428-.956.953-.956h2.89c.525 0 .953.428.953.956v6.326c0 .122.099.22.219.22h5.183c.883 0 1.601-.712 1.601-1.59v-10.3c0-.606-.365-1.186-.844-1.568l-6.745-5.588z"/></svg>' }, link: 'http://bdhp.yixinhuixiang.com' }
]
},
vite: {
assetsInclude: ['**/*.dat']
}
})
+67
View File
@@ -0,0 +1,67 @@
<script setup>
import { onMounted } from 'vue'
const toggleLanguage = () => {
if (typeof OpenCC === 'undefined') {
console.error('OpenCC not loaded')
return
}
const currentMode = localStorage.getItem('lang-mode') || 's2t'
const config = currentMode === 's2t'
? { from: 'cn', to: 'tw' }
: { from: 'tw', to: 'cn' }
const converter = OpenCC.Converter(config)
const root = document.querySelector('#VPContent') || document.body
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false)
let node
while (node = walker.nextNode()) {
node.textContent = converter(node.textContent)
}
localStorage.setItem('lang-mode', currentMode === 's2t' ? 't2s' : 's2t')
}
onMounted(() => {
// 可以根据本地存储初始化
})
</script>
<template>
<button class="lang-btn" @click="toggleLanguage">
/
</button>
</template>
<style scoped>
.lang-btn {
display: flex;
align-items: center;
padding: 0 12px;
height: 32px;
font-size: 14px;
font-weight: 500;
color: var(--vp-c-text-1);
background: var(--vp-c-bg-soft);
border: 1px solid var(--vp-c-divider);
border-radius: 8px;
cursor: pointer;
transition: all 0.25s;
margin-left: 12px;
}
.lang-btn:hover {
border-color: var(--vp-c-brand-1);
color: var(--vp-c-brand-1);
}
@media (max-width: 768px) {
.lang-btn {
margin: 8px 0;
width: 100%;
justify-content: center;
}
}
</style>
+3
View File
@@ -0,0 +1,3 @@
:root {
--vp-nav-logo-height: 24px;
}
+16
View File
@@ -0,0 +1,16 @@
import { h } from 'vue'
import DefaultTheme from 'vitepress/theme'
import LanguageSwitcher from './LanguageSwitcher.vue'
import './custom.css'
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
'nav-bar-content-after': () => h(LanguageSwitcher),
})
},
enhanceApp({ app }) {
app.component('LanguageSwitcher', LanguageSwitcher)
}
}