diff --git a/easyjs/webjs/js.go b/easyjs/webjs/js.go index 1e79c7959160d036a2cce7bd8608749bfcdfd915..8e67d4f22c922c84485c254a08657c7698246302 100644 --- a/easyjs/webjs/js.go +++ b/easyjs/webjs/js.go @@ -222,12 +222,31 @@ func (m *JsController) List() { ifs := make([]*Tree, 0, len(fi)) for _, f := range fi { if f.IsDir() { - continue + cfi, err := os.ReadDir(path + f.Name()) + if err != nil { + m.Error(err.Error()) + return + } + cifs := make([]*Tree, 0, len(cfi)) + for _, cf := range cfi { + cinf := new(Tree) + cinf.Label = cf.Name() + cinf.ID = f.Name() + "/" + cf.Name() + cifs = append(cifs, cinf) + } + ifs = append(ifs, &Tree{ + ID: f.Name(), + Label: f.Name(), + Children: cifs, + }) + + }else{ + inf := new(Tree) + inf.Label = f.Name() + inf.ID = f.Name() + ifs = append(ifs, inf) } - inf := new(Tree) - inf.Label = f.Name() - inf.ID = f.Name() - ifs = append(ifs, inf) + } m.JSON(http.StatusOK, ifs) }