feat: 展示发布 ref 提交信息
This commit is contained in:
+13
-6
@@ -210,14 +210,21 @@ export interface ProjectConfig {
|
|||||||
|
|
||||||
export interface ProjectRefs {
|
export interface ProjectRefs {
|
||||||
source: 'gitea' | 'fallback'
|
source: 'gitea' | 'fallback'
|
||||||
branches: Array<{
|
branches: ProjectRefItem[]
|
||||||
|
tags: ProjectRefItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectRefCommit {
|
||||||
|
sha: string
|
||||||
|
message: string
|
||||||
|
authorName?: string
|
||||||
|
authoredAt?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProjectRefItem {
|
||||||
name: string
|
name: string
|
||||||
commitSha?: string
|
commitSha?: string
|
||||||
}>
|
commit?: ProjectRefCommit
|
||||||
tags: Array<{
|
|
||||||
name: string
|
|
||||||
commitSha?: string
|
|
||||||
}>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PipelineStep {
|
export interface PipelineStep {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* 发布中心负责创建发布单、同步 Jenkins 状态并展示当前运行流程。
|
* 发布中心负责创建发布单、展示真实 Gitea ref 摘要并同步 Jenkins 状态。
|
||||||
*/
|
*/
|
||||||
import { CircleClose, Promotion, RefreshRight, VideoPause } from '@element-plus/icons-vue'
|
import { CircleClose, Promotion, RefreshRight, VideoPause } from '@element-plus/icons-vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
@@ -9,7 +9,7 @@ import BpmnStatusViewer from '../components/BpmnStatusViewer.vue'
|
|||||||
import RunExecutionDetails from '../components/RunExecutionDetails.vue'
|
import RunExecutionDetails from '../components/RunExecutionDetails.vue'
|
||||||
import StatusPill from '../components/StatusPill.vue'
|
import StatusPill from '../components/StatusPill.vue'
|
||||||
import { usePlatformStore } from '../stores/platform'
|
import { usePlatformStore } from '../stores/platform'
|
||||||
import type { EnvironmentName, ReleaseRun, ReleaseStatus } from '../types/devops'
|
import type { EnvironmentName, ProjectRefItem, ReleaseRun, ReleaseStatus } from '../types/devops'
|
||||||
|
|
||||||
const platform = usePlatformStore()
|
const platform = usePlatformStore()
|
||||||
|
|
||||||
@@ -77,6 +77,34 @@ const refSourceText = computed(() => {
|
|||||||
return '等待后端 refs'
|
return '等待后端 refs'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const selectedRefDetail = computed<ProjectRefItem | undefined>(() => {
|
||||||
|
const refs = currentRefs.value
|
||||||
|
|
||||||
|
if (!refs) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const candidates =
|
||||||
|
form.environment === 'production' && !useBranchRefs.value ? refs.tags : refs.branches
|
||||||
|
|
||||||
|
return candidates.find((item) => item.name === form.ref)
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedCommitMessage = computed(() => {
|
||||||
|
return selectedRefDetail.value?.commit?.message?.split('\n')[0] || ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedCommitSha = computed(() => {
|
||||||
|
return selectedRefDetail.value?.commit?.sha || selectedRefDetail.value?.commitSha || ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedCommitMeta = computed(() => {
|
||||||
|
const commit = selectedRefDetail.value?.commit
|
||||||
|
const parts = [commit?.authorName, formatCommitTime(commit?.authoredAt)].filter(Boolean)
|
||||||
|
|
||||||
|
return parts.join(' · ')
|
||||||
|
})
|
||||||
|
|
||||||
const canTrigger = computed(() => {
|
const canTrigger = computed(() => {
|
||||||
if (!form.projectKey || !form.environment || !form.ref) {
|
if (!form.projectKey || !form.environment || !form.ref) {
|
||||||
return false
|
return false
|
||||||
@@ -116,6 +144,23 @@ async function triggerRelease() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shortSha(value: string): string {
|
||||||
|
return value ? value.slice(0, 10) : '-'
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCommitTime(value?: string): string {
|
||||||
|
if (!value) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Intl.DateTimeFormat('zh-CN', {
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
}).format(new Date(value))
|
||||||
|
}
|
||||||
|
|
||||||
async function cancelRelease() {
|
async function cancelRelease() {
|
||||||
if (!shownRun.value) {
|
if (!shownRun.value) {
|
||||||
return
|
return
|
||||||
@@ -264,6 +309,15 @@ watch(refOptions, (options) => {
|
|||||||
{{ form.environment === 'production' ? selectedProject?.tagPolicy : selectedProject?.defaultBranch }}
|
{{ form.environment === 'production' ? selectedProject?.tagPolicy : selectedProject?.defaultBranch }}
|
||||||
· {{ refSourceText }}
|
· {{ refSourceText }}
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="selectedCommitSha" class="commit-preview">
|
||||||
|
<div class="commit-main">
|
||||||
|
<ElTag size="small" effect="plain" class="mono">
|
||||||
|
{{ shortSha(selectedCommitSha) }}
|
||||||
|
</ElTag>
|
||||||
|
<strong>{{ selectedCommitMessage || 'Gitea 未返回提交说明' }}</strong>
|
||||||
|
</div>
|
||||||
|
<small v-if="selectedCommitMeta">{{ selectedCommitMeta }}</small>
|
||||||
|
</div>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem label="备注">
|
<ElFormItem label="备注">
|
||||||
<ElInput v-model="form.note" type="textarea" :rows="3" maxlength="120" show-word-limit />
|
<ElInput v-model="form.note" type="textarea" :rows="3" maxlength="120" show-word-limit />
|
||||||
@@ -356,6 +410,44 @@ watch(refOptions, (options) => {
|
|||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.commit-preview {
|
||||||
|
display: grid;
|
||||||
|
gap: 4px;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid #d9e2ef;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #f8fafc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commit-main {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: max-content minmax(0, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commit-main strong,
|
||||||
|
.commit-preview small {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commit-main strong {
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commit-preview small {
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 760px) {
|
@media (max-width: 760px) {
|
||||||
.form-grid {
|
.form-grid {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
|||||||
Reference in New Issue
Block a user