added support for yadownloader

This commit is contained in:
huangjx 2022-07-20 20:54:07 +08:00
parent f80b016ef0
commit 8dcd72d3b8
2 changed files with 22 additions and 0 deletions

View File

@ -2,6 +2,11 @@
<div> <div>
<header-bar showMenu showLogo> <header-bar showMenu showLogo>
<search /> <title /> <search /> <title />
<action
icon="storage"
:label="$t('yadownloader')"
@action="redirect"
/>
<action <action
class="search-button" class="search-button"
icon="search" icon="search"
@ -437,6 +442,10 @@ export default {
document.removeEventListener("drop", this.drop); document.removeEventListener("drop", this.drop);
}, },
methods: { methods: {
redirect(){
let url = "/downloader";
window.location.href = url;
},
...mapMutations(["updateUser", "addSelected"]), ...mapMutations(["updateUser", "addSelected"]),
base64: function (name) { base64: function (name) {
return window.btoa(unescape(encodeURIComponent(name))); return window.btoa(unescape(encodeURIComponent(name)));

View File

@ -2,12 +2,14 @@ package http
import ( import (
"io/fs" "io/fs"
"log"
"net/http" "net/http"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage" "github.com/filebrowser/filebrowser/v2/storage"
downloader "github.com/shiningw/yadownloader/http"
) )
type modifyRequest struct { type modifyRequest struct {
@ -85,5 +87,16 @@ func NewHandler(
public.PathPrefix("/dl").Handler(monkey(publicDlHandler, "/api/public/dl/")).Methods("GET") public.PathPrefix("/dl").Handler(monkey(publicDlHandler, "/api/public/dl/")).Methods("GET")
public.PathPrefix("/share").Handler(monkey(publicShareHandler, "/api/public/share/")).Methods("GET") public.PathPrefix("/share").Handler(monkey(publicShareHandler, "/api/public/share/")).Methods("GET")
settings, err := store.Settings.Get()
if err != nil {
log.Fatalf("ERROR: couldn't get settings: %v\n", err)
}
data := &downloader.Data{
Settings: settings,
Server: server,
}
downloader.RegisterRoutes(r, data)
return stripPrefix(server.BaseURL, r), nil return stripPrefix(server.BaseURL, r), nil
} }