Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(version-diff): 修复未生成任何版本时版本对比无内容的问题 #1085

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/dashboard-front/src/components/version-diff/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- eslint-disable vue/no-v-html -->

<template>
<div class="ag-version-diff-box">
<p class="summary-data">
Expand Down Expand Up @@ -116,15 +114,15 @@
</bk-select>
<strong class="title" v-else>
<template v-if="pageType === 'publishEnvironment'">
当前版本({{ sourceVersion.version }})
{{ t('当前版本({version})', { version: sourceVersion.version }) }}
</template>
<template v-else>
{{ sourceVersion.version }} {{ sourceVersion.comment ? `(${sourceVersion.comment})` : '' }}
</template>
</strong>
</template>
<strong class="title" v-else>
暂无版本
{{ t('暂无版本') }}
</strong>
</div>
</div>
Expand Down Expand Up @@ -158,7 +156,7 @@
<strong class="title" v-else>
<template v-if="pageType !== 'createVersion'">
<template v-if="pageType === 'publishEnvironment'">
待发布({{ targetVersion.version }})
{{ t('待发布({version})', { version: targetVersion.version }) }}
</template>
<template v-else>
{{ targetVersion.version }} {{ targetVersion.comment ? `(${targetVersion.comment})` : '' }}
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard-front/src/language/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ const lang: ILANG = {
'停用成功': ['Successfully disabled'],
'已绑定的环境:': ['Bound environments:'],
'当前版本:': ['Current version:'],
'当前版本({version})': ['Current version({version})'],
'已绑定的资源:': ['Bound resources:'],
'请输入插件关键字,按Enter搜索': ['Please enter plugin keyword, press Enter to search'],
'版本:': ['Version:'],
Expand Down Expand Up @@ -1663,6 +1664,8 @@ const lang: ILANG = {
'上传失败': ['Upload failed'],
'管理网关的应用列表': ['Related App Codes'],
'允许列表中的应用使用 sdk 或者开放 API 调用网关接口,同步环境/资源以及发布版本': ['Apps allowed to use SDK or openAPI to call gateway APIs, sync environments/resources and publish versions'],
'暂无版本': ['No Version'],
'待发布({version})': ['To Be Published({version})'],
'删除操作无法撤回,请谨慎操作': ['Deletion can\'t be reverted, please be cautious'],

// 变量的使用 $t('test', { vari1: 1, vari2: 2 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ const showReleaseSideslider = () => {

// 获取资源版本列表
const getResourceVersions = async () => {
const res = await getResourceVersionsList(apigwId.value, { offset: 0, limit: 999 });
versionList.value = res.results;

// 新建的网关,需要传入为 0 的 sourceId 去和空版本做对比
if (formData.version === '1.0.0') {
const response = await getResourceVersionsList(apigwId.value, { offset: 0, limit: 999 });
versionList.value = response.results;
// 如果此网关还未生成版本,或这是网关的第一个版本(版本号为 1.0.0),则与空网关版本对比(版本ID为0)
if (!response.results.length || response.results[0]?.version === '1.0.0') {
diffTargetId.value = response.results[0]?.id || '';
diffSourceId.value = 0;
} else {
diffSourceId.value = versionList.value[0]?.id || '';
diffSourceId.value = response.results[0]?.id || '';
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/dashboard-front/src/views/resource/setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,13 @@ const handleOutBatch = () => {
// 版本对比
const handleShowDiff = async () => {
try {
const res = await getResourceVersionsList(props.apigwId, { offset: 0, limit: 999 });
// 如果是此网关的第一个版本(版本号为 1.0.0),则与空网关版本对比(版本ID为0)
if (res.results[0]?.version === '1.0.0') {
diffTargetId.value = res.results[0].id;
const response = await getResourceVersionsList(props.apigwId, { offset: 0, limit: 999 });
// 如果此网关还未生成版本,或这是网关的第一个版本(版本号为 1.0.0),则与空网关版本对比(版本ID为0)
if (!response.results.length || response.results[0]?.version === '1.0.0') {
diffTargetId.value = response.results[0]?.id || '';
diffSourceId.value = 0;
} else {
diffSourceId.value = res.results[0]?.id || '';
diffSourceId.value = response.results[0]?.id || '';
}
diffSidesliderConf.width = window.innerWidth <= 1280 ? 1040 : 1280;
diffSidesliderConf.isShow = true;
Expand Down
Loading