This commit is contained in:
mxd
2021-07-11 09:43:36 +08:00
parent ab83715e82
commit 82811db0a4

View File

@@ -48,7 +48,8 @@
<button class="ma-button" @click="() => doUpload('full')">全量上传</button>
</template>
</magic-dialog>
<magic-dialog v-model="exportVisible" title="导出" align="right" :moveable="false" width="340px" height="490px" className="ma-tree-wrapper">
<magic-dialog v-model="exportVisible" title="导出" align="right" :moveable="false" width="340px" height="490px"
className="ma-tree-wrapper">
<template #content>
<magic-resource-choose ref="resourceExport" height="400px" max-height="400px"/>
</template>
@@ -58,24 +59,25 @@
<button class="ma-button active" @click="doExport">导出</button>
</template>
</magic-dialog>
<magic-dialog title="远程推送" v-model="showPushDialog" align="right" class="ma-remote-push-container ma-tree-wrapper" width="400px" height="540px">
<template #content>
<magic-resource-choose ref="resourcePush" height="400px" max-height="400px"/>
<div>
<label>远程地址</label>
<magic-input placeholder="请输入远程地址" v-model="target" width="300px"/>
</div>
<div>
<label>秘钥</label>
<magic-input placeholder="请输入秘钥" v-model="secretKey" width="300px"/>
</div>
</template>
<template #buttons>
<button class="ma-button" @click="$refs.resourcePush.doSelectAll(true)">全选</button>
<button class="ma-button" @click="$refs.resourcePush.doSelectAll(false)">取消全选</button>
<button class="ma-button active" @click="() => doPush('increment')">增量推送</button>
<button class="ma-button" @click="() => doPush('full')">量推送</button>
</template>
<magic-dialog title="远程推送" v-model="showPushDialog" align="right" class="ma-remote-push-container ma-tree-wrapper"
width="400px" height="540px">
<template #content>
<magic-resource-choose ref="resourcePush" height="400px" max-height="400px"/>
<div>
<label>远程地址</label>
<magic-input placeholder="请输入远程地址" v-model="target" width="300px"/>
</div>
<div>
<label>秘钥</label>
<magic-input placeholder="请输入秘钥" v-model="secretKey" width="300px"/>
</div>
</template>
<template #buttons>
<button class="ma-button" @click="$refs.resourcePush.doSelectAll(true)">全选</button>
<button class="ma-button" @click="$refs.resourcePush.doSelectAll(false)">取消全选</button>
<button class="ma-button active" @click="() => doPush('increment')">量推送</button>
<button class="ma-button" @click="() => doPush('full')">全量推送</button>
</template>
</magic-dialog>
<magic-search ref="search" style="flex: none"></magic-search>
</div>
@@ -117,7 +119,7 @@ export default {
filename: null,
target: 'http://host:port/_magic-api-sync',
secretKey: '123456789',
skinRight: 40+ 'px',
skinRight: 40 + 'px',
}
},
mounted() {
@@ -140,7 +142,7 @@ export default {
},
doExport() {
let selected = this.$refs.resourceExport.getSelected()
if(selected.length > 0){
if (selected.length > 0) {
request.send('/download', JSON.stringify(selected), {
method: 'post',
headers: {
@@ -149,7 +151,7 @@ export default {
transformRequest: [],
responseType: 'blob'
}).success(blob => {
downloadFile(blob, 'magic-api.zip')
downloadFile(blob, 'magic-api.zip')
});
}
},
@@ -164,25 +166,38 @@ export default {
upload() {
this.showUploadDialog = true;
},
doPush(mode){
let selected = 'full' === mode ? [] : this.$refs.resourcePush.getSelected()
if('full' === mode || selected.length > 0) {
request.send('/push', JSON.stringify(selected),{
method: 'post',
headers: {
'magic-push-target': this.target,
'magic-push-secret-key': this.secretKey,
'magic-push-mode': mode,
'Content-Type': 'application/json'
},
transformRequest: []
}).success(() => {
this.$magicAlert({
content: '推送成功!'
})
this.showPushDialog = false;
doPush(mode) {
let selected = 'full' === mode ? [] : this.$refs.resourcePush.getSelected()
let _push = () => {
request.send('/push', JSON.stringify(selected), {
method: 'post',
headers: {
'magic-push-target': this.target,
'magic-push-secret-key': this.secretKey,
'magic-push-mode': mode,
'Content-Type': 'application/json'
},
transformRequest: []
}).success(() => {
this.$magicAlert({
content: '推送成功!'
})
}
this.showPushDialog = false;
})
}
if ('full' === mode) {
this.$magicConfirm({
title: '远程推送',
content: `全量模式推送时,以本地数据为准全量覆盖更新,是否继续?`,
ok: '继续',
cancel: '取消',
onOk: () => {
_push()
}
});
} else if (selected.length > 0) {
_push()
}
},
doUpload(mode) {
let file = this.$refs.file.files[0];
@@ -190,7 +205,7 @@ export default {
let formData = new FormData();
formData.append('file', file, this.filename);
formData.append('mode', mode);
let _upload = ()=>{
let _upload = () => {
this.showUploadDialog = false;
request.send('/upload', formData, {
method: 'post',
@@ -206,7 +221,7 @@ export default {
this.filename = '';
this.$refs.file.value = '';
}
if(mode === 'full'){
if (mode === 'full') {
this.$magicConfirm({
title: '上传接口',
content: `全量模式上传时,以上传的数据为准进行覆盖更新操作,可能会删除其他接口<br>在非全量导出时,建议使用增量更新,是否继续?`,
@@ -216,7 +231,7 @@ export default {
_upload();
}
});
}else{
} else {
_upload();
}
}
@@ -327,8 +342,8 @@ export default {
}
.ma-header .ma-icon-push {
color: var(--button-run-color);
font-weight: bold;
color: var(--button-run-color);
font-weight: bold;
}
.ma-header > span:hover:not(.disabled) {
@@ -353,11 +368,13 @@ export default {
border-bottom: 1px solid var(--border-color);
padding: 2px 5px;
}
.ma-remote-push-container label{
.ma-remote-push-container label {
width: 80px;
text-align: right;
display: inline-block;
}
ul li {
height: 24px;
line-height: 24px;