1
0
forked from devstar/docs

重新组织项目文件目录结构,在仓库中可以直接查看文档中的图片

This commit is contained in:
孟宁
2025-11-16 06:29:10 +00:00
parent ff69c668c1
commit 6b3638c71a
57 changed files with 193 additions and 259 deletions

View File

@@ -21,5 +21,5 @@
}
},
"postCreateCommand": "apk add git && npm install && npm add -D vitepress",
"postAttachCommand": "npm run docs:dev"
"postAttachCommand": "npm run dev"
}

View File

@@ -28,7 +28,7 @@ jobs:
working-directory:
run: |
chmod +x node_modules/.bin/vitepress
npm run docs:build
npm run build
- name: 构建 Docker 镜像
run: |

6
.gitignore vendored
View File

@@ -1,7 +1,7 @@
# VitePress
docs/.vitepress/dist/
docs/.vitepress/cache/
docs/.vitepress/.temp/
.vitepress/dist/
.vitepress/cache/
.vitepress/.temp/
# Node.js
node_modules/

View File

@@ -1,6 +1,5 @@
import { defineConfig } from 'vitepress'
import type { DefaultTheme } from 'vitepress'
import { set_sidebar } from "../utils/auto_sidebar.js";
// https://vitepress.dev/reference/site-config
export default defineConfig({
@@ -18,18 +17,18 @@ export default defineConfig({
src: '/mnsoftware.png',
},
nav: [
// { text: '文档', link: '/document/index' },
// { text: '文档', link: '/src/document/index' },
//
{ text: 'DevStar', link: '/devstar' },
{ text: '编译加速', link: '/compile' },
{ text: '虚拟仿真', link: '/simulator' },
{ text: 'Enterprise', link: '/enterprise' },
{ text: 'DevStar', link: '/src/devstar' },
{ text: '编译加速', link: '/src/compile' },
{ text: '虚拟仿真', link: '/src/simulator' },
{ text: 'Enterprise', link: '/src/enterprise' },
],
sidebar: {
'/devstar/': sidebarDevStar(), // 直接返回 SidebarItem[]
'/compile/': sidebarCompiling(),
'/simulator/': sidebarSimulator(),
'/enterprise/': sidebarEnterprise()
'/src/devstar/': sidebarDevStar(), // 直接返回 SidebarItem[]
'/src/compile/': sidebarCompiling(),
'/src/simulator/': sidebarSimulator(),
'/src/enterprise/': sidebarEnterprise()
},
socialLinks: [
{ icon: 'github', link: ' https://github.com/mengning/DevStar' }
@@ -70,11 +69,11 @@ function sidebarDevStar(): DefaultTheme.SidebarItem[] {
return [
{
text: 'DevStar Studio',
link: '/devstar/index',
link: '/src/devstar/index',
collapsible: true, // 使整个组可折叠
collapsed: false, // 默认展开
items: [
{ text: 'AI+ DevOps', link: '/devstar/ai-devops' },
{ text: 'AI+ DevOps', link: '/src/devstar/ai-devops' },
]
} as any,
{
@@ -84,8 +83,8 @@ function sidebarDevStar(): DefaultTheme.SidebarItem[] {
items: [
{ text: '对比Gitea与其它Git托管工具', link: 'https://docs.gitea.com/zh-cn/installation/comparison' },
{ text: '数据库准备', link: 'https://docs.gitea.com/zh-cn/installation/database-prep' },
// { text: '数据库准备', link: '/document/installation/from-source' },
{ text: '使用shell脚本安装', link: '/devstar/installation/install-via-shell-script' },
// { text: '数据库准备', link: '/src/document/installation/from-source' },
{ text: '使用shell脚本安装', link: '/src/devstar/installation/install-via-shell-script' },
{ text: '使用二进制文件安装', link: 'https://docs.gitea.com/zh-cn/installation/install-from-binary' },
{ text: '包管理器安装', link: 'https://docs.gitea.com/zh-cn/installation/install-from-package' },
{ text: '使用源代码安装', link: 'https://docs.gitea.com/zh-cn/installation/install-from-source' },
@@ -239,19 +238,19 @@ function sidebarSimulator(): DefaultTheme.SidebarItem[] {
return [
{
text: '虚拟仿真技术',
link: '/simulator/index',
link: '/src/simulator/index',
items: [
]
},
{
text: '虚拟ECU',
link: '/simulator/vECU',
link: '/src/simulator/vECU',
items: [
]
} as any,
{
text: '整车系统级软硬件联合仿真',
link: '/simulator/vehicle-simulator',
link: '/src/simulator/vehicle-simulator',
items: []
},
]
@@ -261,7 +260,7 @@ function sidebarCompiling(): DefaultTheme.SidebarItem[] {
return [
{
text: '编译加速',
link: '/compile/index',
link: '/src/compile/index',
items: [
]
@@ -273,15 +272,15 @@ function sidebarCompiling(): DefaultTheme.SidebarItem[] {
items: [
{
text: '为什么需要分布式编译?',
link: '/compile/why-distributed-compiling'
link: '/src/compile/why-distributed-compiling'
},
{
text: 'CloudBuild',
link: '/compile/cloudbuild'
link: '/src/compile/cloudbuild'
},
{
text: 'ShareBuild',
link: '/compile/sharebuild'
link: '/src/compile/sharebuild'
},
]
} as any,
@@ -292,15 +291,15 @@ function sidebarCompiling(): DefaultTheme.SidebarItem[] {
items: [
{
text: 'AI Compiler简介',
link: '/compile/why-distributed-compiling'
link: '/src/compile/why-distributed-compiling'
},
{
text: 'CloudBuild',
link: '/compile/cloudbuild'
link: '/src/compile/cloudbuild'
},
{
text: 'ShareBuild',
link: '/compile/sharebuild'
link: '/src/compile/sharebuild'
},
]
} as any,
@@ -311,15 +310,15 @@ function sidebarCompiling(): DefaultTheme.SidebarItem[] {
items: [
{
text: 'PGO/LTO简介',
link: '/compile/why-distributed-compiling'
link: '/src/compile/why-distributed-compiling'
},
{
text: 'CloudBuild',
link: '/compile/cloudbuild'
link: '/src/compile/cloudbuild'
},
{
text: 'ShareBuild',
link: '/compile/sharebuild'
link: '/src/compile/sharebuild'
},
]
},
@@ -330,14 +329,14 @@ function sidebarEnterprise(): DefaultTheme.SidebarItem[] {
return [
{
text: 'DevStar Enterprise',
link: '/enterprise/index',
link: '/src/enterprise/index',
items: [
]
},
{
text: '常见问题FAQ',
link: '/enterprise/faq',
link: '/src/enterprise/faq',
items: []
},
]

View File

@@ -4,7 +4,7 @@ WORKDIR /build-app
COPY . .
RUN npm install
RUN npm add -D vitepress
RUN npm run docs:build
RUN npm run build
# 第二阶段nginx打包
FROM nginx:1.25-alpine
@@ -15,7 +15,7 @@ COPY nginx.conf /etc/nginx/conf.d/default.conf
# 将第一阶段的静态文件复制到nginx中
RUN rm -rf /usr/share/nginx/html
RUN mkdir /usr/share/nginx/html
COPY --from=frontend-builder /build-app/docs/.vitepress/dist /usr/share/nginx/html
COPY --from=frontend-builder /build-app/.vitepress/dist /usr/share/nginx/html
# 运行
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -9,15 +9,15 @@ npm add -D vitepress
## 如何启动调试项目
```md
npm run docs:dev
npm run dev
```
## 如何打包项目
```md
npm run docs:build
npm run build
```
## 如何预览打包的项目
```md
npm run docs:preview
npm run preview
```
## 如何添加或修改侧边栏
在docs/.vitepress/config.mts中的sidebar进行修改对于不同路径下的侧边栏分别使用不同函数得到text为侧边栏的描述内容link为点击侧边栏后加载的内容的链接如果有子目录在items进行修改

View File

@@ -1,65 +0,0 @@
import path from "node:path";
import fs from "node:fs";
const DIR_PATH = path.resolve("docs");
const WHITE_LIST = ["index.md", ".vitepress", "node_modules", ".idea", "assets", "public"];
const isDirectory = (path) => fs.lstatSync(path).isDirectory();
const intersections = (arr1, arr2) =>
Array.from(new Set(arr1.filter((item) => !new Set(arr2).has(item))));
// 新增:按文件系统原始顺序排序
const keepOriginalOrder = (files, dirPath) => {
return files
.map(file => ({
name: file,
time: fs.statSync(path.join(dirPath, file)).birthtimeMs // 获取创建时间戳
}))
.sort((a, b) => a.time - b.time) // 按创建时间排序
.map(item => item.name);
};
function getList(params, path1, pathname) {
const res = [];
// 修改点1使用 keepOriginalOrder 保持原始顺序
const orderedParams = keepOriginalOrder(params, path1);
for (let file of orderedParams) { // 修改点2改用 for...of 遍历
const dir = path.join(path1, file);
const isDir = isDirectory(dir);
if (isDir) {
const files = fs.readdirSync(dir);
res.push({
text: file,
collapsible: true,
items: getList(files, dir, `${pathname}/${file}`),
});
} else {
const suffix = path.extname(file);
if (suffix !== ".md") continue;
const name = path.basename(file, '.md');
res.push({
text: name,
link: `${pathname}/${name}`,
});
}
}
// 修改点3完全移除 sort() 调用
return res;
}
export const set_sidebar = (pathname) => {
try {
const dirPath = path.join(DIR_PATH, pathname);
const files = fs.readdirSync(dirPath);
const items = intersections(files, WHITE_LIST);
return getList(items, dirPath, pathname);
} catch (error) {
console.error(`Error generating sidebar for ${pathname}:`, error);
return [];
}
};

View File

@@ -30,7 +30,7 @@ hero:
# details: 安装和使用体验良好的详细描述
---
<script setup>
import Index from './index.vue' // 你的组件
import Index from './src/index.vue' // 你的组件
</script>
<Index/>

View File

@@ -3,9 +3,9 @@
"vitepress": "^1.6.4"
},
"scripts": {
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
},
"dependencies": {
"@vitejs/plugin-vue": "^6.0.1",

View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 233 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

Before

Width:  |  Height:  |  Size: 556 KiB

After

Width:  |  Height:  |  Size: 556 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

Before

Width:  |  Height:  |  Size: 510 KiB

After

Width:  |  Height:  |  Size: 510 KiB

View File

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 126 KiB

View File

Before

Width:  |  Height:  |  Size: 941 KiB

After

Width:  |  Height:  |  Size: 941 KiB

View File

Before

Width:  |  Height:  |  Size: 756 KiB

After

Width:  |  Height:  |  Size: 756 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

@@ -47,6 +47,6 @@ DevStar Enterprise 与 Gitea 项目的版本号不同但相互对应:
## 问题反馈
大多数问题已在 [FAQ](/enterprise/faq) 中解答,如需进一步帮助请联系:
大多数问题已在 [FAQ](/src/enterprise/faq) 中解答,如需进一步帮助请联系:
**邮箱**: [contact@mengning.com.cn](mailto:contact@mengning.com.cn)

View File

@@ -47,6 +47,6 @@ DevStar Enterprise 与 Gitea 项目的版本号不同但相互对应:
## 问题反馈
大多数问题已在 [FAQ](/enterprise/faq) 中解答,如需进一步帮助请联系:
大多数问题已在 [FAQ](/src/enterprise/faq) 中解答,如需进一步帮助请联系:
**邮箱**: [contact@mengning.com.cn](mailto:contact@mengning.com.cn)

View File

@@ -3,7 +3,7 @@
<div class="ten_main">
<div class="ten_links">
<a
href="/devstar/ai-devops"
href="/src/devstar/ai-devops"
class="ten_img"
@mouseenter="hoverItem = 'about'"
@mouseleave="hoverItem = null"
@@ -20,7 +20,7 @@
</a>
<a
href="/compile"
href="/src/compile"
class="ten_img"
@mouseenter="hoverItem = 'culture'"
@mouseleave="hoverItem = null"
@@ -37,7 +37,7 @@
</a>
<a
href="/simulator"
href="/src/simulator"
class="ten_img"
@mouseenter="hoverItem = 'office'"
@mouseleave="hoverItem = null"
@@ -90,7 +90,7 @@
<p>
<a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer">苏ICP备2024068144号-1</a>
©
<a href="/copyright" rel="noopener noreferrer">Mengning Software</a>.
<a href="/src/copyright" rel="noopener noreferrer">Mengning Software</a>.
2025- All rights reserved.
</p>
</div>