|
@@ -86,13 +86,18 @@ export default defineComponent({
|
|
|
const hasMore = ref(false);
|
|
|
const searchQuery = ref('');
|
|
|
const isSearching = ref(false);
|
|
|
+ const localTotal = ref(props.total);
|
|
|
+
|
|
|
+ // 监听props中的total变化
|
|
|
+ watch(() => props.total, (newTotal) => {
|
|
|
+ localTotal.value = newTotal;
|
|
|
+ });
|
|
|
|
|
|
// 监听 searchResults 变化
|
|
|
watch(() => props.searchResults, (newResults) => {
|
|
|
displayResults.value = newResults;
|
|
|
hasMore.value = displayResults.value.length < props.total;
|
|
|
}, { immediate: true });
|
|
|
-
|
|
|
// 格式化日期
|
|
|
const formatDate = (date) => {
|
|
|
return dayjs(date).format('YYYY-MM-DD');
|
|
@@ -122,11 +127,13 @@ export default defineComponent({
|
|
|
displayResults.value = response.data.data.results || [];
|
|
|
// 添加调试日志
|
|
|
console.log('Total Results:', response.data.data.total_results);
|
|
|
+ localTotal.value = response.data.data.total_results || 0;
|
|
|
emit('update:total', response.data.data.total_results || 0);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('Web search failed:', error);
|
|
|
displayResults.value = [];
|
|
|
+ localTotal.value = 0;
|
|
|
emit('update:total', 0);
|
|
|
} finally {
|
|
|
isSearching.value = false;
|
|
@@ -137,13 +144,14 @@ export default defineComponent({
|
|
|
const clearSearch = () => {
|
|
|
searchQuery.value = '';
|
|
|
displayResults.value = [];
|
|
|
+ localTotal.value = 0;
|
|
|
emit('update:total', 0);
|
|
|
};
|
|
|
|
|
|
return {
|
|
|
displayResults,
|
|
|
loading: props.loading,
|
|
|
- total: props.total,
|
|
|
+ total: localTotal,
|
|
|
hasMore,
|
|
|
formatDate,
|
|
|
searchQuery,
|