1.5.0
This commit is contained in:
@@ -16,6 +16,8 @@ import (
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type ComponentsAction actions.Action
|
||||
@@ -41,12 +43,7 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
||||
|
||||
var buffer = bytes.NewBuffer([]byte{})
|
||||
|
||||
var webRoot string
|
||||
if Tea.IsTesting() {
|
||||
webRoot = Tea.Root + "/../web/public/js/components/"
|
||||
} else {
|
||||
webRoot = Tea.Root + "/web/public/js/components/"
|
||||
}
|
||||
webRoot := findComponentsRoot()
|
||||
f := files.NewFile(webRoot)
|
||||
|
||||
f.Range(func(file *files.File) {
|
||||
@@ -173,3 +170,27 @@ func (this *ComponentsAction) RunGet(params struct{}) {
|
||||
|
||||
_, _ = this.Write(componentsData)
|
||||
}
|
||||
|
||||
func findComponentsRoot() string {
|
||||
candidates := []string{
|
||||
filepath.Join(Tea.Root, "web", "public", "js", "components"),
|
||||
filepath.Join(Tea.Root, "..", "web", "public", "js", "components"),
|
||||
filepath.Join(Tea.Root, "..", "..", "web", "public", "js", "components"),
|
||||
}
|
||||
|
||||
if cwd, err := os.Getwd(); err == nil && len(cwd) > 0 {
|
||||
candidates = append(candidates,
|
||||
filepath.Join(cwd, "web", "public", "js", "components"),
|
||||
filepath.Join(cwd, "EdgeAdmin", "web", "public", "js", "components"),
|
||||
)
|
||||
}
|
||||
|
||||
for _, candidate := range candidates {
|
||||
info, err := os.Stat(candidate)
|
||||
if err == nil && info.IsDir() {
|
||||
return candidate + string(filepath.Separator)
|
||||
}
|
||||
}
|
||||
|
||||
return filepath.Join(Tea.Root, "web", "public", "js", "components") + string(filepath.Separator)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user