|
|
@@ -112,133 +112,10 @@
|
|
|
:visible.sync="showAddDialog"
|
|
|
center
|
|
|
>
|
|
|
- <template>
|
|
|
- <div class="compiler-config-steps">
|
|
|
- <el-steps :active="active" finish-status="success" simple style="margin-bottom: 30px">
|
|
|
- <el-step title="配置基础环境" icon="el-icon-monitor" />
|
|
|
- <el-step title="配置打包" icon="el-icon-edit" />
|
|
|
- </el-steps>
|
|
|
-
|
|
|
- <el-form ref="form" :model="form" :rules="dynamicRules" label-width="130px">
|
|
|
- <div v-show="active === 0">
|
|
|
- <el-form-item label="打包类型" prop="type">
|
|
|
- <el-select v-model="form.type" placeholder="请选择打包类型" style="width: 100%">
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in packTypes"
|
|
|
- :key="index"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="配置名称" prop="name">
|
|
|
- <el-input v-model="form.name" placeholder="例如 docker-pack" />
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div v-show="active === 1">
|
|
|
- <div v-if="form.type === 'docker'">
|
|
|
- <el-form-item label="docker 仓库" prop="dockerRegistry">
|
|
|
- <div style="display: flex; align-items: center;">
|
|
|
- <el-select v-model="form.dockerRegistry" placeholder="请选择 docker 仓库" style="width: 100%">
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in registryList"
|
|
|
- :key="index"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- <el-tooltip content="添加 docker 仓库" placement="top">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- icon="el-icon-plus"
|
|
|
- circle
|
|
|
- size="mini"
|
|
|
- style="margin-left: 10px"
|
|
|
- @click="goToAddRegistry"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- </div>
|
|
|
- <div class="form-tip">编译构建生成的镜像会推送到该仓库</div>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- <div v-else-if="form.type === 'ossStatic'" class="oss-config-group">
|
|
|
- <el-form-item prop="artifactPath">
|
|
|
- <span slot="label">
|
|
|
- 编译产物路径
|
|
|
- <el-tooltip content="编译完成后产物所在的相对路径,例如:dist/ 或 target/app.jar" placement="top">
|
|
|
- <i class="el-icon-question" style="cursor: help; color: #909399;"></i>
|
|
|
- </el-tooltip>
|
|
|
- </span>
|
|
|
- <el-input v-model="form.artifactPath" placeholder="例如 dist/" clearable />
|
|
|
- <div class="form-tip">源码根目录下的相对路径</div>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="阿里云 OSS" prop="ossEndpoint">
|
|
|
- <div class="oss-select-wrapper">
|
|
|
- <el-select
|
|
|
- v-model="form.ossEndpoint"
|
|
|
- placeholder="请选择阿里云 OSS"
|
|
|
- style="flex: 1"
|
|
|
- filterable
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in ossList"
|
|
|
- :key="index"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
-
|
|
|
- <el-tooltip content="添加新的 OSS" placement="top">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- icon="el-icon-plus"
|
|
|
- circle
|
|
|
- size="small"
|
|
|
- class="add-bucket-btn"
|
|
|
- @click="goToAddOss"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- </div>
|
|
|
- <div class="form-tip">编译生成的静态产物将自动上传并同步至该 OSS, 应用部署配置中会指定使用的 bucket</div>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- <div v-else>
|
|
|
- <el-form-item prop="artifactPath">
|
|
|
- <span slot="label">
|
|
|
- 编译产物路径
|
|
|
- <el-tooltip content="编译完成后产物所在的相对路径,例如:dist/ 或 target/app.jar" placement="top">
|
|
|
- <i class="el-icon-question" style="cursor: help; color: #909399;"></i>
|
|
|
- </el-tooltip>
|
|
|
- </span>
|
|
|
- <el-input v-model="form.artifactPath" placeholder="例如 dist/" clearable />
|
|
|
- <div class="form-tip">源码根目录下的相对路径</div>
|
|
|
- </el-form-item>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <el-form-item style="margin-top: 40px">
|
|
|
- <el-button v-if="active > 0" @click="active--">上一步</el-button>
|
|
|
- <el-button v-if="active < 1" type="primary" @click="nextStep">下一步</el-button>
|
|
|
- <el-button v-if="active === 1" type="success" @click="onAddPacker">提交保存</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-dialog>
|
|
|
- <el-dialog
|
|
|
- title="添加 docker 仓库"
|
|
|
- append-to-body
|
|
|
- :visible.sync="showAddRegistryDialog"
|
|
|
- center
|
|
|
- >
|
|
|
- </el-dialog>
|
|
|
- <el-dialog
|
|
|
- title="添加阿里云 OSS"
|
|
|
- append-to-body
|
|
|
- :visible.sync="showAddOssDialog"
|
|
|
- center
|
|
|
- >
|
|
|
+ <packer-add-card
|
|
|
+ @close="showAddDialog = false"
|
|
|
+ @success="handleAddSuccess"
|
|
|
+ />
|
|
|
</el-dialog>
|
|
|
<el-dialog
|
|
|
title="存储位置"
|
|
|
@@ -251,10 +128,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { addPacker, deletePacker, getPackerList, getPackTypes } from '@/api/devops'
|
|
|
+import PackerAddCard from '@/components/card/PackerAddCard.vue'
|
|
|
+import { deletePacker, getPackerList } from '@/api/devops'
|
|
|
|
|
|
export default {
|
|
|
name: 'Packer',
|
|
|
+ components: {
|
|
|
+ PackerAddCard
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
queryInfo: {
|
|
|
@@ -268,29 +149,7 @@ export default {
|
|
|
totalSize: 0,
|
|
|
dataList: [],
|
|
|
// **********************************************************************
|
|
|
- active: 0,
|
|
|
showAddDialog: false,
|
|
|
- form: {
|
|
|
- type: '',
|
|
|
- name: '',
|
|
|
- artifactPath: '',
|
|
|
- dockerRegistry: '',
|
|
|
- ossEndpoint: '',
|
|
|
- targetPath: ''
|
|
|
- },
|
|
|
- packTypes: [],
|
|
|
- registryList: [],
|
|
|
- ossList: [],
|
|
|
- // **********************************************************************
|
|
|
- showAddRegistryDialog: false,
|
|
|
- registryForm: {
|
|
|
- registryUrl: ''
|
|
|
- },
|
|
|
- // **********************************************************************
|
|
|
- showAddOssDialog: false,
|
|
|
- ossForm: {
|
|
|
- ossEndpoint: ''
|
|
|
- },
|
|
|
// **********************************************************************
|
|
|
showTargetDialog: false,
|
|
|
ossForm1: {
|
|
|
@@ -298,19 +157,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- dynamicRules() {
|
|
|
- const baseRules = {
|
|
|
- type: [{ required: true, message: '请选择类型', trigger: 'blur' }],
|
|
|
- name: [{ required: true, message: '请输入名称', trigger: 'blur' }]
|
|
|
- }
|
|
|
- // 根据选择的类型增加特定规则
|
|
|
- if (this.form.type === 'docker') {
|
|
|
- baseRules.dockerRegistry = [{ required: true, message: 'docker 类型必须指定使用的仓库', trigger: 'blur' }]
|
|
|
- }
|
|
|
- return baseRules
|
|
|
- }
|
|
|
- },
|
|
|
created() {
|
|
|
document.title = '打包配置列表'
|
|
|
this.getData()
|
|
|
@@ -336,68 +182,11 @@ export default {
|
|
|
this.$message.error(error.message)
|
|
|
})
|
|
|
},
|
|
|
- handleShowAdd(index, row) {
|
|
|
- getPackTypes().then(resp => {
|
|
|
- if (resp.code === 0) {
|
|
|
- this.showAddDialog = true
|
|
|
- this.packTypes = resp.data.packTypes
|
|
|
- this.registryList = resp.data.registryList
|
|
|
- this.ossList = resp.data.ossList
|
|
|
- } else {
|
|
|
- this.$message.error(resp.msg)
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
- this.$message.error(error.message)
|
|
|
- })
|
|
|
- },
|
|
|
- onAddPacker1() {
|
|
|
- const formData = new FormData()
|
|
|
- formData.append('type', this.form.type)
|
|
|
- formData.append('name', this.form.name)
|
|
|
- formData.append('artifactPath', this.form.artifactPath)
|
|
|
- formData.append('dockerRegistry', this.form.dockerRegistry)
|
|
|
- formData.append('targetPath', this.form.targetPath)
|
|
|
- addPacker(formData).then(resp => {
|
|
|
- this.$message.info(resp.msg)
|
|
|
- this.getData()
|
|
|
- }).catch(error => {
|
|
|
- this.$message.error(error.message)
|
|
|
- }).finally(() => {
|
|
|
- this.showAddDialog = false
|
|
|
- })
|
|
|
+ handleShowAdd() {
|
|
|
+ this.showAddDialog = true
|
|
|
},
|
|
|
- // 异步校验并跳转
|
|
|
- async nextStep() {
|
|
|
- const stepFields = ['type', 'name'] // 第一步需要校验的字段
|
|
|
-
|
|
|
- try {
|
|
|
- // 关键:将所有字段的校验转为 Promise 数组
|
|
|
- const checkActions = stepFields.map(field => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- this.$refs.form.validateField(field, error => {
|
|
|
- if (error) reject(error)
|
|
|
- else resolve()
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- await Promise.all(checkActions)
|
|
|
- this.active++ // 只有全部校验成功才加 1
|
|
|
- } catch (e) {
|
|
|
- this.$message.warning('请检查基础配置是否填写完整')
|
|
|
- }
|
|
|
- },
|
|
|
- onAddPacker() {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- // 这里发起 API 请求
|
|
|
- console.log('Final Data:', this.form)
|
|
|
- this.$message.success('打包配置添加成功!')
|
|
|
- // 逻辑处理,如关闭弹窗或跳转列表
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
+ handleAddSuccess() {
|
|
|
+ this.$message.success('打包配置添加成功!')
|
|
|
},
|
|
|
handleEdit(index, row) {
|
|
|
this.$confirm('确定要删除 ' + row.name + '?', '提示', {
|
|
|
@@ -420,12 +209,6 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- goToAddRegistry() {
|
|
|
- this.showAddRegistryDialog = true
|
|
|
- },
|
|
|
- goToAddOss() {
|
|
|
- this.showAddOssDialog = true
|
|
|
- },
|
|
|
handleUsage(row) {
|
|
|
this.$message.info('handleUsage')
|
|
|
},
|
|
|
@@ -437,41 +220,4 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
-/* OSS 配置组容器,可以加一个淡色背景或边框区分 */
|
|
|
-.oss-config-group {
|
|
|
- padding: 15px;
|
|
|
- background-color: #fcfcfc;
|
|
|
- border-radius: 4px;
|
|
|
- border: 1px dashed #e4e7ed;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-/* Flex 布局让选择框和按钮完美对齐 */
|
|
|
-.oss-select-wrapper {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- gap: 12px; /* 间距更加现代化 */
|
|
|
-}
|
|
|
-
|
|
|
-/* 按钮悬停动画 */
|
|
|
-.add-bucket-btn {
|
|
|
- transition: transform 0.2s;
|
|
|
-}
|
|
|
-.add-bucket-btn:hover {
|
|
|
- transform: scale(1.1);
|
|
|
-}
|
|
|
-
|
|
|
-/* 提示文字样式优化 */
|
|
|
-.form-tip {
|
|
|
- font-size: 12px;
|
|
|
- color: #909399;
|
|
|
- line-height: 1.5;
|
|
|
- margin-top: 4px;
|
|
|
-}
|
|
|
-
|
|
|
-/* 统一图标颜色 */
|
|
|
-.el-icon-question {
|
|
|
- font-size: 14px;
|
|
|
- vertical-align: middle;
|
|
|
-}
|
|
|
</style>
|