mirror of https://github.com/Xhofe/alist
feat: add readme field to list resp
parent
e614faa99b
commit
35b04ffa9c
|
@ -59,7 +59,7 @@ func whetherHide(user *model.User, meta *model.Meta, path string) bool {
|
|||
return false
|
||||
}
|
||||
// if meta doesn't apply to sub_folder, don't hide
|
||||
if !utils.PathEqual(meta.Path, path) && !meta.SubFolder {
|
||||
if !utils.PathEqual(meta.Path, path) && !meta.HSub {
|
||||
return false
|
||||
}
|
||||
// if is guest, hide
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package model
|
||||
|
||||
type Meta struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
Path string `json:"path" gorm:"unique" binding:"required"`
|
||||
Password string `json:"password"`
|
||||
Write bool `json:"upload"`
|
||||
Hide string `json:"hide"`
|
||||
SubFolder bool `json:"sub_folder"`
|
||||
Readme string `json:"readme"`
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
Path string `json:"path" gorm:"unique" binding:"required"`
|
||||
Password string `json:"password"`
|
||||
PSub bool `json:"p_sub"`
|
||||
Write bool `json:"write"`
|
||||
WSub bool `json:"w_sub"`
|
||||
Hide string `json:"hide"`
|
||||
HSub bool `json:"h_sub"`
|
||||
Readme string `json:"readme"`
|
||||
RSub bool `json:"r_sub"`
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func canMkdirOrPut(meta *model.Meta, path string) bool {
|
|||
if meta == nil || !meta.Write {
|
||||
return false
|
||||
}
|
||||
return meta.SubFolder || meta.Path == path
|
||||
return meta.WSub || meta.Path == path
|
||||
}
|
||||
|
||||
type MoveCopyReq struct {
|
||||
|
|
|
@ -34,6 +34,7 @@ type ObjResp struct {
|
|||
type FsListResp struct {
|
||||
Content []ObjResp `json:"content"`
|
||||
Total int64 `json:"total"`
|
||||
Readme string `json:"readme"`
|
||||
}
|
||||
|
||||
func FsList(c *gin.Context) {
|
||||
|
@ -66,9 +67,17 @@ func FsList(c *gin.Context) {
|
|||
common.SuccessResp(c, FsListResp{
|
||||
Content: toObjResp(objs),
|
||||
Total: int64(total),
|
||||
Readme: getReadme(meta, req.Path),
|
||||
})
|
||||
}
|
||||
|
||||
func getReadme(meta *model.Meta, path string) string {
|
||||
if meta != nil && (utils.PathEqual(meta.Path, path) || meta.RSub) {
|
||||
return meta.Readme
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func canAccess(user *model.User, meta *model.Meta, path string, password string) bool {
|
||||
// if is not guest, can access
|
||||
if user.CanAccessWithoutPassword() {
|
||||
|
@ -79,7 +88,7 @@ func canAccess(user *model.User, meta *model.Meta, path string, password string)
|
|||
return true
|
||||
}
|
||||
// if meta doesn't apply to sub_folder, can access
|
||||
if !utils.PathEqual(meta.Path, path) && !meta.SubFolder {
|
||||
if !utils.PathEqual(meta.Path, path) && !meta.PSub {
|
||||
return true
|
||||
}
|
||||
// validate password
|
||||
|
|
|
@ -47,7 +47,7 @@ func needSign(meta *model.Meta, path string) bool {
|
|||
if meta == nil || meta.Password == "" {
|
||||
return false
|
||||
}
|
||||
if !meta.SubFolder && path != meta.Path {
|
||||
if !meta.PSub && path != meta.Path {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue