Skip to content

Commit

Permalink
fix(version-diff): 修复未生成任何版本时版本对比无内容的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlmac committed Oct 30, 2024
1 parent 8e909e2 commit 701a55a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
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})'],

// 变量的使用 $t('test', { vari1: 1, vari2: 2 })
// // 变量的使用 $t('test', { vari1: 1, vari2: 2 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const isShow = ref(false);
const dialogShow = ref(false);
const versionList = ref<any>([]);
const formRef = ref(null);
const diffSourceId = ref('');
const diffSourceId = ref<number | string>('');
const diffTargetId = ref('');
const loading = ref(false);
const createError = ref<boolean>(false);
Expand Down Expand Up @@ -324,12 +324,14 @@ const showReleaseSideslider = () => {
// 获取资源版本列表
const getResourceVersions = async () => {
try {
const res = await getResourceVersionsList(apigwId.value, { offset: 0, limit: 999 });
versionList.value = res.results;
diffSourceId.value = versionList.value[0]?.id || '';
} catch (e) {
console.log(e);
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 = response.results[0]?.id || '';
}
};
Expand Down Expand Up @@ -398,7 +400,7 @@ watch(
stepsConfig.value.curStep = 1;
formData.version = '';
formData.comment = '';
};
}
},
);
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

0 comments on commit 701a55a

Please sign in to comment.