Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-10-24 12:51:36 +08:00
commit 6e415879ee
5 changed files with 42 additions and 62 deletions

View file

@ -11,6 +11,7 @@ Below are the detailed changes in this version.
* [Support `siyuan://` protocol on macOS](https://github.com/siyuan-note/siyuan/issues/12271)
* [Improve UI layout](https://github.com/siyuan-note/siyuan/pull/15011)
* [Improve the outline panel](https://github.com/siyuan-note/siyuan/pull/15814)
* [Improve `Recent documents`](https://github.com/siyuan-note/siyuan/pull/15824)
* [Improve code block language selection](https://github.com/siyuan-note/siyuan/pull/15966)
* [Improve the database history](https://github.com/siyuan-note/siyuan/issues/16092)
* [Improve the prompt displayed when the web page does not have permission to read the clipboard](https://github.com/siyuan-note/siyuan/issues/16100)

View file

@ -11,6 +11,7 @@
* [在 macOS 上支援 `siyuan://` 協定](https://github.com/siyuan-note/siyuan/issues/12271)
* [改進介面佈局](https://github.com/siyuan-note/siyuan/pull/15011)
* [改進大綱面板](https://github.com/siyuan-note/siyuan/pull/15814)
* [改進 `最近的文件`](https://github.com/siyuan-note/siyuan/pull/15824)
* [改進程式碼區塊語言選擇](https://github.com/siyuan-note/siyuan/pull/15966)
* [改進資料庫歷史](https://github.com/siyuan-note/siyuan/issues/16092)
* [改進網頁無權限讀取剪貼簿時顯示的提示](https://github.com/siyuan-note/siyuan/issues/16100)

View file

@ -11,6 +11,7 @@
* [在 macOS 上支持 `siyuan://` 协议](https://github.com/siyuan-note/siyuan/issues/12271)
* [改进界面布局](https://github.com/siyuan-note/siyuan/pull/15011)
* [改进大纲面板](https://github.com/siyuan-note/siyuan/pull/15814)
* [改进 `最近的文档`](https://github.com/siyuan-note/siyuan/pull/15824)
* [改进代码块语言选择](https://github.com/siyuan-note/siyuan/pull/15966)
* [改进数据库历史](https://github.com/siyuan-note/siyuan/issues/16092)
* [改进网页无权限读取剪贴板时显示的提示](https://github.com/siyuan-note/siyuan/issues/16100)

View file

@ -35,7 +35,7 @@ func getRecentDocs(c *gin.Context) {
}
// 获取排序参数
sortBy := "viewedAt" // 默认按浏览时间排序
sortBy := "viewedAt" // 默认按浏览时间排序openAt按打开时间排序closedAt按关闭时间排序
if arg["sortBy"] != nil {
sortBy = arg["sortBy"].(string)
}
@ -248,7 +248,6 @@ func removeOutlineStorage(c *gin.Context) {
}
}
func updateRecentDocViewTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -267,7 +266,6 @@ func updateRecentDocViewTime(c *gin.Context) {
}
}
func updateRecentDocOpenTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -302,4 +300,4 @@ func updateRecentDocCloseTime(c *gin.Context) {
ret.Msg = err.Error()
return
}
}
}

View file

@ -53,7 +53,7 @@ func RemoveRecentDoc(ids []string) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
recentDocs, err := getRecentDocs("")
if err != nil {
return
}
@ -86,7 +86,7 @@ func setRecentDocByTree(tree *parse.Tree) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
recentDocs, err := getRecentDocs("")
if err != nil {
return
}
@ -112,7 +112,7 @@ func UpdateRecentDocOpenTime(rootID string) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
recentDocs, err := getRecentDocs("")
if err != nil {
return
}
@ -138,7 +138,7 @@ func UpdateRecentDocViewTime(rootID string) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
recentDocs, err := getRecentDocs("")
if err != nil {
return
}
@ -168,7 +168,7 @@ func UpdateRecentDocCloseTime(rootID string) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
recentDocs, err := getRecentDocs("")
if err != nil {
return
}
@ -189,10 +189,10 @@ func UpdateRecentDocCloseTime(rootID string) (err error) {
return
}
func GetRecentDocs(sortBy ...string) (ret []*RecentDoc, err error) {
func GetRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
return getRecentDocs(sortBy...)
return getRecentDocs(sortBy)
}
func setRecentDocs(recentDocs []*RecentDoc) (err error) {
@ -217,7 +217,7 @@ func setRecentDocs(recentDocs []*RecentDoc) (err error) {
return
}
func getRecentDocs(sortBy ...string) (ret []*RecentDoc, err error) {
func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
tmp := []*RecentDoc{}
dataPath := filepath.Join(util.DataDir, "storage/recent-doc.json")
if !filelock.IsExist(dataPath) {
@ -255,56 +255,36 @@ func getRecentDocs(sortBy ...string) (ret []*RecentDoc, err error) {
}
// 根据排序参数进行排序
if len(sortBy) > 0 {
switch sortBy[0] {
case "closedAt":
// 按关闭时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].ClosedAt == 0 && ret[j].ClosedAt == 0 {
// 如果都没有关闭时间,按浏览时间排序
return ret[i].ViewedAt > ret[j].ViewedAt
}
if ret[i].ClosedAt == 0 {
return false // 没有关闭时间的排在后面
}
if ret[j].ClosedAt == 0 {
return true // 有关闭时间的排在前面
}
return ret[i].ClosedAt > ret[j].ClosedAt
})
case "openAt":
// 按打开时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].OpenAt == 0 && ret[j].OpenAt == 0 {
// 如果都没有打开时间按ID时间排序ID包含时间信息
return ret[i].RootID > ret[j].RootID
}
if ret[i].OpenAt == 0 {
return false // 没有打开时间的排在后面
}
if ret[j].OpenAt == 0 {
return true // 有打开时间的排在前面
}
return ret[i].OpenAt > ret[j].OpenAt
})
default:
// 默认按浏览时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].ViewedAt == 0 && ret[j].ViewedAt == 0 {
// 如果都没有浏览时间按ID时间排序ID包含时间信息
return ret[i].RootID > ret[j].RootID
}
if ret[i].ViewedAt == 0 {
return false // 没有浏览时间的排在后面
}
if ret[j].ViewedAt == 0 {
return true // 有浏览时间的排在前面
}
switch sortBy {
case "closedAt": // 按关闭时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].ClosedAt == 0 && ret[j].ClosedAt == 0 {
// 如果都没有关闭时间,按浏览时间排序
return ret[i].ViewedAt > ret[j].ViewedAt
})
}
} else {
// 默认按浏览时间降序排序如果ViewedAt为0则使用文档创建时间
}
if ret[i].ClosedAt == 0 {
return false // 没有关闭时间的排在后面
}
if ret[j].ClosedAt == 0 {
return true // 有关闭时间的排在前面
}
return ret[i].ClosedAt > ret[j].ClosedAt
})
case "openAt": // 按打开时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].OpenAt == 0 && ret[j].OpenAt == 0 {
// 如果都没有打开时间按ID时间排序ID包含时间信息
return ret[i].RootID > ret[j].RootID
}
if ret[i].OpenAt == 0 {
return false // 没有打开时间的排在后面
}
if ret[j].OpenAt == 0 {
return true // 有打开时间的排在前面
}
return ret[i].OpenAt > ret[j].OpenAt
})
default: // 默认按浏览时间排序
sort.Slice(ret, func(i, j int) bool {
if ret[i].ViewedAt == 0 && ret[j].ViewedAt == 0 {
// 如果都没有浏览时间按ID时间排序ID包含时间信息
@ -319,7 +299,6 @@ func getRecentDocs(sortBy ...string) (ret []*RecentDoc, err error) {
return ret[i].ViewedAt > ret[j].ViewedAt
})
}
return
}