Przeglądaj źródła

修改超出页面部分

Hugvvn 1 miesiąc temu
rodzic
commit
ddca211499

+ 2 - 2
src/components/Pagination.vue

@@ -103,8 +103,8 @@ const displayPages = computed<number[]>(() => {
   // 如果窗口与最后一页不连续,加省略号
   if (end < total - 1) pages.push(-1)
 
-  // 始终显示最后一页
-  if (total > 1) pages.push(total)
+  // 始终显示最后一页(窗口中未包含时才加)
+  if (total > 1 && total !== end) pages.push(total)
 
   return pages
 })

+ 7 - 0
src/components/ResultCard.vue

@@ -129,6 +129,8 @@ function truncateText(html: string, maxLength: number): string {
   cursor: pointer;
   transition: all 0.2s;
   border: 1px solid #f0f0f0;
+  overflow-wrap: break-word;
+  word-break: break-word;
 }
 .result-card:hover {
   box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
@@ -186,6 +188,8 @@ function truncateText(html: string, maxLength: number): string {
   margin: 0 0 12px;
   cursor: pointer;
   transition: color 0.2s;
+  overflow-wrap: break-word;
+  word-break: break-word;
 }
 .result-abstract:hover {
   color: #333;
@@ -200,6 +204,7 @@ function truncateText(html: string, maxLength: number): string {
   gap: 6px;
   margin-bottom: 12px;
   flex-wrap: wrap;
+  overflow-wrap: break-word;
 }
 .custom-tag {
   border: 1px solid #d9ecff;
@@ -209,6 +214,8 @@ function truncateText(html: string, maxLength: number): string {
   font-size: 12px;
   border-radius: 2px;
   height: auto;
+  word-break: break-word;
+  overflow-wrap: break-word;
 }
 .result-actions {
   display: flex;

+ 3 - 1
src/components/SearchBar.vue

@@ -22,7 +22,9 @@ const emit = defineEmits<{
 }>()
 
 function handleSearch() {
-  emit('search', props.modelValue)
+  const keyword = props.modelValue.trim()
+  if (!keyword) return  // 空关键词不触发搜索
+  emit('search', keyword)
 }
 </script>
 

+ 3 - 0
src/views/SearchPage.vue

@@ -449,6 +449,9 @@ function mapResultToItem(result: any): any {
 async function doSearch() {
   loading.value = true
   searched.value = true
+  // 先清空旧数据,防止切换页码/条数时旧结果残留
+  results.value = []
+  totalCount.value = 0
   try {
     const body: Record<string, any> = {
       query: searchParams.query || ' ',