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",
|
||||
Type: TypeString,
|
||||
},
|
||||
{
|
||||
Name: "extract_folder",
|
||||
Label: "extract_folder",
|
||||
Values: "front,back",
|
||||
Type: TypeSelect,
|
||||
},
|
||||
}, res[k]...)
|
||||
if v.Config().ApiProxy {
|
||||
res[k] = append([]Item{
|
||||
|
|
|
@ -110,7 +110,6 @@ func (driver Native) Files(path string, account *model.Account) ([]model.File, e
|
|||
}
|
||||
files = append(files, file)
|
||||
}
|
||||
model.SortFiles(files, account)
|
||||
return files, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,13 @@ type Account struct {
|
|||
DownProxyUrl string `json:"down_proxy_url"` // 用于中转下载服务的URL 两处 1. path请求中返回的链接 2. down下载时进行302
|
||||
APIProxyUrl string `json:"api_proxy_url"` // 用于中转api的地址
|
||||
// for s3
|
||||
Bucket string `json:"bucket"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Region string `json:"region"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
CustomHost string `json:"custom_host"`
|
||||
Bucket string `json:"bucket"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Region string `json:"region"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessSecret string `json:"access_secret"`
|
||||
CustomHost string `json:"custom_host"`
|
||||
ExtractFolder string `json:"extract_folder"`
|
||||
}
|
||||
|
||||
var accountsMap = map[string]Account{}
|
||||
|
|
|
@ -25,14 +25,6 @@ func SortFiles(files []File, account *Account) {
|
|||
return
|
||||
}
|
||||
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 {
|
||||
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 {
|
||||
return uint64(f.Size)
|
||||
}
|
||||
|
|
|
@ -164,6 +164,7 @@ func Path(c *gin.Context) {
|
|||
if driver.Config().LocalSort {
|
||||
model.SortFiles(files, account)
|
||||
}
|
||||
model.ExtractFolder(files, account)
|
||||
total, files := Pagination(files, &req)
|
||||
c.JSON(200, common.Resp{
|
||||
Code: 200,
|
||||
|
|
Loading…
Reference in New Issue