feat: 站点列表显示适配版本和状态,支持查看配置内容

This commit is contained in:
mediabot-pt
2026-06-30 21:45:20 +08:00
parent 2ff52314ae
commit c947ce56d2
3 changed files with 40 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ public class SiteDTO {
private SiteType siteType;
private String schemaVersion;
private SiteStatus status;
private String latestVersion;
private String configStatus;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}

View File

@@ -9,7 +9,9 @@ import com.par.core.entity.Site;
import com.par.core.entity.SiteChange;
import com.par.core.enums.SiteStatus;
import com.par.core.enums.SiteType;
import com.par.core.entity.SiteConfig;
import com.par.core.mapper.SiteChangeMapper;
import com.par.core.mapper.SiteConfigMapper;
import com.par.core.mapper.SiteMapper;
import com.par.core.service.SiteService;
import lombok.RequiredArgsConstructor;
@@ -29,6 +31,7 @@ public class SiteServiceImpl implements SiteService {
private final SiteMapper siteMapper;
private final SiteChangeMapper changeMapper;
private final SiteConfigMapper siteConfigMapper;
private static final ObjectMapper objectMapper = new ObjectMapper();
// ==================== 工具方法 ====================
@@ -84,6 +87,12 @@ public class SiteServiceImpl implements SiteService {
dto.setSiteType(site.getSiteType());
dto.setSchemaVersion(site.getSchemaVersion());
dto.setStatus(site.getStatus());
// 填充适配信息:最新版本号和状态
SiteConfig latest = siteConfigMapper.selectLatestBySiteId(site.getSiteId());
if (latest != null) {
dto.setLatestVersion(latest.getVersion());
dto.setConfigStatus(latest.getStatus() != null ? latest.getStatus().getValue() : null);
}
dto.setCreatedAt(site.getCreatedAt());
dto.setUpdatedAt(site.getUpdatedAt());
return dto;

View File

@@ -22,10 +22,24 @@
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="220">
<el-table-column label="适配版本" width="110">
<template #default="scope">
<span v-if="scope.row.latestVersion" class="text-xs">{{ scope.row.latestVersion }}</span>
<el-tag v-else size="small" type="info">未适配</el-tag>
</template>
</el-table-column>
<el-table-column label="适配状态" width="100">
<template #default="scope">
<el-tag v-if="scope.row.configStatus" size="small" :type="configStatusTag(scope.row.configStatus)">
{{ configStatusLabel(scope.row.configStatus) }}
</el-tag>
<span v-else class="text-xs" style="color:#909399">-</span>
</template>
</el-table-column>
<el-table-column label="操作" width="240">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
<el-button size="small" @click="handleViewConfig(scope.row)">配置</el-button>
<el-button size="small" type="primary" @click="handleViewConfig(scope.row)">查看配置</el-button>
<el-button size="small" @click="handleViewHistory(scope.row)">变更</el-button>
</template>
</el-table-column>
@@ -66,7 +80,7 @@
</el-dialog>
<!-- 查看配置对话框 -->
<el-dialog v-model="configVisible" :title="'配置:' + configSiteId" width="700px" :close-on-click-modal="false">
<el-dialog v-model="configVisible" :title="'配置:' + configSiteId + (configVersion ? ' v' + configVersion : '')" width="700px" :close-on-click-modal="false">
<div v-if="configLoading" style="text-align:center;padding:40px">加载中...</div>
<div v-else-if="configError" style="color:#f56c6c;text-align:center;padding:20px">{{ configError }}</div>
<div v-else-if="!configContent" style="text-align:center;padding:40px;color:#909399">暂无配置</div>
@@ -129,7 +143,7 @@ const siteTypes = [
{ value: 'unknown', label: '未知' },
]
const configVisible = ref(false), configLoading = ref(false), configError = ref(''), configContent = ref(''), configSiteId = ref('')
const configVisible = ref(false), configLoading = ref(false), configError = ref(''), configContent = ref(''), configSiteId = ref(''), configVersion = ref('')
const historyVisible = ref(false), historyLoading = ref(false), historyList = ref([]), historySiteId = ref('')
const highlightedJson = computed(() => {
@@ -173,11 +187,12 @@ const handleSave = async () => {
}
const handleViewConfig = async (row) => {
configVisible.value = true; configSiteId.value = row.siteId; configLoading.value = true; configError.value = ''; configContent.value = ''
configVisible.value = true; configSiteId.value = row.siteId; configVersion.value = ''; configLoading.value = true; configError.value = ''; configContent.value = ''
try {
const r = await api.configs.bySite(row.siteId)
const configs = r.data || []
if (configs.length) {
configVersion.value = configs[0].version
const resp = await api.configs.content(configs[0].siteId, configs[0].version)
configContent.value = typeof resp.data==='string' ? resp.data : JSON.stringify(resp.data,null,2)
}
@@ -202,6 +217,15 @@ const syntaxHighlight = (json) => escapeHtml(json).replace(/("(\\u[a-fA-F0-9]{4}
const escapeHtml = (str) => str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')
const configStatusLabel = (s) => {
const map = { approved: '已适配', pending: '待审核', rejected: '已拒绝', deprecated: '已弃用' }
return map[s] || s
}
const configStatusTag = (s) => {
const map = { approved: 'success', pending: 'warning', rejected: 'danger', deprecated: 'info' }
return map[s] || 'info'
}
onMounted(fetchAll)
</script>