diff --git a/.gitignore b/.gitignore index 65b4f3dab8b1d301d9057716a27f2141faedbbf9..c0a8f0502b7708155f95ddb85c3156925790109c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ example/www logs/ .idea/ +/demo/sample/ diff --git a/internal/server/modules/v1/utils/script/asset.go b/internal/server/modules/v1/utils/script/asset.go index bc26d172d459db83321af6364246fa32493eedc5..8e563b2409c9dd5b4df62ddd308d61fd8995dbe9 100644 --- a/internal/server/modules/v1/utils/script/asset.go +++ b/internal/server/modules/v1/utils/script/asset.go @@ -23,7 +23,7 @@ func LoadScriptTree(dir string) (asset serverDomain.TestAsset, err error) { commonUtils.ChangeScriptForDebug(&dir) asset = serverDomain.TestAsset{Path: dir, Title: fileUtils.GetDirName(dir), IsDir: true, Slots: iris.Map{"icon": "icon"}} - LoadScriptNodesInDir(dir, &asset) + LoadScriptNodesInDir(dir, &asset, 0) jsn, _ := json.Marshal(asset) logUtils.Infof(string(jsn)) @@ -32,7 +32,7 @@ func LoadScriptTree(dir string) (asset serverDomain.TestAsset, err error) { } func LoadScriptByProject(projectPath string) (scriptFiles []string) { - LoadScriptListInDir(projectPath, &scriptFiles) + LoadScriptListInDir(projectPath, &scriptFiles, 0) return } @@ -43,7 +43,7 @@ func GetScriptContent(pth string) (script model.TestScript, err error) { return } -func LoadScriptNodesInDir(childPath string, parent *serverDomain.TestAsset) (err error) { +func LoadScriptNodesInDir(childPath string, parent *serverDomain.TestAsset, level int) (err error) { if !fileUtils.IsDir(childPath) { // is file addScript(childPath, parent) return @@ -63,10 +63,10 @@ func LoadScriptNodesInDir(childPath string, parent *serverDomain.TestAsset) (err } childPath := childPath + name - if grandson.IsDir() { // 目录, 递归遍历 + if grandson.IsDir() && level < 3 { // 目录, 递归遍历 dirNode := addDir(childPath, parent) - LoadScriptNodesInDir(childPath, dirNode) + LoadScriptNodesInDir(childPath, dirNode, level+1) } else { addScript(childPath, parent) } @@ -75,7 +75,7 @@ func LoadScriptNodesInDir(childPath string, parent *serverDomain.TestAsset) (err return } -func LoadScriptListInDir(path string, files *[]string) error { +func LoadScriptListInDir(path string, files *[]string, level int) error { regx := langUtils.GetSupportLanguageExtRegx() if !fileUtils.IsDir(path) { // first call, param is file @@ -103,8 +103,8 @@ func LoadScriptListInDir(path string, files *[]string) error { continue } - if fi.IsDir() { // 目录, 递归遍历 - LoadScriptListInDir(path+name+consts.PthSep, files) + if fi.IsDir() && level < 3 { // 目录, 递归遍历 + LoadScriptListInDir(path+name+consts.PthSep, files, level+1) } else { path := path + name pass, _ := regexp.MatchString("^*.\\."+regx+"$", path)