refactor: 重构优化

This commit is contained in:
xiaojunnuo
2021-02-04 18:44:16 +08:00
parent a39dac4dbd
commit a25a15ca6e
59 changed files with 3903 additions and 967 deletions
+49 -59
View File
@@ -1153,9 +1153,9 @@
"tencentcloud-sdk-nodejs": "^4.0.44"
}
},
"@certd/providers": {
"@certd/dns-providers": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@certd/providers/-/providers-0.1.11.tgz",
"resolved": "https://registry.npmjs.org/@certd/dns-providers/-/providers-0.1.11.tgz",
"integrity": "sha512-km3WluZzNLNA0aeaJjQKochpx52CC5qrjN6Qql9FG+lJ+ceHl1P8oGU8oNUna13eRHcK54oe0vYQt8KkdFnrMQ==",
"requires": {
"@alicloud/pop-core": "^1.7.10",
@@ -3116,6 +3116,27 @@
"webpack-sources": "^1.4.3"
}
},
"vue-loader-v15": {
"version": "npm:vue-loader@15.9.6",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.9.6.tgz",
"integrity": "sha512-j0cqiLzwbeImIC6nVIby2o/ABAWhlppyL/m5oJ67R5MloP0hj/DtFgb0Zmq3J9CG7AJ+AXIvHVnJAPBvrLyuDg==",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz",
"integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=",
"dev": true
}
}
},
"webpack": {
"version": "5.19.0",
"resolved": "https://registry.npm.taobao.org/webpack/download/webpack-5.19.0.tgz",
@@ -6363,9 +6384,9 @@
"integrity": "sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w=="
},
"dayjs": {
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.3.tgz",
"integrity": "sha512-/2fdLN987N8Ki7Id8BUN2nhuiRyxTLumQnSQf9CNncFCyqFsSKb9TNhzRYcC8K8eJSJOKvbvkImo/MKKhNi4iw=="
"version": "1.10.4",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz",
"integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw=="
},
"debug": {
"version": "4.3.1",
@@ -9602,31 +9623,23 @@
}
},
"internal-slot": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz",
"integrity": "sha512-2cQNfwhAfJIkU4KZPkDI+Gj5yNNnbqi40W9Gge6dfnk4TocEVm00B3bdiL+JINrbGJil2TeHvM4rETGzk/f/0g==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz",
"integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==",
"requires": {
"es-abstract": "^1.17.0-next.1",
"get-intrinsic": "^1.1.0",
"has": "^1.0.3",
"side-channel": "^1.0.2"
"side-channel": "^1.0.4"
},
"dependencies": {
"es-abstract": {
"version": "1.17.7",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.7.tgz",
"integrity": "sha512-VBl/gnfcJ7OercKA9MVaegWsBHFjV492syMudcnQZvt/Dw8ezpcOHYZXa/J96O8vx+g4x65YKhxOwDUh63aS5g==",
"get-intrinsic": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
"integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.2.2",
"is-regex": "^1.1.1",
"object-inspect": "^1.8.0",
"object-keys": "^1.1.1",
"object.assign": "^4.1.1",
"string.prototype.trimend": "^1.0.1",
"string.prototype.trimstart": "^1.0.1"
"has-symbols": "^1.0.1"
}
}
}
@@ -12333,6 +12346,11 @@
}
}
},
"object-hash": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.1.1.tgz",
"integrity": "sha512-VOJmgmS+7wvXf8CjbQmimtCnEx3IAoLxI3fp2fbWehxrWBcAQFbk+vcwb6vzR0VZv/eNCJ/27j151ZTwqW/JeQ=="
},
"object-inspect": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
@@ -12514,11 +12532,6 @@
"yallist": "^4.0.0"
}
},
"object-hash": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.1.1.tgz",
"integrity": "sha512-VOJmgmS+7wvXf8CjbQmimtCnEx3IAoLxI3fp2fbWehxrWBcAQFbk+vcwb6vzR0VZv/eNCJ/27j151ZTwqW/JeQ=="
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
@@ -14570,6 +14583,11 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true
},
"prepend-http": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npm.taobao.org/prettier/download/prettier-1.19.1.tgz?cache=0&sync_timestamp=1606521141305&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fprettier%2Fdownload%2Fprettier-1.19.1.tgz",
@@ -16460,9 +16478,9 @@
}
},
"tencentcloud-sdk-nodejs": {
"version": "4.0.51",
"resolved": "https://registry.npmjs.org/tencentcloud-sdk-nodejs/-/tencentcloud-sdk-nodejs-4.0.51.tgz",
"integrity": "sha512-ZdayaDpby5RPR8m5/pUQOaEMkRek655Bp5c9ySgruqVhJskEwOQmzbSCGD3MFf7frV/n038vOSbXuvr0iRILOw==",
"version": "4.0.64",
"resolved": "https://registry.npmjs.org/tencentcloud-sdk-nodejs/-/tencentcloud-sdk-nodejs-4.0.64.tgz",
"integrity": "sha512-Nh0SVRA+MEdLLMt4Uy8UgZD/CT+UDGZwca4sYFso0m/qO8RpCk6z9Jieq7Ltp5FAi3b2cV2GFgB6GrItoe+SUQ==",
"requires": {
"babel-eslint": "^10.0.2",
"eslint-plugin-react": "^7.17.0",
@@ -17065,13 +17083,6 @@
"integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=",
"requires": {
"prepend-http": "^2.0.0"
},
"dependencies": {
"prepend-http": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
}
}
},
"use": {
@@ -17322,27 +17333,6 @@
}
}
},
"vue-loader-v15": {
"version": "npm:vue-loader@15.9.6",
"resolved": "https://registry.npm.taobao.org/vue-loader/download/vue-loader-15.9.6.tgz?cache=0&sync_timestamp=1608188009078&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-15.9.6.tgz",
"integrity": "sha1-9Lua4gw6g3CvPs8JuBJtOP/ba4s=",
"dev": true,
"requires": {
"@vue/component-compiler-utils": "^3.1.0",
"hash-sum": "^1.0.2",
"loader-utils": "^1.1.0",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0"
},
"dependencies": {
"hash-sum": {
"version": "1.0.2",
"resolved": "https://registry.npm.taobao.org/hash-sum/download/hash-sum-1.0.2.tgz",
"integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=",
"dev": true
}
}
},
"vue-router": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.3.tgz",
+1 -1
View File
@@ -10,7 +10,7 @@
},
"dependencies": {
"@certd/plugins": "^0.1.11",
"@certd/providers": "^0.1.11",
"@certd/dns-providers": "^0.1.11",
"ant-design-vue": "^2.0.0-rc.8",
"lodash-es": "^4.17.20",
"vue-i18n": "^9.0.0-rc.2",
+25
View File
@@ -0,0 +1,25 @@
import { request } from './service'
export default {
exportsToZip (options) {
return request({
url: '/exports/toZip',
data: { options },
method: 'post',
responseType: 'blob' // 重点在于配置responseType: 'blob'
}).then(res => {
console.log('res', res)
const filename = decodeURI(res.headers['content-disposition'].replace('attachment;filename=', '')) // 由后端设置下载文件名
const blob = new Blob([res.data], { type: 'application/zip' })
const a = document.createElement('a')
const url = window.URL.createObjectURL(blob)
a.href = url
a.download = filename
const body = document.getElementsByTagName('body')[0]
body.appendChild(a)
a.click()
body.removeChild(a)
window.URL.revokeObjectURL(url)
})
}
}
+4
View File
@@ -20,6 +20,10 @@ function createService () {
// 响应拦截
service.interceptors.response.use(
response => {
console.log('response.config', response.config)
if (response.config.responseType === 'blob') {
return response
}
// dataAxios 是 axios 返回数据中的 data
const dataAxios = response.data
// 这个状态码是和后端约定的
@@ -76,6 +76,7 @@ function useTaskForm (context) {
const taskPluginDefineList = ref([])
const onCreated = async () => {
const plugins = await pluginsApi.list()
console.log('plugins', plugins)
taskPluginDefineList.value = plugins
}
@@ -113,7 +114,15 @@ function useTaskForm (context) {
message.warn('请先选择类型')
return
}
// 给task的input设置默认值
changeCurrentPlugin(currentTask.value)
for (const key in currentPlugin.value.input) {
const input = currentPlugin.value.input[key]
if (input.default != null) {
currentTask.value[key] = input.default
}
}
}
const taskDrawerShow = () => {
@@ -245,6 +254,7 @@ export default {
font-size: 10px;
line-height: 20px;
height: 40px;
color: #7f7f7f
}
}
}
+30 -2
View File
@@ -134,6 +134,20 @@
</a-card>
</div>
</div>
<div class="flow-group flow-export">
<h3 class="group-head">
导出
</h3>
<a-divider></a-divider>
<div class="export">
<div><a-button @click="exportsToZip">导出可执行项目</a-button></div>
<br/>
<div> <a-button>仅导出配置</a-button></div>
</div>
</div>
</div>
<cert-form ref="certFormRef" v-model:cert="options.cert" v-model:access-providers="options.accessProviders"></cert-form>
@@ -145,11 +159,12 @@
<script>
import { message } from 'ant-design-vue'
// eslint-disable-next-line no-unused-vars
import { reactive, ref, toRef, provide, readonly } from 'vue'
import { reactive, ref, toRef, toRefs, provide, readonly } from 'vue'
// eslint-disable-next-line no-unused-vars
import { useRoute } from 'vue-router'
import CertForm from '@/views/detail/components/cert-form'
import TaskForm from './components/task-form'
import exportsApi from '@/api/api.exports'
import _ from 'lodash-es'
function useDeploy (options) {
@@ -187,6 +202,14 @@ function useProvideAccessProviders (options) {
})
}
function useExports (options) {
return {
async exportsToZip () {
await exportsApi.exportsToZip(options)
}
}
}
export default {
components: { CertForm, TaskForm },
setup () {
@@ -238,7 +261,8 @@ export default {
...useDeploy(options),
taskFormRef,
taskAdd,
taskEdit
taskEdit,
...useExports(options)
}
}
}
@@ -360,6 +384,10 @@ export default {
}
}
.flow-export{
max-width: 300px;
}
}
}