Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 数据历史文档中支持操作类型过滤 https://github.com/siyuan-note/siyuan/issues/5754

Liang Ding84b0cf70335e
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 6c2434795e..4e5f8f16a5 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -606,20 +606,29 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) {
tmpTime = unixSec
}
if tmpTime == unixSec {
- items = append(items, &HistoryItem{
+ item := &HistoryItem{
Title: sqlHistory.Title,
Path: filepath.Join(util.HistoryDir, sqlHistory.Path),
- })
+ }
+ if HistoryTypeAsset == sqlHistory.Type {
+ item.Path = filepath.ToSlash(strings.TrimPrefix(item.Path, util.WorkspaceDir))
+ }
+ items = append(items, item)
} else {
ret = append(ret, &History{
HCreated: time.Unix(unixSec, 0).Format("2006-01-02 15:04:05"),
Items: items,
})
- items = []*HistoryItem{}
- items = append(items, &HistoryItem{
+
+ item := &HistoryItem{
Title: sqlHistory.Title,
Path: filepath.Join(util.HistoryDir, sqlHistory.Path),
- })
+ }
+ if HistoryTypeAsset == sqlHistory.Type {
+ item.Path = filepath.ToSlash(strings.TrimPrefix(item.Path, util.WorkspaceDir))
+ }
+ items = []*HistoryItem{}
+ items = append(items, item)
}
}
if 0 < len(items) {
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index a974d91a19..993780bf4c 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -204,11 +204,8 @@ func serveAssets(ginServer *gin.Engine) {
http.ServeFile(context.Writer, context.Request, p)
return
})
- ginServer.GET("/history/:dir/assets/*name", model.CheckAuth, func(context *gin.Context) {
- dir := context.Param("dir")
- name := context.Param("name")
- relativePath := path.Join(dir, "assets", name)
- p := filepath.Join(util.HistoryDir, relativePath)
+ ginServer.GET("/history/*path", model.CheckAuth, func(context *gin.Context) {
+ p := filepath.Join(util.HistoryDir, context.Param("path"))
http.ServeFile(context.Writer, context.Request, p)
return
})