mirror of https://github.com/Xhofe/alist
✨ Extract folder
parent
e952f1c243
commit
cfb51e9f80
|
@ -119,6 +119,12 @@ func GetDrivers() map[string][]Item {
|
||||||
Label: "down_proxy_url",
|
Label: "down_proxy_url",
|
||||||
Type: TypeString,
|
Type: TypeString,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "extract_folder",
|
||||||
|
Label: "extract_folder",
|
||||||
|
Values: "front,back",
|
||||||
|
Type: TypeSelect,
|
||||||
|
},
|
||||||
}, res[k]...)
|
}, res[k]...)
|
||||||
if v.Config().ApiProxy {
|
if v.Config().ApiProxy {
|
||||||
res[k] = append([]Item{
|
res[k] = append([]Item{
|
||||||
|
|
|
@ -110,7 +110,6 @@ func (driver Native) Files(path string, account *model.Account) ([]model.File, e
|
||||||
}
|
}
|
||||||
files = append(files, file)
|
files = append(files, file)
|
||||||
}
|
}
|
||||||
model.SortFiles(files, account)
|
|
||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Account struct {
|
||||||
AccessKey string `json:"access_key"`
|
AccessKey string `json:"access_key"`
|
||||||
AccessSecret string `json:"access_secret"`
|
AccessSecret string `json:"access_secret"`
|
||||||
CustomHost string `json:"custom_host"`
|
CustomHost string `json:"custom_host"`
|
||||||
|
ExtractFolder string `json:"extract_folder"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var accountsMap = map[string]Account{}
|
var accountsMap = map[string]Account{}
|
||||||
|
|
|
@ -25,14 +25,6 @@ func SortFiles(files []File, account *Account) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sort.Slice(files, func(i, j int) bool {
|
sort.Slice(files, func(i, j int) bool {
|
||||||
if files[i].IsDir() || files[j].IsDir() {
|
|
||||||
if !files[i].IsDir() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if !files[j].IsDir() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch account.OrderBy {
|
switch account.OrderBy {
|
||||||
case "name":
|
case "name":
|
||||||
{
|
{
|
||||||
|
@ -59,6 +51,24 @@ func SortFiles(files []File, account *Account) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExtractFolder(files []File, account *Account) {
|
||||||
|
if account.ExtractFolder == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
front := account.ExtractFolder == "front"
|
||||||
|
sort.Slice(files, func(i, j int) bool {
|
||||||
|
if files[i].IsDir() || files[j].IsDir() {
|
||||||
|
if !files[i].IsDir() {
|
||||||
|
return !front
|
||||||
|
}
|
||||||
|
if !files[j].IsDir() {
|
||||||
|
return front
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (f File) GetSize() uint64 {
|
func (f File) GetSize() uint64 {
|
||||||
return uint64(f.Size)
|
return uint64(f.Size)
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ func Path(c *gin.Context) {
|
||||||
if driver.Config().LocalSort {
|
if driver.Config().LocalSort {
|
||||||
model.SortFiles(files, account)
|
model.SortFiles(files, account)
|
||||||
}
|
}
|
||||||
|
model.ExtractFolder(files, account)
|
||||||
total, files := Pagination(files, &req)
|
total, files := Pagination(files, &req)
|
||||||
c.JSON(200, common.Resp{
|
c.JSON(200, common.Resp{
|
||||||
Code: 200,
|
Code: 200,
|
||||||
|
|
Loading…
Reference in New Issue