diff --git a/internal/comm/consts/enum.go b/internal/comm/consts/enum.go index 1a4c1ef343c3e4dc69be87bf939a969c241c8d13..f2229206322f00ad3c1b8d0e063b00674e8599fe 100644 --- a/internal/comm/consts/enum.go +++ b/internal/comm/consts/enum.go @@ -14,6 +14,7 @@ var ( NeedInitErr = ResponseCode{1000, "data not init"} BizErrZentaoRequest = ResponseCode{2000, "zentao request err"} BizErrNameNotExist = ResponseCode{3000, "record not found"} + NotAvailable = ResponseCode{4000, "not available"} ) type ResultStatus string diff --git a/internal/server/modules/v1/controller/interpreter.go b/internal/server/modules/v1/controller/interpreter.go index 9f0fe2160ccdcaa103a18000f7f82a12ff72046a..bf5f685cfb58aa24843da1dedacba744e845633d 100644 --- a/internal/server/modules/v1/controller/interpreter.go +++ b/internal/server/modules/v1/controller/interpreter.go @@ -2,6 +2,7 @@ package controller import ( commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts" + commonUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/common" "github.com/aaronchen2k/deeptest/internal/server/modules/v1/model" "github.com/aaronchen2k/deeptest/internal/server/modules/v1/service" "github.com/kataras/iris/v12" @@ -39,6 +40,11 @@ func (c *InterpreterCtrl) GetLangInterpreter(ctx iris.Context) { } func (c *InterpreterCtrl) List(ctx iris.Context) { + if !commonUtils.IsWin() { + ctx.JSON(c.SuccessResp(nil)) + return + } + data, err := c.InterpreterService.List() if err != nil { ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error())) diff --git a/internal/server/modules/v1/service/interpreter.go b/internal/server/modules/v1/service/interpreter.go index 77a8814d884f67cb455cb4ce3b8fdb99310d043f..e1c2127031379f729c13877058718d38a6aefe01 100644 --- a/internal/server/modules/v1/service/interpreter.go +++ b/internal/server/modules/v1/service/interpreter.go @@ -5,6 +5,7 @@ import ( "fmt" commConsts "github.com/aaronchen2k/deeptest/internal/comm/consts" langHelper "github.com/aaronchen2k/deeptest/internal/comm/helper/lang" + commonUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/common" fileUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/file" shellUtils "github.com/aaronchen2k/deeptest/internal/pkg/lib/shell" "github.com/aaronchen2k/deeptest/internal/server/modules/v1/model" @@ -54,16 +55,23 @@ func (s *InterpreterService) Delete(id uint) error { } func (s *InterpreterService) GetLangSettings() (mp map[string]interface{}, err error) { - langs := langHelper.GetSupportLanguageArrSort() + allLangs := langHelper.GetSupportLanguageArrSort() + langs := []string{} mpData := map[string]map[string]string{} - for _, lang := range langs { + for _, lang := range allLangs { + mp := commConsts.LangMap[lang] + if mp["interpreter"] == "" { + continue + } + subMap := map[string]string{ - "name": commConsts.LangMap[lang]["name"], - "interpreter": commConsts.LangMap[lang]["interpreter"], - "versionCmd": commConsts.LangMap[lang]["versionCmd"], + "name": mp["name"], + "interpreter": mp["interpreter"], + "versionCmd": mp["versionCmd"], } mpData[lang] = subMap + langs = append(langs, lang) } mp = map[string]interface{}{} @@ -74,6 +82,8 @@ func (s *InterpreterService) GetLangSettings() (mp map[string]interface{}, err e } func (s *InterpreterService) GetLangInterpreter(language string) (mp map[string]interface{}, err error) { + mp = map[string]interface{}{} + langSettings := commConsts.LangMap[language] whereCmd := strings.TrimSpace(langSettings["whereCmd"]) versionCmd := strings.TrimSpace(langSettings["versionCmd"]) @@ -81,7 +91,7 @@ func (s *InterpreterService) GetLangInterpreter(language string) (mp map[string] path := langSettings["interpreter"] info := "" - if whereCmd == "" { + if !commonUtils.IsWin() || whereCmd == "" { return } @@ -97,7 +107,6 @@ func (s *InterpreterService) GetLangInterpreter(language string) (mp map[string] return } - mp = map[string]interface{}{} mp["path"] = path mp["info"] = info diff --git a/ui/src/views/interpreter/index.vue b/ui/src/views/interpreter/index.vue index 8013c4430a978f51ea405bf86b362cead9267a35..5aea40cc780318bb68fb83dc0a67515ab1982b41 100644 --- a/ui/src/views/interpreter/index.vue +++ b/ui/src/views/interpreter/index.vue @@ -9,13 +9,19 @@ +
+ 非Windows平台中,请参照此文将可执行文件加入PATH变量中, + 即可在任意目录中执行测试,不需要为各种语言设置运行环境。 +
+ string; @@ -94,6 +101,7 @@ interface InterpreterListSetupData { export default defineComponent({ name: 'InterpreterList', components: { + ALink, EditInterpreterForm, PlusCircleOutlined, }, setup(props): InterpreterListSetupData {