From ac966af3d126d59081d119e05ba02f946257f669 Mon Sep 17 00:00:00 2001
From: ai_xiaopei <xiaopei@aisim.cn>
Date: Sun, 26 Jul 2026 23:22:36 +0800
Subject: [PATCH] fix: 移除所有help中的等号格式

---
 scripts/update-wikilinks.py |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/scripts/update-wikilinks.py b/scripts/update-wikilinks.py
new file mode 100644
index 0000000..870c827
--- /dev/null
+++ b/scripts/update-wikilinks.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python3
+"""
+根据 migration-plan.json 更新所有文档的 wikilinks
+"""
+
+import json
+import os
+import re
+import sys
+from pathlib import Path
+
+def load_migration_plan(vault_path):
+    """加载迁移计划"""
+    with open(os.path.join(vault_path, 'migration-plan.json'), 'r', encoding='utf-8') as f:
+        return json.load(f)
+
+def build_path_mapping(migration_plan):
+    """构建路径映射表(旧路径 -> 新路径)"""
+    mapping = {}
+    for migration in migration_plan['migrations']:
+        source = migration['source']
+        target = migration['target']
+        # 移除 .md 扩展名用于匹配
+        source_base = os.path.splitext(source)[0]
+        target_base = os.path.splitext(target)[0]
+        mapping[source_base] = target_base
+        
+        # 也添加文件名到完整路径的映射
+        source_name = os.path.basename(source_base)
+        mapping[source_name] = target_base
+    
+    return mapping
+
+def update_wikilinks(file_path, path_mapping):
+    """更新文件中的 wikilinks"""
+    with open(file_path, 'r', encoding='utf-8') as f:
+        content = f.read()
+    
+    original_content = content
+    
+    # 查找所有 [[...]] 格式的 wikilinks
+    # 支持 [[路径]] 和 [[路径|显示文本]] 格式
+    pattern = r'\[\[([^\]|]+)(\|[^\]]+)?\]\]'
+    
+    def replace_wikilink(match):
+        link_path = match.group(1).strip()
+        display_text = match.group(2) or ''
+        
+        # 尝试在映射中查找
+        if link_path in path_mapping:
+            new_path = path_mapping[link_path]
+            return f'[[{new_path}{display_text}]]'
+        
+        # 尝试匹配文件名(不含路径)
+        link_name = os.path.basename(link_path)
+        if link_name in path_mapping:
+            new_path = path_mapping[link_name]
+            return f'[[{new_path}{display_text}]]'
+        
+        # 未找到匹配,保持原样
+        return match.group(0)
+    
+    content = re.sub(pattern, replace_wikilink, content)
+    
+    if content != original_content:
+        with open(file_path, 'w', encoding='utf-8') as f:
+            f.write(content)
+        return True
+    
+    return False
+
+def main():
+    vault_path = sys.argv[1] if len(sys.argv) > 1 else '.'
+    
+    # 加载迁移计划
+    migration_plan = load_migration_plan(vault_path)
+    path_mapping = build_path_mapping(migration_plan)
+    
+    print(f'已加载 {len(path_mapping)} 个路径映射')
+    
+    # 更新所有迁移后的文件
+    updated = 0
+    total = 0
+    
+    # 遍历新目录结构
+    for platform_dir in ['电子秤平台', '共有硬件', '通用', '第三方平台', '运营管理平台']:
+        platform_path = os.path.join(vault_path, platform_dir)
+        if not os.path.exists(platform_path):
+            continue
+        
+        for md_file in Path(platform_path).rglob('*.md'):
+            total += 1
+            if update_wikilinks(str(md_file), path_mapping):
+                print(f'已更新 wikilinks: {md_file.relative_to(vault_path)}')
+                updated += 1
+    
+    print(f'\n更新完成: {updated}/{total} 个文件的 wikilinks 已更新')
+
+if __name__ == '__main__':
+    main()

--
Gitblit v1.9.1