Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
4f563d13
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
4f563d13
编写于
9月 01, 2022
作者:
雨
雨爱无痕
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add rename script and dir
上级
cc961ba3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
83 addition
and
5 deletion
+83
-5
internal/server/modules/v1/controller/test-script.go
internal/server/modules/v1/controller/test-script.go
+18
-0
internal/server/modules/v1/index/test-script.go
internal/server/modules/v1/index/test-script.go
+1
-0
internal/server/modules/v1/service/test-script.go
internal/server/modules/v1/service/test-script.go
+17
-2
ui/src/locales/en-US.ts
ui/src/locales/en-US.ts
+1
-0
ui/src/locales/zh-CN.ts
ui/src/locales/zh-CN.ts
+1
-0
ui/src/views/script/FormNode.vue
ui/src/views/script/FormNode.vue
+10
-2
ui/src/views/script/TreeContextMenu.vue
ui/src/views/script/TreeContextMenu.vue
+3
-0
ui/src/views/script/WorkDir.vue
ui/src/views/script/WorkDir.vue
+11
-1
ui/src/views/script/service.ts
ui/src/views/script/service.ts
+8
-0
ui/src/views/script/store.ts
ui/src/views/script/store.ts
+13
-0
未找到文件。
internal/server/modules/v1/controller/test-script.go
浏览文件 @
4f563d13
...
...
@@ -177,6 +177,24 @@ func (c *TestScriptCtrl) Delete(ctx iris.Context) {
ctx
.
JSON
(
c
.
SuccessResp
(
nil
))
}
func
(
c
*
TestScriptCtrl
)
Rename
(
ctx
iris
.
Context
)
{
req
:=
serverDomain
.
TestScript
{}
err
:=
ctx
.
ReadJSON
(
&
req
)
if
err
!=
nil
{
ctx
.
JSON
(
c
.
ErrResp
(
commConsts
.
CommErr
,
err
.
Error
()))
return
}
bizErr
:=
c
.
TestScriptService
.
Rename
(
req
.
Path
,
req
.
Name
)
if
bizErr
!=
nil
{
ctx
.
JSON
(
c
.
BizErrResp
(
bizErr
,
""
))
return
}
ctx
.
JSON
(
c
.
SuccessResp
(
nil
))
}
// Extract 详情
func
(
c
*
TestScriptCtrl
)
Extract
(
ctx
iris
.
Context
)
{
scriptPath
:=
ctx
.
URLParam
(
"path"
)
...
...
internal/server/modules/v1/index/test-script.go
浏览文件 @
4f563d13
...
...
@@ -30,6 +30,7 @@ func (m *TestScriptModule) Party() module.WebModule {
index
.
Put
(
"/updateName"
,
m
.
TestScriptCtrl
.
UpdateName
)
.
Name
=
"重命令脚本"
index
.
Put
(
"/paste"
,
m
.
TestScriptCtrl
.
Paste
)
.
Name
=
"粘贴脚本"
index
.
Put
(
"/move"
,
m
.
TestScriptCtrl
.
Move
)
.
Name
=
"移动脚本"
index
.
Put
(
"/rename"
,
m
.
TestScriptCtrl
.
Rename
)
.
Name
=
"重命名脚本"
index
.
Get
(
"/extract"
,
m
.
TestScriptCtrl
.
Extract
)
.
Name
=
"抽取脚本"
index
.
Post
(
"/syncFromZentao"
,
m
.
TestScriptCtrl
.
SyncFromZentao
)
.
Name
=
"从禅道导出脚本"
...
...
internal/server/modules/v1/service/test-script.go
浏览文件 @
4f563d13
package
service
import
(
"os"
"path/filepath"
commConsts
"github.com/easysoft/zentaoatf/internal/pkg/consts"
commDomain
"github.com/easysoft/zentaoatf/internal/pkg/domain"
codeHelper
"github.com/easysoft/zentaoatf/internal/pkg/helper/code"
...
...
@@ -12,8 +15,6 @@ import (
"github.com/easysoft/zentaoatf/pkg/domain"
fileUtils
"github.com/easysoft/zentaoatf/pkg/lib/file"
"github.com/kataras/iris/v12"
"os"
"path/filepath"
)
type
TestScriptService
struct
{
...
...
@@ -200,6 +201,20 @@ func (s *TestScriptService) Delete(pth string) (bizErr *domain.BizError) {
return
}
func
(
s
*
TestScriptService
)
Rename
(
pth
string
,
name
string
)
(
bizErr
*
domain
.
BizError
)
{
dir
,
_
:=
filepath
.
Split
(
pth
)
err
:=
os
.
Rename
(
pth
,
dir
+
name
)
_
,
ok
:=
err
.
(
*
os
.
PathError
)
if
ok
{
bizErr
=
&
domain
.
BizError
{
Code
:
commConsts
.
ErrDirNotEmpty
.
Code
}
}
else
{
bizErr
=
nil
}
return
}
func
(
s
*
TestScriptService
)
Move
(
req
serverDomain
.
MoveScriptReq
)
(
err
error
)
{
src
:=
req
.
DragKey
srcName
:=
fileUtils
.
GetFileName
(
src
)
...
...
ui/src/locales/en-US.ts
浏览文件 @
4f563d13
...
...
@@ -236,6 +236,7 @@ export default {
'
copy
'
:
'
Copy
'
,
'
cut
'
:
'
Cut
'
,
'
paste
'
:
'
Paste
'
,
'
rename
'
:
'
Rename
'
,
'
open-in-explore
'
:
'
Open In Explore
'
,
'
open-in-terminal
'
:
'
Open In Terminal
'
,
...
...
ui/src/locales/zh-CN.ts
浏览文件 @
4f563d13
...
...
@@ -247,6 +247,7 @@ export default {
'
copy
'
:
'
复制
'
,
'
cut
'
:
'
剪切
'
,
'
paste
'
:
'
粘贴
'
,
'
rename
'
:
'
重命名
'
,
'
open-in-explore
'
:
'
在资源管理器中显示
'
,
'
open-in-terminal
'
:
'
从此位置打开命令行
'
,
...
...
ui/src/views/script/FormNode.vue
浏览文件 @
4f563d13
...
...
@@ -3,7 +3,7 @@
:showModal=
"showModalRef"
@
onCancel=
"cancel"
@
onOk=
"submit"
:title=
"
t('creat
e')"
:title=
"
props.path == '' ? t('create') : t('renam
e')"
:contentStyle=
"
{width: '400px'}"
>
<Form>
...
...
@@ -31,17 +31,25 @@ import FormItem from "@/components/FormItem.vue";
export
interface
FormWorkspaceProps
{
show
?:
boolean
;
path
?:
string
;
name
?:
string
;
}
const
{
t
}
=
useI18n
();
const
props
=
withDefaults
(
defineProps
<
FormWorkspaceProps
>
(),
{
show
:
false
,
path
:
""
,
name
:
""
,
});
watch
(
props
,
()
=>
{
if
(
!
props
.
show
){
setTimeout
(()
=>
{
validateInfos
.
value
=
{};
modelRef
.
value
=
{
name
:
''
,
path
:
''
}
},
200
);
}
else
{
modelRef
.
value
.
name
=
props
.
name
modelRef
.
value
.
path
=
props
.
path
}
})
...
...
@@ -53,7 +61,7 @@ const cancel = () => {
emit
(
"
cancel
"
,
{});
};
const
modelRef
=
ref
({});
const
modelRef
=
ref
({
name
:
''
,
path
:
''
});
const
rulesRef
=
ref
({
name
:
[{
required
:
true
,
msg
:
t
(
"
pls_name
"
)
}],
});
...
...
ui/src/views/script/TreeContextMenu.vue
浏览文件 @
4f563d13
...
...
@@ -23,6 +23,9 @@
<div
v-if=
"treeNode?.type != 'workspace'"
@
click=
"menuClick('delete')"
class=
"menu-item"
>
<span>
{{
t
(
'
delete
'
)
}}
</span>
</div>
<div
v-if=
"treeNode?.type != 'workspace'"
@
click=
"menuClick('rename')"
class=
"menu-item"
>
<span>
{{
t
(
'
rename
'
)
}}
</span>
</div>
<div
v-if=
"isElectron"
@
click=
"menuClick('open-in-explore')"
class=
"menu-item"
>
<span>
{{
t
(
'
open-in-explore
'
)
}}
</span>
...
...
ui/src/views/script/WorkDir.vue
浏览文件 @
4f563d13
...
...
@@ -13,7 +13,7 @@
:defaultCollapsedMap=
"collapsedMap"
:defaultCollapsed=
"true"
/>
<FormNode
:show=
"showModal"
@
submit=
"createNode"
@
cancel=
"modalClose"
ref=
"formNode"
/>
<FormNode
:show=
"showModal"
@
submit=
"createNode"
@
cancel=
"modalClose"
:path=
"currentNode.path"
:name=
"currentNode.title"
ref=
"formNode"
/>
</div>
<Button
v-if=
"checkable && checkedKeys.length"
...
...
@@ -122,6 +122,7 @@ const onToolbarClicked = (e) => {
case
'
createFile
'
:
case
'
createWorkspace
'
:
case
'
createDir
'
:
currentNode
.
value
=
{}
showModal
.
value
=
true
;
toolbarAction
.
value
=
e
.
event
.
key
;
break
;
...
...
@@ -380,6 +381,12 @@ let rightClickedNode = {} as any
const
formNode
=
ref
({}
as
any
)
const
createNode
=
(
formData
)
=>
{
if
(
formData
.
path
!=
""
){
store
.
dispatch
(
'
Script/renameScript
'
,
formData
)
formNode
.
value
.
clearFormData
()
showModal
.
value
=
false
;
return
;
}
const
mode
=
'
child
'
;
let
type
=
'
dir
'
;
if
(
toolbarAction
.
value
===
'
createFile
'
)
type
=
'
node
'
...
...
@@ -484,6 +491,9 @@ const menuClick = (menuKey: string, targetId: number) => {
store
.
dispatch
(
'
Script/deleteScript
'
,
contextNodeData
.
id
)
},
});
}
else
if
(
menuKey
===
'
rename
'
)
{
showModal
.
value
=
true
;
currentNode
.
value
=
contextNodeData
;
}
else
if
(
menuKey
==
'
sync-from-zentao
'
){
syncFromZentao
(
contextNodeData
)
}
else
if
(
menuKey
===
'
sync-to-zentao
'
){
...
...
ui/src/views/script/service.ts
浏览文件 @
4f563d13
...
...
@@ -100,6 +100,14 @@ export async function remove(path: string): Promise<any> {
});
}
export
async
function
rename
(
data
:
any
):
Promise
<
any
>
{
return
request
({
url
:
`/
${
apiPath
}
/rename`
,
method
:
'
put
'
,
data
,
});
}
export
async
function
updateCode
(
data
:
any
):
Promise
<
any
>
{
return
request
({
url
:
`/
${
apiPath
}
/updateCode`
,
...
...
ui/src/views/script/store.ts
浏览文件 @
4f563d13
...
...
@@ -14,6 +14,7 @@ import {
syncFromZentao
,
syncToZentao
,
paste
,
move
,
rename
,
scriptTreeAddAttr
,
getNodeMap
,
}
from
'
./service
'
;
...
...
@@ -51,6 +52,7 @@ export interface ModuleType extends StoreModuleType<ScriptData> {
createScript
:
Action
<
ScriptData
,
ScriptData
>
;
updateScript
:
Action
<
ScriptData
,
ScriptData
>
;
deleteScript
:
Action
<
ScriptData
,
ScriptData
>
;
renameScript
:
Action
<
ScriptData
,
ScriptData
>
;
pasteScript
:
Action
<
ScriptData
,
ScriptData
>
;
moveScript
:
Action
<
ScriptData
,
ScriptData
>
;
updateCode
:
Action
<
ScriptData
,
ScriptData
>
;
...
...
@@ -232,6 +234,17 @@ const StoreModel: ModuleType = {
}
},
async
renameScript
({
dispatch
,
state
},
data
:
any
)
{
try
{
await
rename
(
data
);
await
dispatch
(
'
listScript
'
,
state
.
queryParams
)
return
true
;
}
catch
(
error
)
{
return
false
;
}
},
async
changeWorkspace
({
commit
},
payload
:
any
)
{
commit
(
'
setWorkspace
'
,
payload
);
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录