From e2c34dea3b7f50d445a230c1e3335f7b70f4ad83 Mon Sep 17 00:00:00 2001 From: kurisaw <2053731441@qq.com> Date: Mon, 8 Sep 2025 14:08:00 +0800 Subject: [PATCH] Fix the abnormal UI of version switching --- .github/versions.json | 9 +++++- docs/source/_static/version_menu.js | 49 +++++------------------------ docs/source/config.yaml | 4 +-- docs/source/version_generator.py | 4 +-- 4 files changed, 18 insertions(+), 48 deletions(-) diff --git a/.github/versions.json b/.github/versions.json index c2f9873a..7fbd595f 100644 --- a/.github/versions.json +++ b/.github/versions.json @@ -2,10 +2,17 @@ "versions": [ { "name": "master", - "display_name": "最新版本", + "display_name": "latest", "branch": "master", "url_path": "latest", "description": "最新开发版本" + }, + { + "name": "1.0.0", + "display_name": "1.0.0", + "branch": "1.0.0", + "url_path": "1.0.0", + "description": "1.0.0开发版本" } ], "default_version": "master", diff --git a/docs/source/_static/version_menu.js b/docs/source/_static/version_menu.js index 3639f899..46d83604 100644 --- a/docs/source/_static/version_menu.js +++ b/docs/source/_static/version_menu.js @@ -22,49 +22,14 @@ let config = null; let configPath = ''; - if (isLocalFileSystem) { - // 本地文件系统:优先使用嵌入的版本配置 - console.log('本地文件系统,使用嵌入的版本配置'); - const embeddedConfig = getEmbeddedVersionConfig(); - if (embeddedConfig) { - config = embeddedConfig; - configPath = 'embedded'; - console.log('使用嵌入的版本配置'); - } else { - console.log('嵌入配置不可用,尝试其他方法'); - } + console.log('本地文件系统,使用嵌入的版本配置'); + const embeddedConfig = getEmbeddedVersionConfig(); + if (embeddedConfig) { + config = embeddedConfig; + configPath = 'embedded'; + console.log('使用嵌入的版本配置'); } else { - // 网络环境:尝试加载配置文件 - const possiblePaths = [ - // 当前版本的配置文件(优先) - './_static/version_config.json', - '_static/version_config.json', - '/_static/version_config.json', - '../_static/version_config.json', - '../../_static/version_config.json', - - // 根目录通用配置文件(备选) - '../version_config.json', - '../../version_config.json', - '/version_config.json', - './version_config.json', - 'version_config.json' - ]; - - for (const path of possiblePaths) { - try { - console.log('尝试加载配置文件:', path); - const response = await fetch(path); - if (response.ok) { - config = await response.json(); - configPath = path; - console.log('成功加载配置文件:', path); - break; - } - } catch (e) { - console.log('路径失败:', path, e.message); - } - } + console.log('嵌入配置不可用,尝试其他方法'); } // 如果仍然没有配置,使用嵌入的配置作为兜底 diff --git a/docs/source/config.yaml b/docs/source/config.yaml index f4c23416..8e77dc0e 100644 --- a/docs/source/config.yaml +++ b/docs/source/config.yaml @@ -8,7 +8,7 @@ project: author: "kurisaw" copyright: "Copyright (c) 2006-2025, RT-Thread Development Team" # language: "zh_CN" # 注释掉固定语言配置,支持中英文双语 - website: "kurisaw.eu.org" + website: "www.rt-thread.org" # 仓库配置 repository: @@ -91,4 +91,4 @@ sphinx: - "smartquotes" - "strikethrough" - "substitution" - - "tasklist" \ No newline at end of file + - "tasklist" diff --git a/docs/source/version_generator.py b/docs/source/version_generator.py index 236fce9f..eb61981a 100644 --- a/docs/source/version_generator.py +++ b/docs/source/version_generator.py @@ -18,9 +18,7 @@ def load_versions(): """从 versions.json 文件加载版本列表""" # 尝试多个可能的路径 possible_paths = [ - Path("../.github/versions.json"), # 从根目录运行 - Path("../../.github/versions.json"), # 从docs/source运行 - Path(".github/versions.json"), # 从项目根目录运行 + Path("../../.github/versions.json") # 从docs/source运行 ] versions_file = None