feat(ui/files_pane): enable file/folder searching

This commit is contained in:
hexxa 2022-07-30 15:49:38 +08:00 committed by Hexxa
parent 302d3a6af8
commit dbb1ce65ef
10 changed files with 225 additions and 37 deletions

View file

@ -1181,10 +1181,15 @@ func (h *FileHandlers) SearchItems(c *gin.Context) {
}
}
role := c.MustGet(q.RoleParam).(string)
userName := c.MustGet(q.UserParam).(string)
results := []string{}
for pathname, count := range resultsMap {
if count >= len(keywords) {
results = append(results, pathname)
if role == db.AdminRole ||
(role != db.AdminRole && strings.HasPrefix(pathname, userName)) {
results = append(results, pathname)
}
}
}