提交 78fbe0ab 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

get interpreter info by lang

上级 e835964b
......@@ -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
......
......@@ -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()))
......
......@@ -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
......
......@@ -9,13 +9,19 @@
</template>
<template #extra>
<a-button type="primary" @click="create()">
<a-button v-if="interpreters" @click="create()" type="primary">
<template #icon><PlusCircleOutlined /></template>
{{t('create_interpreter')}}
</a-button>
</template>
<div v-if="!interpreters" style="padding: 20px;">
非Windows平台中,请参照<a-link to="https://ztf.im/book/ztf/ztf-about-26.html">此文</a-link>将可执行文件加入PATH变量中,
即可在任意目录中执行测试,不需要为各种语言设置运行环境。
</div>
<a-table
v-if="interpreters"
row-key="id"
:columns="columns"
:data-source="interpreters"
......@@ -68,6 +74,7 @@ import EditInterpreterForm from './component/edit.vue';
import {getLangSettings} from "./service";
import {listInterpreter, removeInterpreter} from "@/views/interpreter/service";
import {momentUtcDef} from "@/utils/datetime";
import ALink from "@/components/ALink/index.vue";
interface InterpreterListSetupData {
t: (key: string | number) => string;
......@@ -94,6 +101,7 @@ interface InterpreterListSetupData {
export default defineComponent({
name: 'InterpreterList',
components: {
ALink,
EditInterpreterForm, PlusCircleOutlined,
},
setup(props): InterpreterListSetupData {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册