mirror of https://github.com/Xhofe/alist
feat: add `header` to `meta` (ref #5317)
parent
e719a1a456
commit
9ff83a7950
|
@ -1,14 +1,16 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
type Meta struct {
|
type Meta struct {
|
||||||
ID uint `json:"id" gorm:"primaryKey"`
|
ID uint `json:"id" gorm:"primaryKey"`
|
||||||
Path string `json:"path" gorm:"unique" binding:"required"`
|
Path string `json:"path" gorm:"unique" binding:"required"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
PSub bool `json:"p_sub"`
|
PSub bool `json:"p_sub"`
|
||||||
Write bool `json:"write"`
|
Write bool `json:"write"`
|
||||||
WSub bool `json:"w_sub"`
|
WSub bool `json:"w_sub"`
|
||||||
Hide string `json:"hide"`
|
Hide string `json:"hide"`
|
||||||
HSub bool `json:"h_sub"`
|
HSub bool `json:"h_sub"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
RSub bool `json:"r_sub"`
|
RSub bool `json:"r_sub"`
|
||||||
|
Header string `json:"header"`
|
||||||
|
HeaderSub bool `json:"header_sub"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ type FsListResp struct {
|
||||||
Content []ObjResp `json:"content"`
|
Content []ObjResp `json:"content"`
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
|
Header string `json:"header"`
|
||||||
Write bool `json:"write"`
|
Write bool `json:"write"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
}
|
}
|
||||||
|
@ -97,6 +98,7 @@ func FsList(c *gin.Context) {
|
||||||
Content: toObjsResp(objs, reqPath, isEncrypt(meta, reqPath)),
|
Content: toObjsResp(objs, reqPath, isEncrypt(meta, reqPath)),
|
||||||
Total: int64(total),
|
Total: int64(total),
|
||||||
Readme: getReadme(meta, reqPath),
|
Readme: getReadme(meta, reqPath),
|
||||||
|
Header: getHeader(meta, reqPath),
|
||||||
Write: user.CanWrite() || common.CanWrite(meta, reqPath),
|
Write: user.CanWrite() || common.CanWrite(meta, reqPath),
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
})
|
})
|
||||||
|
@ -169,6 +171,13 @@ func getReadme(meta *model.Meta, path string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getHeader(meta *model.Meta, path string) string {
|
||||||
|
if meta != nil && (utils.PathEqual(meta.Path, path) || meta.HeaderSub) {
|
||||||
|
return meta.Header
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func isEncrypt(meta *model.Meta, path string) bool {
|
func isEncrypt(meta *model.Meta, path string) bool {
|
||||||
if common.IsStorageSignEnabled(path) {
|
if common.IsStorageSignEnabled(path) {
|
||||||
return true
|
return true
|
||||||
|
@ -225,6 +234,7 @@ type FsGetResp struct {
|
||||||
ObjResp
|
ObjResp
|
||||||
RawURL string `json:"raw_url"`
|
RawURL string `json:"raw_url"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
|
Header string `json:"header"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Related []ObjResp `json:"related"`
|
Related []ObjResp `json:"related"`
|
||||||
}
|
}
|
||||||
|
@ -328,6 +338,7 @@ func FsGet(c *gin.Context) {
|
||||||
},
|
},
|
||||||
RawURL: rawURL,
|
RawURL: rawURL,
|
||||||
Readme: getReadme(meta, reqPath),
|
Readme: getReadme(meta, reqPath),
|
||||||
|
Header: getHeader(meta, reqPath),
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Related: toObjsResp(related, parentPath, isEncrypt(parentMeta, parentPath)),
|
Related: toObjsResp(related, parentPath, isEncrypt(parentMeta, parentPath)),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue