Skip to content

Commit eeb322d

Browse files
author
fusikai
committed
兼容window
1 parent 660240f commit eeb322d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

api/apiv1/static/filesystem.go

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ func (d Dir) Exists(name string) bool {
2828
}
2929
fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))
3030
fullName = strings.TrimPrefix(fullName, strings.TrimPrefix(Prefix, "/"))
31+
fullName = strings.TrimPrefix(fullName, string(filepath.Separator))
32+
fullName = strings.ReplaceAll(fullName, "\\", "/")
3133
_, err := statikFS.Open(fullName)
3234
return err == nil
3335
}
@@ -38,7 +40,10 @@ func (d Dir) Open(name string) (http.File, error) {
3840
if dir == "" {
3941
dir = "."
4042
}
43+
4144
fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))
4245
fullName = strings.TrimPrefix(fullName, strings.TrimPrefix(Prefix, "/"))
46+
fullName = strings.TrimPrefix(fullName, string(filepath.Separator))
47+
fullName = strings.ReplaceAll(fullName, "\\", "/")
4348
return statikFS.Open(fullName)
4449
}

assets/assets.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ package assets
55

66
import (
77
"net/http"
8+
"path/filepath"
89
)
910

1011
var AssetsEmbedded = false
1112

1213
func Assets() (http.FileSystem, error) {
13-
return http.Dir("./assets/dist"), nil
14+
pathDir := filepath.Join(".", "assets", "dist")
15+
return http.Dir(pathDir), nil
1416
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy