2025-06-22 23:08:40 +08:00
|
|
|
|
<template>
|
2025-12-27 17:29:21 +08:00
|
|
|
|
<BaseToolCall :tool-call="toolCall" :hide-params="true">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
查询:
|
|
|
|
|
|
<span class="keywords">"{{ query }}"</span>
|
|
|
|
|
|
</template>
|
2025-12-27 14:50:32 +08:00
|
|
|
|
<template #result="{ resultContent }">
|
|
|
|
|
|
<div class="web-search-result">
|
|
|
|
|
|
<div class="search-results">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(result, index) in parsedData(resultContent).results"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="search-result-item"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="result-header">
|
|
|
|
|
|
<h5 class="result-title">
|
|
|
|
|
|
<a :href="result.url" target="_blank" rel="noopener noreferrer">
|
|
|
|
|
|
{{ result.title }}
|
|
|
|
|
|
</a>
|
|
|
|
|
|
</h5>
|
|
|
|
|
|
<span class="result-score">相关度: {{ (result.score * 100).toFixed(1) }}%</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="result-meta">
|
|
|
|
|
|
<!-- <span class="result-url">{{ result.url }}</span> -->
|
|
|
|
|
|
<span v-if="result.published_date" class="result-date">
|
|
|
|
|
|
{{ formatDate(result.published_date) }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="result-content">
|
|
|
|
|
|
{{ result.content }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-06-22 23:08:40 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-27 14:50:32 +08:00
|
|
|
|
<div v-if="parsedData(resultContent).results.length === 0" class="no-results">
|
|
|
|
|
|
<p>未找到相关搜索结果</p>
|
2025-06-22 23:08:40 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-12-27 14:50:32 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</BaseToolCall>
|
2025-06-22 23:08:40 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-12-27 14:50:32 +08:00
|
|
|
|
import BaseToolCall from '../BaseToolCall.vue';
|
2025-10-13 15:08:54 +08:00
|
|
|
|
import { parseToShanghai } from '@/utils/time'
|
2025-12-27 17:29:21 +08:00
|
|
|
|
import { computed } from 'vue';
|
2025-06-22 23:08:40 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
2025-12-27 14:50:32 +08:00
|
|
|
|
toolCall: {
|
2025-06-22 23:08:40 +08:00
|
|
|
|
type: Object,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-27 14:50:32 +08:00
|
|
|
|
const parseData = (content) => {
|
|
|
|
|
|
if (typeof content === 'string') {
|
|
|
|
|
|
try {
|
|
|
|
|
|
return JSON.parse(content);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
return { query: '', results: [], response_time: 0 };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return content || { query: '', results: [], response_time: 0 };
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const parsedData = (content) => parseData(content);
|
|
|
|
|
|
|
2025-12-27 17:29:21 +08:00
|
|
|
|
const query = computed(() => {
|
|
|
|
|
|
// First try to get it from result
|
|
|
|
|
|
const result = parsedData(props.toolCall.tool_call_result?.content);
|
|
|
|
|
|
if (result?.query) return result.query;
|
|
|
|
|
|
|
|
|
|
|
|
// Fallback to args
|
|
|
|
|
|
const args = props.toolCall.args || props.toolCall.function?.arguments;
|
|
|
|
|
|
if (!args) return '';
|
|
|
|
|
|
if (typeof args === 'object') return args.query || args.q || '';
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsed = JSON.parse(args);
|
|
|
|
|
|
return parsed.query || parsed.q || '';
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return '';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-06-22 23:08:40 +08:00
|
|
|
|
const formatDate = (dateString) => {
|
|
|
|
|
|
if (!dateString) return ''
|
2025-10-13 15:08:54 +08:00
|
|
|
|
const parsed = parseToShanghai(dateString)
|
|
|
|
|
|
if (!parsed) return ''
|
|
|
|
|
|
return parsed.format('YYYY年MM月DD日')
|
2025-06-22 23:08:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
|
.web-search-result {
|
|
|
|
|
|
background: var(--gray-0);
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
|
2025-12-27 14:50:32 +08:00
|
|
|
|
.search-meta {
|
2025-06-22 23:08:40 +08:00
|
|
|
|
padding: 12px 16px;
|
2025-08-27 09:57:29 +08:00
|
|
|
|
background: var(--gray-25);
|
2025-12-27 14:50:32 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--gray-600);
|
|
|
|
|
|
border-bottom: 1px solid var(--gray-100);
|
2025-06-22 23:08:40 +08:00
|
|
|
|
|
2025-12-27 14:50:32 +08:00
|
|
|
|
.query-text {
|
2025-06-22 23:08:40 +08:00
|
|
|
|
font-weight: 500;
|
2025-12-27 14:50:32 +08:00
|
|
|
|
color: var(--gray-800);
|
2025-06-22 23:08:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-results {
|
|
|
|
|
|
padding: 8px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.search-result-item {
|
|
|
|
|
|
padding: 12px;
|
2025-11-05 02:05:23 +08:00
|
|
|
|
border-bottom: 1px solid var(--gray-200);
|
2025-06-22 23:08:40 +08:00
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
|
2025-11-05 02:05:23 +08:00
|
|
|
|
&:last-child {
|
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-22 23:08:40 +08:00
|
|
|
|
.result-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
2025-11-05 02:05:23 +08:00
|
|
|
|
align-items: center;
|
2025-06-22 23:08:40 +08:00
|
|
|
|
|
|
|
|
|
|
.result-title {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
line-height: 1.4;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
|
color: var(--main-color);
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
2025-07-26 03:36:54 +08:00
|
|
|
|
color: var(--main-color);
|
2025-06-22 23:08:40 +08:00
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.result-score {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
color: var(--gray-600);
|
2025-08-27 09:57:29 +08:00
|
|
|
|
background: var(--gray-50);
|
2025-11-05 02:05:23 +08:00
|
|
|
|
padding: 0px 6px;
|
2025-06-22 23:08:40 +08:00
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.result-meta {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
|
|
|
|
|
|
.result-url {
|
|
|
|
|
|
color: var(--main-400);
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.result-date {
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.result-content {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
color: var(--gray-700);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
display: -webkit-box;
|
2025-11-05 02:05:23 +08:00
|
|
|
|
line-clamp: 2;
|
|
|
|
|
|
-webkit-line-clamp: 2;
|
2025-06-22 23:08:40 +08:00
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.no-results {
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: var(--gray-500);
|
|
|
|
|
|
padding: 20px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-27 17:29:21 +08:00
|
|
|
|
</style>
|