From a18dcc0a78d8ce38b0476def5ad02c277dbace6a Mon Sep 17 00:00:00 2001 From: meowrain Date: Sun, 16 Jun 2024 09:31:03 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main.go | 3 ++- static/embed.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 static/embed.go diff --git a/cmd/main.go b/cmd/main.go index 77a4e55..8793854 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,6 +7,7 @@ import ( "localsend_cli/internal/discovery" "localsend_cli/internal/handlers" "localsend_cli/internal/pkg/server" + "localsend_cli/static" "log" "net/http" "os" @@ -30,7 +31,7 @@ func main() { //如果启用http文件服务器,启用下面的路由 httpServer.HandleFunc("/", handlers.IndexFileHandler) httpServer.HandleFunc("/uploads/", handlers.FileServerHandler) - httpServer.Handle("/static/", http.FileServer(http.Dir("."))) + httpServer.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(static.EmbeddedStaticFiles)))) } /*发送接收部分*/ if config.ConfigData.Functions.LocalSendServer { diff --git a/static/embed.go b/static/embed.go new file mode 100644 index 0000000..9f20ccb --- /dev/null +++ b/static/embed.go @@ -0,0 +1,6 @@ +package static + +import "embed" + +//go:embed * +var EmbeddedStaticFiles embed.FS