feat: 重构AI推荐功能并优化爬虫基础URL

重构前端AI推荐组件,移除本地过滤逻辑,改为从后端获取日期范围内的数据
新增AI服务模块,包含Prompt和推荐逻辑
为投标服务添加按日期范围查询接口
统一各爬虫服务的baseURL格式
This commit is contained in:
dmy
2026-01-12 18:59:17 +08:00
parent 61520e9ebf
commit 3d269ce9d1
16 changed files with 131 additions and 51 deletions

View File

@@ -106,7 +106,7 @@
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { ref } from 'vue'
import axios from 'axios'
import { ElMessage } from 'element-plus'
import { MagicStick, Loading, InfoFilled, List } from '@element-plus/icons-vue'
@@ -132,36 +132,6 @@ const showAllBids = ref(false)
const bidsLoading = ref(false)
const bidsByDateRange = ref<any[]>([])
// 根据日期范围过滤 bids
const filteredBids = computed(() => {
let result = props.bids
// 按日期范围筛选(只限制开始时间,不限制结束时间)
if (dateRange.value && dateRange.value.length === 2) {
const [startDate] = dateRange.value
result = result.filter(bid => {
if (!bid.publishDate) return false
const bidDate = new Date(bid.publishDate)
const start = new Date(startDate)
// 设置时间为当天的开始
start.setHours(0, 0, 0, 0)
return bidDate >= start
})
}
return result
})
// 监听日期范围变化并显示提示
watch(dateRange, () => {
const totalBids = props.bids.length
const filteredCount = filteredBids.value.length
if (totalBids > 0 && filteredCount < totalBids) {
ElMessage.info(`筛选结果:共 ${filteredCount} 条数据(总共 ${totalBids} 条)`)
}
})
// 设置日期范围为最近3天
const setLast3Days = () => {
const endDate = new Date()
@@ -200,12 +170,9 @@ const setLast7Days = () => {
const fetchAIRecommendations = async () => {
loading.value = true
try {
// 准备发送给后端的数据(使用过滤后的 bids
const bidsData = filteredBids.value.map(bid => ({
title: bid.title,
url: bid.url,
source: bid.source,
publishDate: bid.publishDate
// 准备发送给后端的数据(只包含 title
const bidsData = bidsByDateRange.value.map(bid => ({
title: bid.title
}))
// 调用后端 API
@@ -213,7 +180,16 @@ const fetchAIRecommendations = async () => {
bids: bidsData
})
aiRecommendations.value = response.data
// 根据 title 从 bidsByDateRange 中更新 url 和 source
aiRecommendations.value = response.data.map((rec: any) => {
const bid = bidsByDateRange.value.find(b => b.title === rec.title)
return {
title: rec.title,
url: bid?.url || '',
source: bid?.source || '',
confidence: rec.confidence
}
})
ElMessage.success('AI 推荐获取成功')
} catch (error: any) {