From 6b002851c451d0c168ff3adacf2ddf2e31f0db9c Mon Sep 17 00:00:00 2001 From: luckyasme <807254037@qq.com> Date: Wed, 5 Mar 2025 09:53:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 5b35d31..fe2ef0a 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -4,7 +4,7 @@ import matter from 'gray-matter'; import markdownIt from 'markdown-it'; import markdownItAnchor from 'markdown-it-anchor'; import { slugify } from '@mdit-vue/shared'; -import simpleGit from 'simple-git'; +//import simpleGit from 'simple-git'; const __dirname = path.resolve(); // 获取当前文件夹路径 const processedFiles = new Set(); // 记录已处理过的文件路径 @@ -14,7 +14,7 @@ const errors = []; /** * git clone */ -export async function gitClone(options) { +/* export async function gitClone(options) { const tempDir = path.join(__dirname, 'temp'); fs.removeSync(tempDir); fs.ensureDirSync(tempDir); @@ -28,7 +28,7 @@ export async function gitClone(options) { } finally { fs.removeSync(tempDir); } -} +} */ /** * 去除一些 md 符号,只保留文本 -- Gitee From e13a8fae73dc84f0a3c9e4b5cf99238c1e0aa110 Mon Sep 17 00:00:00 2001 From: luckyasme <807254037@qq.com> Date: Wed, 5 Mar 2025 15:14:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build.js | 4 ++- scripts/pre-build-check.js | 61 ++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index fe2ef0a..5f3d7fd 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -304,10 +304,12 @@ async function processMenuFile() { const outputPath = path.join(__dirname, './docs/.vitepress/public/menu/menu.json'); const updatedContent = await mergeReferences(menuFilePath); - fs.outputFileSync(outputPath, JSON.stringify(updatedContent.children, null, 2)); if (errors.length > 0) { console.table(errors); + throw new Error('构建失败~请查看表格输出原因'); } + + fs.outputFileSync(outputPath, JSON.stringify(updatedContent.children, null, 2)); } // 执行处理 diff --git a/scripts/pre-build-check.js b/scripts/pre-build-check.js index c6da9a7..a401412 100644 --- a/scripts/pre-build-check.js +++ b/scripts/pre-build-check.js @@ -2,6 +2,29 @@ import fs from 'fs-extra'; import path from 'path'; import { spawn, execSync } from 'child_process'; +const config = ` +export default { + markdown: { + config: (md) => { + md.renderer.rules.code_inline = (tokens, idx) => { + const content = tokens[idx].content; + const escapedContent = md.utils.escapeHtml(content); + return \`\${escapedContent}\`; + }; + + md.renderer.rules.text = (tokens, idx) => { + const content = tokens[idx].content; + const escapedContent = md.utils.escapeHtml(content); + if (/{{(.*?)}}/g.test(content)) { + return \`\${escapedContent}\`; + } + return escapedContent; + }; + }, + }, +}; +`; + /** * 获取最近一次提交的变更文件(排除被删除的文件) * @returns {string[]} 变更文件路径数组 @@ -61,15 +84,25 @@ function copy(filePath) { * @param {number} tryCount 重试次数 */ function build() { + // 创建临时 docs + fs.ensureDirSync('temp-docs'); + + // 输出临时配置 + if (!fs.existsSync('temp-docs/docs/config.js')) { + fs.outputFileSync('temp-docs/docs/config.js', config); + } + + // 执行 pnpm vitepress build temp-docs const errors = []; - const ps = spawn('pnpm', ['vitepress', 'build', 'temp-docs'], { shell: true }); + const ps = spawn('pnpm', ['vitepress', 'build', 'temp-docs'], { + shell: true, + }); ps.stderr.on('data', (data) => { const match = String(data).match(/Error: \[plugin vite:vue\] (.*?) \((\d+):(\d+)\): (.*?)\n/); if (match && match.length >= 5) { errors.push({ file: match[1].replace('temp-docs', 'docs'), - line: match[2], error: match[4], }); } @@ -82,25 +115,21 @@ function build() { fs.removeSync('docs/.vitepress/dist'); if (errors.length > 0) { console.table(errors); + throw new Error('构建失败~请查看表格输出原因'); } }); } - function main() { - // 创建临时 docs - fs.ensureDirSync('temp-docs'); - - // 获取变更文件复制到临时目录 const changedFiles = getRecentGitChangesSync().filter((item) => item.endsWith('.md') && !item.endsWith('_menu.md')); - console.log('build docs markdown files: '); - console.log(changedFiles.join('\n')); - changedFiles.forEach((item) => { - copy(item); - }); - - // 构建 - build(); + if (changedFiles.length > 0) { + console.log('build docs markdown files: '); + console.log(changedFiles.join('\n')); + changedFiles.forEach((item) => { + copy(item); + }); + build(); + } } -main(); \ No newline at end of file +main(); -- Gitee From fe0d709c16466515a84fff66857edd73032f736a Mon Sep 17 00:00:00 2001 From: luckyasme <807254037@qq.com> Date: Wed, 5 Mar 2025 15:14:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=BD=AC=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/nginx/nginx.conf | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/deploy/nginx/nginx.conf b/deploy/nginx/nginx.conf index 224f56f..e66929d 100644 --- a/deploy/nginx/nginx.conf +++ b/deploy/nginx/nginx.conf @@ -101,6 +101,16 @@ http { index index.html; } + location ^~ /zh/docs/24.03_LTS_SP1/ { + proxy_set_header X-Forwarded-For $http_x_real_ip; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_ssl_protocols TLSv1.3; + proxy_ssl_verify off; + + proxy_pass https://openeuler-website-docs-zh.openeuler-website-docs:8080/zh/docs/24.03_LTS_SP1/; + } + include ./confd/nginx*.conf; error_page 401 402 403 405 406 407 413 414 /error.html; @@ -118,28 +128,5 @@ http { location = /zh/ { return 301 /zh/index.html; } - - # location ^~ /zh/docs/22.03/ { - # proxy_set_header X-Forwarded-For $http_x_real_ip; - # proxy_http_version 1.1; - # proxy_set_header Connection ""; - # proxy_ssl_protocols TLSv1.3; - # proxy_ssl_verify off; - # # 转发后移除前缀 - # rewrite ^/zh/docs/22.03(/.*)$ $1 break; - # proxy_pass http://openeuler-docs-website-stable-2203.openeuler-website-docs:8080; - # } - - # location ^~ /zh/docs/23.03/ { - # proxy_set_header X-Forwarded-For $http_x_real_ip; - # proxy_http_version 1.1; - # proxy_set_header Connection ""; - # proxy_ssl_protocols TLSv1.3; - # proxy_ssl_verify off; - # # 转发后移除前缀 - # rewrite ^/zh/docs/23.03(/.*)$ $1 break; - # proxy_pass http://openeuler-docs-website-stable-2303.openeuler-website-docs:8080; - # } - } } \ No newline at end of file -- Gitee From 7d14f9f89a6dd2ef2fac0e12cd378c05c51ebfb1 Mon Sep 17 00:00:00 2001 From: luckyasme <807254037@qq.com> Date: Wed, 5 Mar 2025 17:15:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E6=A3=80=E8=A7=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/src/components/DocBreadCrumb.vue | 6 ++++++ docs/.vitepress/src/layouts/LayoutDoc.vue | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/src/components/DocBreadCrumb.vue b/docs/.vitepress/src/components/DocBreadCrumb.vue index 05ee2d9..97081b6 100644 --- a/docs/.vitepress/src/components/DocBreadCrumb.vue +++ b/docs/.vitepress/src/components/DocBreadCrumb.vue @@ -100,5 +100,11 @@ const goToPage = (href: string) => { @include respond-to('<=laptop') { height: 18px; } + + .o-breadcrumb { + --breadcrumb-color-hover: var(--o-color-primary1); + --breadcrumb-color-active: var(--o-color-primary1); + --breadcrumb-color-selected: var(--o-color-primary1); + } } diff --git a/docs/.vitepress/src/layouts/LayoutDoc.vue b/docs/.vitepress/src/layouts/LayoutDoc.vue index 8e62a7f..2438ef0 100644 --- a/docs/.vitepress/src/layouts/LayoutDoc.vue +++ b/docs/.vitepress/src/layouts/LayoutDoc.vue @@ -378,11 +378,12 @@ onUnmounted(() => {