You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
4.1 KiB
98 lines
4.1 KiB
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'] |
|
} |
|
})
|
|
|