Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
cd79b4ea
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
12 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cd79b4ea
编写于
3月 14, 2022
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update to use new rest api
上级
eff96181
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
220 addition
and
144 deletion
+220
-144
internal/comm/domain/testing.go
internal/comm/domain/testing.go
+35
-32
internal/comm/helper/script/generator.go
internal/comm/helper/script/generator.go
+6
-6
internal/comm/helper/zentao/case.go
internal/comm/helper/zentao/case.go
+23
-36
internal/comm/helper/zentao/zentao.go
internal/comm/helper/zentao/zentao.go
+0
-19
internal/pkg/lib/http/http.go
internal/pkg/lib/http/http.go
+6
-38
internal/server/modules/v1/service/sync.go
internal/server/modules/v1/service/sync.go
+1
-2
ui/package.json
ui/package.json
+0
-2
ui/src/components/Editor/MonacoEditor.vue
ui/src/components/Editor/MonacoEditor.vue
+132
-0
ui/src/utils/const.ts
ui/src/utils/const.ts
+10
-1
ui/src/views/script/index/main.vue
ui/src/views/script/index/main.vue
+7
-7
ui/vue.config.js
ui/vue.config.js
+0
-1
未找到文件。
internal/comm/domain/testing.go
浏览文件 @
cd79b4ea
...
...
@@ -8,79 +8,82 @@ import (
"time"
)
type
ZtfRespTestCases
struct
{
Cases
[]
ZtfCaseInModule
`json:"testcases"`
}
type
ZtfProduct
struct
{
Id
string
Code
string
Name
string
Id
int
//
Code string
//
Name string
Cases
map
[
int
]
ZtfCaseInModule
Cases
map
[
int
]
ZtfCaseInModule
`json:"testcases"`
}
type
ZtfModule
struct
{
Id
string
Code
string
Nam
e
string
Id
int
Code
string
Titl
e
string
Cases
map
[
int
]
ZtfCaseInModule
}
type
ZtfCaseInModule
struct
{
Id
string
Id
int
Title
string
Product
string
Module
string
Product
int
Module
int
}
type
ZtfSuite
struct
{
Id
string
Id
int
Code
string
Name
string
Product
string
Product
int
Cases
map
[
int
]
ZtfCaseInSuite
}
type
ZtfCaseInSuite
struct
{
Id
string
Id
int
Title
string
Product
string
Suite
string
Module
string
Product
int
Suite
int
Module
int
}
type
ZtfTask
struct
{
Id
string
Id
int
Code
string
Name
string
Product
string
Project
string
Product
int
Project
int
Runs
map
[
int
]
ZtfCaseInTask
}
type
ZtfCaseInTask
struct
{
Id
string
// runId in task
Id
int
// runId in task
Title
string
Case
string
// real caseId
Product
string
Module
string
Case
int
// real caseId
Product
int
Module
int
}
type
ZtfCaseNoStepArr
struct
{
Id
string
Product
string
Module
string
Id
int
Product
int
Module
int
Title
string
Steps
map
[
int
]
ZtfStep
}
type
ZtfCase
struct
{
Id
string
Product
string
Module
string
Id
int
Product
int
Module
int
Title
string
Steps
map
[
int
]
ZtfStep
StepArr
[]
ZtfStep
`json tag -`
Title
string
Steps
[]
ZtfStep
`json:"steps"`
}
type
ZtfCaseWrapper
struct
{
From
string
...
...
internal/comm/helper/script/generator.go
浏览文件 @
cd79b4ea
...
...
@@ -42,20 +42,20 @@ func GenerateScript(cs commDomain.ZtfCase, langType string, independentFile bool
caseTitle
:=
cs
.
Title
if
byModule
{
targetDir
=
filepath
.
Join
(
targetDir
,
moduleId
)
targetDir
=
filepath
.
Join
(
targetDir
,
strconv
.
Itoa
(
moduleId
)
)
}
fileUtils
.
MkDirIfNeeded
(
targetDir
)
content
:=
""
isOldFormat
:=
false
scriptFile
:=
filepath
.
Join
(
targetDir
,
fmt
.
Sprintf
(
"%
s
.%s"
,
caseId
,
langUtils
.
LangMap
[
langType
][
"extName"
]))
scriptFile
:=
filepath
.
Join
(
targetDir
,
fmt
.
Sprintf
(
"%
d
.%s"
,
caseId
,
langUtils
.
LangMap
[
langType
][
"extName"
]))
if
fileUtils
.
FileExist
(
scriptFile
)
{
// update title and steps
content
=
fileUtils
.
ReadFile
(
scriptFile
)
isOldFormat
=
strings
.
Index
(
content
,
"[esac]"
)
>
-
1
}
*
caseIds
=
append
(
*
caseIds
,
caseId
)
*
caseIds
=
append
(
*
caseIds
,
strconv
.
Itoa
(
caseId
)
)
info
:=
make
([]
string
,
0
)
steps
:=
make
([]
string
,
0
)
...
...
@@ -69,12 +69,12 @@ func GenerateScript(cs commDomain.ZtfCase, langType string, independentFile bool
StepWidth
:=
20
stepDisplayMaxWidth
:=
0
computerTestStepWidth
(
cs
.
Step
Arr
,
&
stepDisplayMaxWidth
,
StepWidth
)
computerTestStepWidth
(
cs
.
Step
s
,
&
stepDisplayMaxWidth
,
StepWidth
)
if
isOldFormat
{
generateTestStepAndScriptObsolete
(
cs
.
Step
Arr
,
&
steps
,
&
independentExpects
,
independentFile
)
generateTestStepAndScriptObsolete
(
cs
.
Step
s
,
&
steps
,
&
independentExpects
,
independentFile
)
}
else
{
generateTestStepAndScript
(
cs
.
Step
Arr
,
&
steps
,
&
independentExpects
,
independentFile
)
generateTestStepAndScript
(
cs
.
Step
s
,
&
steps
,
&
independentExpects
,
independentFile
)
}
info
=
append
(
info
,
strings
.
Join
(
steps
,
"
\n
"
))
...
...
internal/comm/helper/zentao/case.go
浏览文件 @
cd79b4ea
...
...
@@ -54,8 +54,7 @@ func GetCasesByModule(productId int, moduleId int, projectPath, scriptDir string
testcases
:=
ListCaseByModule
(
config
.
Url
,
productId
,
moduleId
)
zentaoCaseIdMap
:=
map
[
int
]
string
{}
for
_
,
tc
:=
range
testcases
{
id
,
_
:=
strconv
.
Atoi
(
tc
.
Id
)
zentaoCaseIdMap
[
id
]
=
""
zentaoCaseIdMap
[
tc
.
Id
]
=
""
}
//commonUtils.ChangeScriptForDebug(&projectPath)
...
...
@@ -77,8 +76,7 @@ func GetCasesBySuite(productId int, suiteId int, projectPath, scriptDir string)
caseIdMap
:=
map
[
int
]
string
{}
for
_
,
tc
:=
range
testcases
{
id
,
_
:=
strconv
.
Atoi
(
tc
.
Id
)
caseIdMap
[
id
]
=
""
caseIdMap
[
tc
.
Id
]
=
""
}
//commonUtils.ChangeScriptForDebug(&projectPath)
...
...
@@ -100,8 +98,7 @@ func GetCasesByTask(productId int, taskId int, projectPath, scriptDir string) (c
caseIdMap
:=
map
[
int
]
string
{}
for
_
,
tc
:=
range
testcases
{
id
,
_
:=
strconv
.
Atoi
(
tc
.
Id
)
caseIdMap
[
id
]
=
""
caseIdMap
[
tc
.
Id
]
=
""
}
//commonUtils.ChangeScriptForDebug(&projectPath)
...
...
@@ -110,38 +107,28 @@ func GetCasesByTask(productId int, taskId int, projectPath, scriptDir string) (c
return
}
func
ListCaseByProduct
(
baseUrl
string
,
productId
int
)
[]
commDomain
.
ZtfCase
{
// $productID=productId, $branch = '', $browseType = 'byModule', $param=moduleId,
// $orderBy='id_desc', $recTotal=0, $recPerPage=10000, $pageID=1)
params
:=
""
if
commConsts
.
RequestType
==
commConsts
.
PathInfo
{
params
=
fmt
.
Sprintf
(
"%d--byModule-all-id_asc-0-10000-1"
,
productId
)
}
else
{
params
=
fmt
.
Sprintf
(
"productID=%d&branch=&browseType=byModule¶m=0&orderBy=id_desc&recTotal=0&recPerPage=10000"
,
productId
)
}
func
ListCaseByProduct
(
baseUrl
string
,
productId
int
)
(
caseArr
[]
commDomain
.
ZtfCase
)
{
uri
:=
fmt
.
Sprintf
(
"/products/%d/testcases"
,
productId
)
url
:=
GenApiUrl
(
uri
,
nil
,
baseUrl
)
url
:=
baseUrl
+
GenApiUriOld
(
"testcase"
,
"browse"
,
params
)
dataStr
,
err
:=
httpUtils
.
Get
(
url
)
if
err
!=
nil
{
return
}
if
err
==
nil
{
var
product
commDomain
.
ZtfProduct
json
.
Unmarshal
(
dataStr
,
&
product
)
caseArr
:=
make
([]
commDomain
.
ZtfCase
,
0
)
for
_
,
cs
:=
range
product
.
Cases
{
caseId
:=
cs
.
Id
var
cases
commDomain
.
ZtfRespTestCases
json
.
Unmarshal
(
dataStr
,
&
cases
)
csWithSteps
:=
GetCaseById
(
baseUrl
,
caseId
)
stepArr
:=
genCaseSteps
(
csWithSteps
)
caseArr
=
append
(
caseArr
,
commDomain
.
ZtfCase
{
Id
:
caseId
,
Product
:
cs
.
Product
,
Module
:
cs
.
Module
,
Title
:
cs
.
Title
,
StepArr
:
stepArr
})
}
for
_
,
cs
:=
range
cases
.
Cases
{
caseId
:=
cs
.
Id
return
caseArr
csWithSteps
:=
GetCaseById
(
baseUrl
,
caseId
)
stepArr
:=
genCaseSteps
(
csWithSteps
)
caseArr
=
append
(
caseArr
,
commDomain
.
ZtfCase
{
Id
:
caseId
,
Product
:
cs
.
Product
,
Module
:
cs
.
Module
,
Title
:
cs
.
Title
,
Steps
:
stepArr
})
}
return
nil
return
caseArr
}
func
ListCaseByModule
(
baseUrl
string
,
productId
,
moduleId
int
)
[]
commDomain
.
ZtfCase
{
...
...
@@ -171,7 +158,7 @@ func ListCaseByModule(baseUrl string, productId, moduleId int) []commDomain.ZtfC
stepArr
:=
genCaseSteps
(
csWithSteps
)
caseArr
=
append
(
caseArr
,
commDomain
.
ZtfCase
{
Id
:
caseId
,
Product
:
cs
.
Product
,
Module
:
cs
.
Module
,
Title
:
cs
.
Title
,
Step
Arr
:
stepArr
})
Title
:
cs
.
Title
,
Step
s
:
stepArr
})
}
return
caseArr
...
...
@@ -205,7 +192,7 @@ func ListCaseBySuite(baseUrl string, productId, suiteId int) []commDomain.ZtfCas
stepArr
:=
genCaseSteps
(
csWithSteps
)
caseArr
=
append
(
caseArr
,
commDomain
.
ZtfCase
{
Id
:
caseId
,
Product
:
cs
.
Product
,
Module
:
cs
.
Module
,
Title
:
cs
.
Title
,
Step
Arr
:
stepArr
})
Title
:
cs
.
Title
,
Step
s
:
stepArr
})
}
return
caseArr
...
...
@@ -240,7 +227,7 @@ func ListCaseByTask(baseUrl string, productId, taskId int) []commDomain.ZtfCase
stepArr
:=
genCaseSteps
(
csWithSteps
)
caseArr
=
append
(
caseArr
,
commDomain
.
ZtfCase
{
Id
:
caseId
,
Product
:
cs
.
Product
,
Module
:
cs
.
Module
,
Title
:
cs
.
Title
,
Step
Arr
:
stepArr
})
Title
:
cs
.
Title
,
Step
s
:
stepArr
})
}
return
caseArr
...
...
@@ -265,8 +252,8 @@ func genCaseSteps(csWithSteps commDomain.ZtfCase) (ret []commDomain.ZtfStep) {
return
}
func
GetCaseById
(
baseUrl
string
,
caseId
string
)
(
cs
commDomain
.
ZtfCase
)
{
uri
:=
fmt
.
Sprintf
(
"/testcases/%
s
"
,
caseId
)
func
GetCaseById
(
baseUrl
string
,
caseId
int
)
(
cs
commDomain
.
ZtfCase
)
{
uri
:=
fmt
.
Sprintf
(
"/testcases/%
d
"
,
caseId
)
url
:=
GenApiUrl
(
uri
,
nil
,
baseUrl
)
bytes
,
err
:=
httpUtils
.
Get
(
url
)
...
...
internal/comm/helper/zentao/zentao.go
浏览文件 @
cd79b4ea
...
...
@@ -36,29 +36,10 @@ func GetConfig(baseUrl string) (err error) {
commConsts
.
RequestType
=
requestType
commConsts
.
RequestFix
,
_
=
json
.
Get
(
"requestFix"
)
.
String
()
// check site path by calling login interface
uri
:=
""
if
commConsts
.
RequestType
==
commConsts
.
PathInfo
{
uri
=
"user-login.json"
}
else
{
uri
=
"index.php?m=user&f=login&t=json"
}
url
=
baseUrl
+
uri
bytes
,
err
=
httpUtils
.
Get
(
url
)
if
err
!=
nil
{
return
}
return
}
func
Login
(
config
commDomain
.
ProjectConf
)
(
err
error
)
{
err
=
GetConfig
(
config
.
Url
)
if
err
!=
nil
{
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"fail_to_login"
))
return
}
url
:=
GenApiUrl
(
"tokens"
,
nil
,
config
.
Url
)
params
:=
map
[
string
]
string
{
...
...
internal/pkg/lib/http/http.go
浏览文件 @
cd79b4ea
...
...
@@ -10,7 +10,6 @@ import (
serverDomain
"github.com/aaronchen2k/deeptest/internal/server/modules/v1/domain"
"github.com/ajg/form"
"github.com/fatih/color"
"github.com/yosssi/gohtml"
"io/ioutil"
"net/http"
"regexp"
...
...
@@ -35,12 +34,13 @@ func Get(url string) (ret []byte, err error) {
}
resp
,
err
:=
client
.
Do
(
req
)
defer
resp
.
Body
.
Close
()
if
err
!=
nil
{
logUtils
.
Infof
(
color
.
RedString
(
"get request failed, error: %s."
,
err
.
Error
()))
return
}
bodyBytes
,
err
:
=
ioutil
.
ReadAll
(
resp
.
Body
)
ret
,
err
=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
logUtils
.
Infof
(
color
.
RedString
(
"read response failed, error "
,
err
.
Error
()))
return
...
...
@@ -48,36 +48,7 @@ func Get(url string) (ret []byte, err error) {
if
commConsts
.
Verbose
{
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_response"
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
bodyBytes
))
}
defer
resp
.
Body
.
Close
()
var
zentaoResp
serverDomain
.
ZentaoResp
err
=
json
.
Unmarshal
(
bodyBytes
,
&
zentaoResp
)
if
err
!=
nil
{
if
strings
.
Index
(
string
(
bodyBytes
),
"<html>"
)
>
-
1
{
if
commConsts
.
Verbose
{
logUtils
.
Errorf
(
i118Utils
.
Sprintf
(
"request_response"
)
+
" HTML - "
+
gohtml
.
FormatWithLineNo
(
string
(
bodyBytes
)))
}
return
}
else
{
if
commConsts
.
Verbose
{
logUtils
.
Infof
(
color
.
RedString
(
"unmarshal response failed, error: %s."
,
err
.
Error
()))
}
return
}
}
defer
resp
.
Body
.
Close
()
status
:=
zentaoResp
.
Status
if
status
==
""
{
// 非嵌套结构
ret
=
bodyBytes
}
else
{
// 嵌套结构
ret
=
[]
byte
(
zentaoResp
.
Data
)
if
status
!=
"success"
{
err
=
errors
.
New
(
zentaoResp
.
Data
)
}
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
ret
))
}
return
...
...
@@ -119,7 +90,8 @@ func Post(url string, data interface{}) (ret []byte, err error) {
return
}
bodyBytes
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
ret
,
err
=
ioutil
.
ReadAll
(
resp
.
Body
)
defer
resp
.
Body
.
Close
()
if
err
!=
nil
{
logUtils
.
Infof
(
color
.
RedString
(
"read response failed, error: %s."
,
err
.
Error
()))
return
...
...
@@ -127,13 +99,9 @@ func Post(url string, data interface{}) (ret []byte, err error) {
if
commConsts
.
Verbose
{
logUtils
.
Infof
(
i118Utils
.
Sprintf
(
"request_response"
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
bodyBytes
))
logUtils
.
Infof
(
logUtils
.
ConvertUnicode
(
ret
))
}
defer
resp
.
Body
.
Close
()
ret
,
err
=
GetRespErr
(
bodyBytes
,
url
)
return
}
...
...
internal/server/modules/v1/service/sync.go
浏览文件 @
cd79b4ea
...
...
@@ -12,7 +12,6 @@ import (
logUtils
"github.com/aaronchen2k/deeptest/internal/pkg/lib/log"
"github.com/fatih/color"
"path/filepath"
"strconv"
)
type
SyncService
struct
{
...
...
@@ -42,7 +41,7 @@ func (s *SyncService) SyncFromZentao(settings commDomain.SyncSettings, projectPa
cases
,
loginFail
:=
s
.
TestCaseService
.
LoadTestCases
(
productId
,
moduleId
,
suiteId
,
taskId
,
projectPath
)
if
cases
!=
nil
&&
len
(
cases
)
>
0
{
productId
,
_
=
strconv
.
Atoi
(
cases
[
0
]
.
Product
)
productId
=
cases
[
0
]
.
Product
targetDir
:=
fileUtils
.
AddPathSepIfNeeded
(
filepath
.
Join
(
projectPath
,
fmt
.
Sprintf
(
"product%d"
,
productId
)))
count
,
err
:=
s
.
TestScriptService
.
GenerateScripts
(
cases
,
lang
,
independentFile
,
byModule
,
targetDir
)
...
...
ui/package.json
浏览文件 @
cd79b4ea
...
...
@@ -11,7 +11,6 @@
"svgo"
:
"svgo -f src/assets/iconsvg --config=src/assets/iconsvg/svgo.yml"
},
"dependencies"
:
{
"@highlightjs/vue-plugin"
:
"2.0.1"
,
"@toast-ui/editor"
:
"^2.5.3"
,
"ant-design-vue"
:
"^2.2.8"
,
"axios"
:
"^0.21.4"
,
...
...
@@ -21,7 +20,6 @@
"lodash.debounce"
:
"^4.0.8"
,
"lodash.throttle"
:
"^4.1.1"
,
"monaco-editor"
:
"^0.25.2"
,
"monaco-editor-vue3"
:
"^0.1.5"
,
"monaco-editor-webpack-plugin"
:
"^6.0.0"
,
"neffos.js"
:
"^0.1.25"
,
"nprogress"
:
"^0.2.0"
,
...
...
ui/src/components/Editor/MonacoEditor.vue
0 → 100644
浏览文件 @
cd79b4ea
<
template
>
<div
class=
"monaco-editor-vue3"
:style=
"style"
></div>
</
template
>
<
script
>
import
{
defineComponent
,
computed
,
toRefs
}
from
'
vue
'
import
*
as
monaco
from
'
monaco-editor
'
export
default
defineComponent
({
name
:
"
MonacoEditor
"
,
props
:
{
diffEditor
:
{
type
:
Boolean
,
default
:
false
},
width
:
{
type
:
[
String
,
Number
],
default
:
'
100%
'
},
height
:
{
type
:
[
String
,
Number
],
default
:
'
100%
'
},
original
:
String
,
value
:
String
,
language
:
{
type
:
String
,
default
:
'
javascript
'
},
theme
:
{
type
:
String
,
default
:
'
vs
'
},
options
:
{
type
:
Object
,
default
()
{
return
{};}},
},
emits
:
[
'
editorWillMount
'
,
'
editorDidMount
'
,
'
change
'
],
setup
(
props
){
const
{
width
,
height
}
=
toRefs
(
props
)
const
style
=
computed
(()
=>
{
const
fixedWidth
=
width
.
value
.
toString
().
includes
(
'
%
'
)
?
width
.
value
:
`
${
width
.
value
}
px`
const
fixedHeight
=
height
.
value
.
toString
().
includes
(
'
%
'
)?
height
.
value
:
`
${
height
.
value
}
px`
return
{
width
:
fixedWidth
,
height
:
fixedHeight
,
'
text-align
'
:
'
left
'
}
})
return
{
style
}
},
mounted
()
{
this
.
initMonaco
()
},
beforeUnmount
()
{
this
.
editor
&&
this
.
editor
.
dispose
();
},
methods
:
{
initMonaco
(){
this
.
$emit
(
'
editorWillMount
'
,
this
.
monaco
)
const
{
value
,
language
,
theme
,
options
}
=
this
;
Object
.
assign
(
options
,
{
scrollbar
:
{
useShadows
:
false
,
verticalScrollbarSize
:
6
,
horizontalScrollbarSize
:
6
}})
this
.
editor
=
monaco
.
editor
[
this
.
diffEditor
?
'
createDiffEditor
'
:
'
create
'
](
this
.
$el
,
{
value
:
value
,
language
:
language
,
theme
:
theme
,
...
options
});
this
.
diffEditor
&&
this
.
_setModel
(
this
.
value
,
this
.
original
);
// @event `change`
const
editor
=
this
.
_getEditor
()
editor
.
onDidChangeModelContent
(
event
=>
{
const
value
=
editor
.
getValue
()
if
(
this
.
value
!==
value
)
{
this
.
$emit
(
'
change
'
,
value
,
event
)
}
})
this
.
$emit
(
'
editorDidMount
'
,
this
.
editor
)
setTimeout
(()
=>
{
editor
.
getAction
(
'
editor.action.formatDocument
'
).
run
()
},
100
)
},
_setModel
(
value
,
original
)
{
const
{
language
}
=
this
;
const
originalModel
=
monaco
.
editor
.
createModel
(
original
,
language
);
const
modifiedModel
=
monaco
.
editor
.
createModel
(
value
,
language
);
this
.
editor
.
setModel
({
original
:
originalModel
,
modified
:
modifiedModel
});
},
_setValue
(
value
)
{
let
editor
=
this
.
_getEditor
();
if
(
editor
)
return
editor
.
setValue
(
value
);
},
_getValue
()
{
let
editor
=
this
.
_getEditor
();
if
(
!
editor
)
return
''
;
return
editor
.
getValue
();
},
_getEditor
()
{
if
(
!
this
.
editor
)
return
null
;
return
this
.
diffEditor
?
this
.
editor
.
modifiedEditor
:
this
.
editor
;
},
_setOriginal
(){
const
{
original
}
=
this
.
editor
.
getModel
()
original
.
setValue
(
this
.
original
)
}
},
watch
:
{
options
:
{
deep
:
true
,
handler
(
options
)
{
this
.
editor
.
updateOptions
(
options
);
}
},
value
()
{
this
.
value
!==
this
.
_getValue
()
&&
this
.
_setValue
(
this
.
value
);
},
original
()
{
this
.
_setOriginal
()
},
language
()
{
if
(
!
this
.
editor
)
return
;
if
(
this
.
diffEditor
){
const
{
original
,
modified
}
=
this
.
editor
.
getModel
();
monaco
.
editor
.
setModelLanguage
(
original
,
this
.
language
);
monaco
.
editor
.
setModelLanguage
(
modified
,
this
.
language
);
}
else
monaco
.
editor
.
setModelLanguage
(
this
.
editor
.
getModel
(),
this
.
language
);
},
theme
()
{
monaco
.
editor
.
setTheme
(
this
.
theme
);
},
}
});
</
script
>
\ No newline at end of file
ui/src/utils/const.ts
浏览文件 @
cd79b4ea
...
...
@@ -38,4 +38,13 @@ export const AutoTestTools = [
'
Appium
'
,
'
RobotFramework
'
,
'
Cypress
'
,
]
\ No newline at end of file
]
export
const
MonacoOptions
=
{
colorDecorators
:
true
,
lineHeight
:
24
,
tabSize
:
2
,
autoIndent
:
true
,
formatOnPaste
:
true
,
formatOnType
:
true
}
\ No newline at end of file
ui/src/views/script/index/main.vue
浏览文件 @
cd79b4ea
...
...
@@ -50,6 +50,7 @@
class=
"editor"
:value=
"scriptCode"
:language=
"lang"
:options=
"editorOptions"
/>
</div>
</div>
...
...
@@ -67,7 +68,8 @@ import {resizeWidth} from "@/utils/dom";
import
{
Empty
,
message
,
notification
}
from
"
ant-design-vue
"
;
import
{
useI18n
}
from
"
vue-i18n
"
;
import
MonacoEditor
from
'
monaco-editor-vue3
'
import
{
MonacoOptions
}
from
"
@/utils/const
"
;
import
MonacoEditor
from
"
@/components/Editor/MonacoEditor.vue
"
;
interface
ListScriptPageSetupData
{
t
:
(
key
:
string
|
number
)
=>
string
;
...
...
@@ -75,9 +77,11 @@ interface ListScriptPageSetupData {
treeData
:
ComputedRef
<
any
[]
>
;
replaceFields
:
any
,
tree
:
Ref
;
script
:
ComputedRef
scriptCode
:
Ref
<
string
>
;
lang
:
Ref
<
string
>
;
editorOptions
:
Ref
isExpand
:
Ref
<
boolean
>
;
expandNode
:
(
expandedKeys
:
string
[],
e
:
any
)
=>
void
;
...
...
@@ -132,6 +136,7 @@ export default defineComponent({
let
script
=
computed
<
any
>
(()
=>
storeScript
.
state
.
script
.
detail
);
let
scriptCode
=
ref
(
''
)
let
lang
=
ref
(
''
)
const
editorOptions
=
ref
(
MonacoOptions
)
onMounted
(()
=>
{
console
.
log
(
'
onMounted
'
,
tree
)
...
...
@@ -142,14 +147,8 @@ export default defineComponent({
console
.
log
(
'
expandNode
'
,
keys
[
0
],
e
)
}
// let monacoInstance: any
// const disposeEditor = () => {
// console.log('disposeEditor')
// if (monacoInstance) monacoInstance.dispose();
// }
onUnmounted
(()
=>
{
console
.
log
(
'
onUnmounted
'
,
tree
)
// disposeEditor()
})
const
selectNode
=
(
selectedKeys
,
e
)
=>
{
console
.
log
(
'
selectNode
'
,
e
.
selectedNodes
)
...
...
@@ -206,6 +205,7 @@ export default defineComponent({
script
,
scriptCode
,
lang
,
editorOptions
,
simpleImage
:
Empty
.
PRESENTED_IMAGE_SIMPLE
,
}
}
...
...
ui/vue.config.js
浏览文件 @
cd79b4ea
...
...
@@ -46,7 +46,6 @@ module.exports = {
},
chainWebpack
(
config
)
{
// 内置的 svg Rule 添加 exclude
config
.
module
.
rule
(
'
svg
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录