ai_xiaopei
2026-07-25 3e73d7aa07b288e06bd475d96d1a72dfc304adc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package vault
 
// SectionConfig 定义板块配置
type SectionConfig struct {
    Name     string
    SubPaths map[string]string // 子板块名 -> 路径
}
 
// RootSections 板块配置(对应 Python 版 ROOT_SECTIONS)
var RootSections = map[string]*SectionConfig{
    "实体":     {Name: "实体", SubPaths: map[string]string{"_root": "实体"}},
    "知识":     {Name: "知识", SubPaths: map[string]string{
        "平台知识": "知识/平台知识",
        "典型案例": "知识/典型案例",
        "行业知识": "知识/行业知识",
        "疑难问题": "知识/疑难问题",
        "FAQ":     "知识/FAQ",
        "技术运维": "知识/技术运维",
    }},
    "笔记":     {Name: "笔记", SubPaths: map[string]string{"_root": "笔记"}},
    "FAQ":      {Name: "FAQ", SubPaths: map[string]string{
        "充装类":     "FAQ/充装类",
        "配送类":     "FAQ/配送类",
        "平台操作类": "FAQ/平台操作类",
        "数据同步类": "FAQ/数据同步类",
        "硬件类":     "FAQ/硬件类",
        "网络类":     "FAQ/网络类",
        "综合类":     "FAQ/综合类",
    }},
    "案例":     {Name: "案例", SubPaths: map[string]string{"_root": "案例"}},
    "文档":     {Name: "文档", SubPaths: map[string]string{"_root": "文档"}},
    "行业":     {Name: "行业", SubPaths: map[string]string{"_root": "行业"}},
    "内部工具": {Name: "内部工具", SubPaths: map[string]string{"_root": "内部工具"}},
    "设备":     {Name: "设备", SubPaths: map[string]string{"_root": "设备"}},
}
 
// GetSection 根据文件路径判断所属板块
func GetSection(relPath string) string {
    for section, cfg := range RootSections {
        for _, subPath := range cfg.SubPaths {
            if subPath == "." || subPath == section {
                continue
            }
            if len(relPath) >= len(subPath) && relPath[:len(subPath)] == subPath {
                return section
            }
        }
        if len(relPath) >= len(section) && relPath[:len(section)] == section {
            return section
        }
    }
    return "其他"
}