chore(build): 更新.gitignore配置和清理Wails临时文件
- 添加dist/目录到.gitignore,用于排除打包输出的绿色免安装版 - 添加Wails打包过程中的临时文件和自动生成文件到.gitignore - 删除build/windows/installer/wails_tools.nsh自动生成文件 - 添加Windows安装器临时目录和Webview2安装文件到忽略列表 feat(docs): 添加万川平台对接文档和产品素材 - 创建万川平台登录到获取模型信息的流程说明文档 - 添加万川平台对接实施计划文档 - 新增产品图片、公司简介图、宣传海报、教程截图、案例展示等素材文件 refactor(runtime): 扩展通知功能类型定义 - 添加NotificationOptions接口定义 - 添加NotificationAction接口定义 - 添加NotificationCategory接口定义 - 扩展通知相关的运行时API类型声明,包括初始化、发送、注册分类等功能
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -286,36 +287,54 @@ func syncAutoReplyMaterials(root string, indexPath string) (autoReplyMaterialSyn
|
||||
|
||||
func discoverAutoReplyMaterials(root string) []AutoReplyMaterial {
|
||||
dir := resolveAutoReplyPath(root)
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
items := make([]AutoReplyMaterial, 0, len(entries))
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
items := make([]AutoReplyMaterial, 0, 8)
|
||||
// 递归遍历子目录(filepath.WalkDir):支持 config/materials 下任意层级嵌套。
|
||||
// Path 存相对 root 的子路径并统一为 / 分隔;顶层文件相对路径即文件名,向后兼容旧索引。
|
||||
_ = filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return nil // 单个条目出错跳过,不中断整体扫描
|
||||
}
|
||||
name := entry.Name()
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
name := d.Name()
|
||||
if strings.EqualFold(name, "materials.json") {
|
||||
continue
|
||||
return nil
|
||||
}
|
||||
materialType := inferMaterialType(name)
|
||||
if materialType == "" {
|
||||
continue
|
||||
return nil
|
||||
}
|
||||
rel, relErr := filepath.Rel(dir, path)
|
||||
if relErr != nil {
|
||||
rel = name
|
||||
}
|
||||
rel = filepath.ToSlash(rel)
|
||||
title := strings.TrimSuffix(name, filepath.Ext(name))
|
||||
keywords := defaultMaterialKeywords(title, materialType)
|
||||
// 把子目录名也并入关键词,便于"发我<目录名>的图/文件"命中。
|
||||
// 只添加目录名本身,不再分词,避免关键词过度膨胀。
|
||||
if dirPart := filepath.ToSlash(filepath.Dir(rel)); dirPart != "." && dirPart != "" {
|
||||
for _, seg := range strings.Split(dirPart, "/") {
|
||||
if seg = strings.TrimSpace(seg); seg != "" {
|
||||
keywords = append(keywords, seg)
|
||||
}
|
||||
}
|
||||
keywords = dedupeNonEmptyStrings(keywords)
|
||||
}
|
||||
items = append(items, AutoReplyMaterial{
|
||||
ID: materialIDFromTitle(title),
|
||||
ID: materialIDFromTitle(strings.TrimSuffix(rel, filepath.Ext(rel))),
|
||||
Title: title,
|
||||
Keywords: defaultMaterialKeywords(title, materialType),
|
||||
Keywords: keywords,
|
||||
QuestionPatterns: defaultMaterialQuestionPatterns(title),
|
||||
MaterialType: materialType,
|
||||
Path: name,
|
||||
Path: rel,
|
||||
Caption: defaultMaterialCaption(materialType),
|
||||
Priority: 1,
|
||||
Enabled: true,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return normalizeAutoReplyMaterials(items)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user