Skip to content

Commit

Permalink
Merge pull request #523 from linthan/adjustwindow
Browse files Browse the repository at this point in the history
feat: 兼容window文件查找
  • Loading branch information
sysulq committed May 5, 2023
2 parents 660240f + eeb322d commit 2391fa0
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 2391fa0

Please sign in to comment.