mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 数据历史文档中支持操作类型过滤 https://github.com/siyuan-note/siyuan/issues/5754
This commit is contained in:
parent
a165cac78e
commit
84b0cf7033
2 changed files with 16 additions and 10 deletions
|
|
@ -606,20 +606,29 @@ func fromSQLHistories(sqlHistories []*sql.History) (ret []*History) {
|
||||||
tmpTime = unixSec
|
tmpTime = unixSec
|
||||||
}
|
}
|
||||||
if tmpTime == unixSec {
|
if tmpTime == unixSec {
|
||||||
items = append(items, &HistoryItem{
|
item := &HistoryItem{
|
||||||
Title: sqlHistory.Title,
|
Title: sqlHistory.Title,
|
||||||
Path: filepath.Join(util.HistoryDir, sqlHistory.Path),
|
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 {
|
} else {
|
||||||
ret = append(ret, &History{
|
ret = append(ret, &History{
|
||||||
HCreated: time.Unix(unixSec, 0).Format("2006-01-02 15:04:05"),
|
HCreated: time.Unix(unixSec, 0).Format("2006-01-02 15:04:05"),
|
||||||
Items: items,
|
Items: items,
|
||||||
})
|
})
|
||||||
items = []*HistoryItem{}
|
|
||||||
items = append(items, &HistoryItem{
|
item := &HistoryItem{
|
||||||
Title: sqlHistory.Title,
|
Title: sqlHistory.Title,
|
||||||
Path: filepath.Join(util.HistoryDir, sqlHistory.Path),
|
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) {
|
if 0 < len(items) {
|
||||||
|
|
|
||||||
|
|
@ -204,11 +204,8 @@ func serveAssets(ginServer *gin.Engine) {
|
||||||
http.ServeFile(context.Writer, context.Request, p)
|
http.ServeFile(context.Writer, context.Request, p)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
ginServer.GET("/history/:dir/assets/*name", model.CheckAuth, func(context *gin.Context) {
|
ginServer.GET("/history/*path", model.CheckAuth, func(context *gin.Context) {
|
||||||
dir := context.Param("dir")
|
p := filepath.Join(util.HistoryDir, context.Param("path"))
|
||||||
name := context.Param("name")
|
|
||||||
relativePath := path.Join(dir, "assets", name)
|
|
||||||
p := filepath.Join(util.HistoryDir, relativePath)
|
|
||||||
http.ServeFile(context.Writer, context.Request, p)
|
http.ServeFile(context.Writer, context.Request, p)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue