| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <div class="chunk-list">
- <a-spin v-if="loading" dot :loading="loading" />
- <div v-else>
- <div v-for="(item, index) in chunks" :key="index">
- <div class="card">
- <AsideImage v-if="item.image_url" :src="item.image_url" />
- <div class="document-reference">
- <a-popover trigger="hover">
- <template #content>
- <div class="popup-markdown">
- <div v-html="highlightText(item.content_with_weight)" />
- </div>
- </template>
- <div v-html="highlightText(item.highlight)" class="highlight-content" />
- </a-popover>
- <div class="file-btn" @click="fileClick(item)">
- <a-space>
- <FileIcon :name="item.docnm_kwd" />
- <div>{{ item.docnm_kwd }}</div>
- </a-space>
- </div>
- </div>
- </div>
- <a-divider :margin="12" v-if="index < chunks.length - 1" />
- </div>
- <div v-if="chunks.length > 1">
- <a-divider />
- <a-pagination
- :current="current_page"
- :total="total"
- :page-size="page_size"
- show-total
- show-page-size
- @change="handlePageChange"
- @page-size-change="handlePageSizeChange"
- />
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { ref } from 'vue';
- import FileIcon from './FileIcon.vue';
- import AsideImage from './PopoverImage.vue';
- const props = defineProps({
- chunks: Array,
- total: {
- type: Number,
- required: true
- },
- highlight_word: String,
- page_size: {
- type: Number,
- default: 10
- },
- loading: Boolean
- });
- const emit = defineEmits(['clickDocumentButton', 'pageChange', 'pageSizeChange']);
- const fileClick = (item) => {
- emit('clickDocumentButton', item);
- };
- const highlightText = (text) => {
- if (!props.highlight_word) return text;
- const regex = new RegExp(`(${props.highlight_word})`, 'gi');
- return text.replace(regex, `<span class="highlighted">$1</span>`);
- };
- const current_page = ref(1);
- const page_size = ref(10);
- const handlePageChange = (page) => {
- current_page.value = page;
- emit('pageChange', page);
- };
- const handlePageSizeChange = (page_size) => {
- page_size.value = page_size;
- emit('pageSizeChange', page_size);
- };
- </script>
- <style scoped>
- .chunk-list {
- text-align: center;
- }
- .card {
- display: flex;
- align-items: center;
- box-sizing: border-box;
- text-align: left;
- padding: 14px;
- padding-bottom: 8px;
- color: var(--color-text-1);
- font-size: 14px;
- list-style: none;
- position: relative;
- background: var(--color-bg-1);
- border: 1px solid var(--color-neutral-3);
- border-radius: 8px;
- }
- .popup-markdown {
- color: var(--color-text-1);
- width: 60vw;
- max-height: 40vh;
- overflow: auto;
- }
- .highlight-content {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .file-btn {
- font-weight: 600;
- cursor: pointer;
- }
- .document-reference {
- margin-left: 8px;
- display: flex;
- flex-direction: column;
- gap: 16px;
- }
- /* 新增高亮样式 */
- :deep(.highlighted) {
- color: red; /* 设置高亮文本为链接颜色 */
- }
- :deep(.arco-pagination) {
- justify-content: end;
- }
- :deep(.arco-pagination-item-active) {
- border-radius: 8px;
- font-weight: 600;
- background-color: var(--color-bg-1);
- }
- :deep(.arco-select-view-single) {
- border-radius: 8px;
- background-color: var(--color-bg-1);
- }
- </style>
|