Skip to content

Commit

Permalink
兼容window
Browse files Browse the repository at this point in the history
  • Loading branch information
fusikai committed May 5, 2023
1 parent 660240f commit eeb322d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/apiv1/static/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func (d Dir) Exists(name string) bool {
}
fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))
fullName = strings.TrimPrefix(fullName, strings.TrimPrefix(Prefix, "/"))
fullName = strings.TrimPrefix(fullName, string(filepath.Separator))
fullName = strings.ReplaceAll(fullName, "\\", "/")
_, err := statikFS.Open(fullName)
return err == nil
}
Expand All @@ -38,7 +40,10 @@ func (d Dir) Open(name string) (http.File, error) {
if dir == "" {
dir = "."
}

fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name)))
fullName = strings.TrimPrefix(fullName, strings.TrimPrefix(Prefix, "/"))
fullName = strings.TrimPrefix(fullName, string(filepath.Separator))
fullName = strings.ReplaceAll(fullName, "\\", "/")
return statikFS.Open(fullName)
}
4 changes: 3 additions & 1 deletion assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ package assets

import (
"net/http"
"path/filepath"
)

var AssetsEmbedded = false

func Assets() (http.FileSystem, error) {
return http.Dir("./assets/dist"), nil
pathDir := filepath.Join(".", "assets", "dist")
return http.Dir(pathDir), nil
}

0 comments on commit eeb322d

Please sign in to comment.