Skip to content

Commit

Permalink
Merge pull request #1074 from shuzhenyang/fix_experience
Browse files Browse the repository at this point in the history
fix(online-debug): 在线调试体验问题修复
  • Loading branch information
jinquantianxia authored Oct 28, 2024
2 parents 422afc0 + 4c98605 commit 8e909e2
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/dashboard-front/src/components/ag-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,21 @@ defineExpose({
</script>
<style scoped lang="scss">
.codemirror,
.monaco-editor {
width: 100%;
height: 100%;
}
.codemirror {
position: relative;
width: 100%;
height: calc(100% - 26px);
.monaco-editor {
position: absolute;
top: 26px;
bottom: 0;
left: 0;
right: 0;
}
.tools {
position: absolute;
top: 5px;
right: 28px;
right: 14px;
display: flex;
align-items: center;
.tool-icon {
Expand Down
1 change: 1 addition & 0 deletions src/dashboard-front/src/language/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ const lang: ILANG = {
'发布时间:': ['Release Time:'],
'你可能想进行以下操作:': ['You may want to perform the following actions:'],
'在线调试 API 资源': ['Online debugging APIs'],
'至少需要保留一行!': ['You need to keep at least one line! '],
'查看 API 文档': ['View api doc'],
'为蓝鲸应用主动授权': ['Add permissions for app'],
'生成 API 资源 SDK': ['Generate SDK'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ const addRow = (index: number) => {
};
const delRow = (index: number) => {
if (tableData.value.length === 1) {
Message({
theme: 'warning',
message: t('至少需要保留一行!'),
});
return;
}
const row = tableData.value[index];
checkedList.value = checkedList.value.filter(item => item.id !== row.id);
tableData.value?.splice(index, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<bk-sideslider
v-model:isShow="isShow"
v-model:is-show="isShow"
:title="t('调用历史')"
:width="960"
class="sutra-scrollbar"
Expand Down Expand Up @@ -44,6 +44,7 @@
:data="tableList"
:row-style="{ cursor: 'pointer' }"
:show-overflow-tooltip="true"
:cell-class="getCellClass"
>
<bk-table-column :label="t('资源名称')" prop="resource_name"></bk-table-column>
<bk-table-column :label="t('响应状态码')" prop="status_code">
Expand Down Expand Up @@ -122,6 +123,7 @@ const tableEmptyConf = reactive<any>({
keyword: '',
isAbnormal: false,
});
let expandIds: number[] = [];
const updateTableEmptyConfig = () => {
// if (!curPagination.value.count) {
Expand Down Expand Up @@ -177,6 +179,7 @@ const handleRowClick = async (e: Event, row: Record<string, any>) => {
await getDetails(row.id, row);
} else {
row.isExpand = !row.isExpand;
expandIds = expandIds.filter((id: number) => id !== row.id);
nextTick(() => {
tableRef.value.setRowExpand(row, row.isExpand);
});
Expand Down Expand Up @@ -215,11 +218,19 @@ const getDetails = async (id: number, row: Record<string, any>) => {
row.editorText = res?.response?.data?.curl;
row.isExpand = !row.isExpand;
expandIds.push(id);
nextTick(() => {
tableRef.value.setRowExpand(row, row.isExpand);
});
};
const getCellClass = (_column: any, _index: number, row: any) => {
if (expandIds.includes(row.id)) {
return 'td-highlight-bg';
}
return '';
};
defineExpose({
show,
});
Expand Down Expand Up @@ -262,3 +273,9 @@ defineExpose({
}
}
</style>

<style>
.td-highlight-bg {
background: #f5f7fa !important;
}
</style>
50 changes: 45 additions & 5 deletions src/dashboard-front/src/views/online-debug/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
type="search"
/>
</div>
<bk-collapse class="my-menu" v-model="activeName" v-if="Object.keys(resourceGroup).length">
<bk-collapse class="my-menu" v-model="activeName" v-if="resourceGroupLength">
<template v-for="group of resourceGroup">
<bk-collapse-panel
v-if="group?.resources?.length"
Expand Down Expand Up @@ -79,7 +79,7 @@
</div>
</template>
<template #main>
<div class="resize-main">
<div class="resize-main" v-show="resourceGroupLength">
<div class="request-setting">
<bk-collapse
class="request-setting-collapse"
Expand Down Expand Up @@ -225,7 +225,7 @@

<div class="edit-user-tips">
<info-line class="icon" />
<span class="tips">{{ t('默认测试应用,网关自动为其短期授权;自定义应用,需主动为应用授权资源访问权限') }}</span>
<span class="tips">{{ t('默认用户认证,将默认从 Cookies 中获取用户认证信息;自定义用户认证,可自定义用户认证信息') }}</span>
</div>
<!-- <div class="edit-user-btns">
<bk-button theme="primary" @click="saveUserAuthEdit">{{ t('保存') }}</bk-button>
Expand Down Expand Up @@ -277,19 +277,28 @@
</template>
</bk-resize-layout>
</div>

<div class="exception-part" v-show="!resourceGroupLength">
<bk-exception
class="exception-wrap-item"
:description="t('暂无数据')"
scene="part"
type="empty"
/>
</div>
</template>
</bk-resize-layout>

<!-- 查看文档侧栏 -->
<bk-sideslider v-model:isShow="isShowDoc" :width="960" quick-close>
<bk-sideslider v-model:is-show="isShowDoc" :width="960" quick-close>
<template #header>
<div class="custom-side-header">
<div class="title">{{ t('查看文档详情') }}</div>
<span></span>
<div class="subtitle">{{ curResource?.name }}</div>

<div class="opt-btns">
<share class="opt-share" />
<share class="opt-share" v-show="curResource?.is_public" @click="openTab(curResource?.name)" />
<close-line class="opt-close" @click="isShowDoc = false" />
</div>
</div>
Expand All @@ -312,6 +321,7 @@ import responseContent from '@/views/online-debug/components/response-content.vu
import doc from '@/views/online-debug/components/doc.vue';
import TableEmpty from '@/components/table-empty.vue';
import { useCommon } from '@/store';
import { useRouter } from 'vue-router';
import { Message } from 'bkui-vue';
import {
getStages,
Expand All @@ -324,6 +334,7 @@ import {
const { t } = useI18n();
const common = useCommon();
const router = useRouter();
const isLoading = ref<boolean>(false);
const keyword = ref<string>('');
Expand Down Expand Up @@ -542,6 +553,10 @@ const resourceGroup = computed(() => {
return group;
});
const resourceGroupLength = computed(() => {
return Object.keys(resourceGroup.value)?.length;
});
const getItemName = (item: any) => {
if (!['unreleased', 'failure'].includes(item?.release?.status)) {
return item.name;
Expand Down Expand Up @@ -844,6 +859,21 @@ const viewDoc = (e: Event) => {
isShowDoc.value = true;
};
const openTab = (name?: string) => {
if (!name) {
return;
}
const routeData = router.resolve({
name: 'apiDocDetail',
params: {
curTab: 'apigw',
targetName: common?.apigwName,
componentName: name,
},
});
window.open(routeData.href, '_blank');
};
const init = async () => {
await getApigwDetail();
getApigwStages();
Expand Down Expand Up @@ -1198,4 +1228,14 @@ watch(
flex-direction: column;
height: 100%;
}
.exception-part {
background-color: #fff;
height: 100%;
margin: 24px;
box-sizing: border-box;
.exception-wrap-item {
height: 100%;
justify-content: center;
}
}
</style>

0 comments on commit 8e909e2

Please sign in to comment.