AI修复建议接口对接

This commit is contained in:
付民康
2025-03-19 21:43:36 +08:00
parent 75d503a96d
commit 6761ce1a49
2 changed files with 70 additions and 57 deletions

View File

@@ -98,15 +98,11 @@ export function getDepencyList(softwareId: string) {
} }
// 获取AI修复建议 // 获取AI修复建议
export function getRepairInfo() { export function getRepairInfo(data) {
return request({ return request({
url: '/api/v1/repo/repair/info', url: '/api/v1/repo/repair/info',
method: 'POST', method: 'POST',
data: { data
"current": 1,
"size": 10,
"softwareId": 47
}
}); });
} }

View File

@@ -13,8 +13,9 @@
</div> </div>
</div> </div>
<div class="ai-container"> <div class="ai-container">
<div class="ai-container-card" style="width: 100%;" v-for="(rowItem, index) in list" :key="index"> <template v-if="tableData.length>0">
<Panel :expand="rowItem.expand"> <div class="ai-container-card" style="width: 100%;" v-for="(rowItem, index) in tableData" :key="index">
<Panel :expand="!rowItem.expand">
<template #header> <template #header>
<div class="ai-panel-header"> <div class="ai-panel-header">
<div style="padding: 25px 8px 0px 20px;"> <div style="padding: 25px 8px 0px 20px;">
@@ -23,10 +24,10 @@
<div style="width: 100%; padding: 20px 20px 0px 0;"> <div style="width: 100%; padding: 20px 20px 0px 0;">
<div class="ai-panel-header-title"> <div class="ai-panel-header-title">
<div> <div>
<d-tag color="red-w98" class="mr-1" size="sm">严重</d-tag> <d-tag color="red-w98" class="mr-1" size="sm">{{'严重'}}</d-tag>
<span>{{ rowItem.title }}</span> <span>{{rowItem.libraryName||'--'}}</span>
</div> </div>
<div style="cursor: pointer; display: flex; gap: 8px; align-items: center;" @click="rowItem.expand = !rowItem.expand"> <div style="cursor: pointer; display: flex; gap: 8px; align-items: center;" @click="rowItem.expand == rowItem.expand">
<img style="width: 14px; height: 14px;" src="@/assets/imgs/jyh/collapseIcon.png"> <img style="width: 14px; height: 14px;" src="@/assets/imgs/jyh/collapseIcon.png">
<span>全部收起</span> <span>全部收起</span>
</div> </div>
@@ -34,19 +35,19 @@
<div class="ai-panel-header-sub-title"> <div class="ai-panel-header-sub-title">
<div> <div>
<span class="weak-text">安全问题</span> <span class="weak-text">安全问题</span>
<span>2</span> <span>{{rowItem.vulnerabilities.length ||'--'}}</span>
</div> </div>
<div> <div>
<span class="weak-text">修复兼容性</span> <span class="weak-text">修复兼容性</span>
<span>2</span> <span>{{rowItem.vulnerabilities.length ||'--'}}</span>
<img src="@/assets/imgs/jyh/help.png" class="icon-sm"> <img src="@/assets/imgs/jyh/help.png" class="icon-sm">
<d-tag class="ml-1" type="warning" size="sm"></d-tag> <d-tag class="ml-1" type="warning" size="sm">{{rowItem.vulnerabilities.length>0?rowItem.vulnerabilities[0].severity:'--'}}</d-tag>
</div> </div>
<div> <div>
<span class="weak-text">升级版本</span> <span class="weak-text">升级版本</span>
<span>1.7.0</span> <span>{{rowItem.currentVersion ||'--'}}</span>
<img src="@/assets/imgs/jyh/ic_digital_power_next_step_@2x.png" class="icon-sm"> <img src="@/assets/imgs/jyh/ic_digital_power_next_step_@2x.png" class="icon-sm">
<span>1.9.1</span> <span>{{rowItem.currentVersion ||'--'}}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -55,21 +56,24 @@
<template #body> <template #body>
<div style="padding: 8px 20px 20px 20px; width: 100%;"> <div style="padding: 8px 20px 20px 20px; width: 100%;">
<Table :tableConfig="tableConfig" :dataSource="rowItem.data.listData"/> <Table class="jyh-table" :tableConfig="tableConfig" :dataSource="rowItem.vulnerabilities"/>
<div class="w-full flex items-center justify-end"><span>{{ rowItem.data.listData.length }}</span></div> <div class="w-full flex items-center justify-end"><span>{{ rowItem.vulnerabilities.length }}</span></div>
</div> </div>
</template> </template>
</Panel> </Panel>
</div> </div>
</template>
<NoData v-else :small="false"></NoData>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import { ref,onMounted,defineProps } from 'vue';
import Panel from '@/components/AIRepair/Panel.vue'; import Panel from '@/components/AIRepair/Panel.vue';
import Table from '@/components/AIRepair/Table.vue'; import Table from '@/components/AIRepair/Table.vue';
import NoData from '@/components/NoData/NoData.vue';
import { getRepairInfo } from '@/api/jyh'; import { getRepairInfo } from '@/api/jyh';
const propsData = defineProps(['versionId']);
const infoList = ref([ const infoList = ref([
'当前代码主要风险为易受常见的注入攻击包括命令注入、SQL注入、表达式注入针对每种攻击应提供相应的防范措施如数据校验、使用安全函数和限制程序权限。', '当前代码主要风险为易受常见的注入攻击包括命令注入、SQL注入、表达式注入针对每种攻击应提供相应的防范措施如数据校验、使用安全函数和限制程序权限。',
'相对上一次检查【提升点】在于代码基础编码问题少了47.8%问题总数降低29.3%' '相对上一次检查【提升点】在于代码基础编码问题少了47.8%问题总数降低29.3%'
@@ -77,25 +81,25 @@ const infoList = ref([
const tableConfig = ref([ const tableConfig = ref([
{ {
field: 'securityProblemCode', field: 'vulnId',
header: '安全问题编号', header: '安全问题编号',
sortable: true, sortable: true,
sortMethod: null sortMethod: null
}, },
{ {
field: 'type', field: 'vulnType',
header: '安全问题类型', header: '安全问题类型',
sortable: false, sortable: false,
sortMethod: null sortMethod: null
}, },
{ {
field: 'CWEcode', field: 'vulnId',
header: 'CWE编号', header: 'CWE编号',
sortable: false, sortable: false,
sortMethod: null sortMethod: null
}, },
{ {
field: 'score', field: 'cvssScore',
header: '分值', header: '分值',
sortable: true, sortable: true,
sortMethod: null sortMethod: null
@@ -147,9 +151,22 @@ const list = ref([
]) ])
const getInfo = async() => { const getInfo = async() => {
const res = await getRepairInfo(); const { data } = await getRepairInfo({
"current": 1,
"size": 10,
"softwareId": 47,
// softwareId: propsData.versionId,
});
debugger
if(data.code===200) {
tableData.value = data?.data?.components || [];
// pager.value.total = data?.data?.data?.total || [];
} }
getInfo(); }
const tableData = ref([]);
onMounted( () => {
getInfo()
});
</script> </script>