修复 debug 模式下静态文件路径问题
This commit is contained in:
+11
-1
@@ -4,6 +4,8 @@ import (
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"next-terminal/server/api"
|
||||
"next-terminal/server/api/worker"
|
||||
@@ -19,7 +21,15 @@ import (
|
||||
func getFS(useOS bool) fs.FS {
|
||||
if useOS {
|
||||
log.Debug("using live mode")
|
||||
return os.DirFS("web/build")
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
panic("failed to get caller info")
|
||||
}
|
||||
appDir := filepath.Dir(filename)
|
||||
baseDir := filepath.Dir(filepath.Dir(appDir))
|
||||
webBuildPath := filepath.Join(baseDir, "web", "build")
|
||||
log.Debug("web build path: " + webBuildPath)
|
||||
return os.DirFS(webBuildPath)
|
||||
}
|
||||
|
||||
log.Debug("using embed mode")
|
||||
|
||||
Reference in New Issue
Block a user