feat: 添加爬虫状态监控功能
新增爬虫统计信息展示组件,包括后端数据查询接口和前端展示界面。同时简化日期显示格式并添加刷新提示功能。
This commit is contained in:
@@ -2,25 +2,43 @@
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import PinnedBids from './components/PinnedBids.vue'
|
||||
import AiRecommendations from './components/AiRecommendations.vue'
|
||||
import WidgetCrawlInfo from './components/WidgetCrawlInfo.vue'
|
||||
|
||||
const activeTab = ref('pinned')
|
||||
const pinnedBidsRef = ref<InstanceType<typeof PinnedBids>>()
|
||||
const aiRecommendationsRef = ref<InstanceType<typeof AiRecommendations>>()
|
||||
const widgetCrawlInfoRef = ref<InstanceType<typeof WidgetCrawlInfo>>()
|
||||
let refreshTimer: number | null = null
|
||||
const showToast = ref(false)
|
||||
const toastMessage = ref('')
|
||||
|
||||
const tabs = [
|
||||
{ id: 'pinned', label: '置顶项目' },
|
||||
{ id: 'ai', label: 'AI 推荐' }
|
||||
{ id: 'ai', label: 'AI 推荐' },
|
||||
{ id: 'status', label: '状态' }
|
||||
]
|
||||
|
||||
const handleRefresh = () => {
|
||||
if (activeTab.value === 'pinned' && pinnedBidsRef.value) {
|
||||
pinnedBidsRef.value.loadPinnedBids()
|
||||
showToastMessage('置顶项目已刷新')
|
||||
} else if (activeTab.value === 'ai' && aiRecommendationsRef.value) {
|
||||
aiRecommendationsRef.value.loadRecommendations()
|
||||
showToastMessage('AI 推荐已刷新')
|
||||
} else if (activeTab.value === 'status' && widgetCrawlInfoRef.value) {
|
||||
widgetCrawlInfoRef.value.loadCrawlStats()
|
||||
showToastMessage('状态已刷新')
|
||||
}
|
||||
}
|
||||
|
||||
const showToastMessage = (message: string) => {
|
||||
toastMessage.value = message
|
||||
showToast.value = true
|
||||
setTimeout(() => {
|
||||
showToast.value = false
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
const startAutoRefresh = () => {
|
||||
// 每5分钟(300000毫秒)自动刷新
|
||||
refreshTimer = window.setInterval(() => {
|
||||
@@ -63,6 +81,11 @@ onUnmounted(() => {
|
||||
<div class="tab-content">
|
||||
<PinnedBids v-if="activeTab === 'pinned'" ref="pinnedBidsRef"/>
|
||||
<AiRecommendations v-else-if="activeTab === 'ai'" ref="aiRecommendationsRef"/>
|
||||
<WidgetCrawlInfo v-else-if="activeTab === 'status'" ref="widgetCrawlInfoRef"/>
|
||||
</div>
|
||||
|
||||
<div v-if="showToast" class="toast">
|
||||
{{ toastMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -146,4 +169,27 @@ body {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.toast {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: #fff;
|
||||
padding: 12px 24px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
z-index: 1000;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user