frontend: print the 参考文献 block as entries, not quotes

The card listed the quoted passage where the bibliography entry belongs, under
a `引用 #53` tag that named a database id rather than the work. It now prints
the server's `references` verbatim — one line per work, already formatted in
Springer's basic style — with the fields a complete entry still lacks shown as
「缺 责任者、出版年」, and the paragraphs that cite it underneath:

    1 引言 / Introduction
    2.1 技术主题识别 / Technology Topic Identification ×2

Each of those links carries the quoted passages for that paragraph in its
tooltip, which is where the quote belongs: it is evidence for a citation, not
the citation itself. The client formats nothing and groups nothing but the
paragraph labels — a second implementation of "which work is number 7" would
eventually disagree with the first.

The marker tooltip in the text stops saying `引用 #53` too and shows the entry
it points at, so hovering a `[7]` answers the question the number raises.
This commit is contained in:
2026-09-22 21:50:39 +08:00
parent 54292eb231
commit 340e0777ce
3 changed files with 200 additions and 22 deletions
+135 -15
View File
@@ -29,7 +29,6 @@ import {
Delete,
Edit,
Refresh,
Right,
Switch,
Warning,
} from '@element-plus/icons-vue'
@@ -41,8 +40,10 @@ import {
getPaperDocument,
PAPER_STATUS_LABELS,
PAPER_STATUS_TAG,
referenceStyleLabel,
type PaperDocument,
type PaperParagraph,
type PaperReference,
} from '@/api/papers'
import PaperFormDialog from '@/components/papers/PaperFormDialog.vue'
import ParagraphEditDialog from '@/components/papers/ParagraphEditDialog.vue'
@@ -77,6 +78,52 @@ const citationIndex = computed<Record<number, number>>(() => {
return map
})
/**
* Reference id -> the formatted entry, for the marker tooltips.
*
* The tooltip on a `[7]` in the text should say what `[7]` *is*, and the entry
* is assembled once by the server — this is a lookup of that same string, not a
* second attempt at formatting it.
*/
const referenceText = computed<Record<number, string>>(() => {
const map: Record<number, string> = {}
for (const entry of paperDoc.value?.references ?? []) {
if (entry.reference_id != null && entry.text) {
map[entry.reference_id] = entry.text
}
}
return map
})
/** How the entries are printed, named rather than hard-coded in the view. */
const styleLabel = computed(() =>
referenceStyleLabel(paperDoc.value?.reference_style ?? 'springer'),
)
/**
* Where an entry is cited, one row per paragraph.
*
* The same work cited twice in one paragraph is one place with a count, not two
* identical links: what the reader needs from the list is where to look, and
* the quotes for that paragraph travel in the tooltip.
*/
function places(entry: PaperReference): { sort: number; name: string; quotes: string[] }[] {
const byParagraph = new Map<number, { sort: number; name: string; quotes: string[] }>()
for (const citation of entry.citations) {
const found = byParagraph.get(citation.paper_template_filed_sort)
if (found) {
found.quotes.push(citation.quote)
continue
}
byParagraph.set(citation.paper_template_filed_sort, {
sort: citation.paper_template_filed_sort,
name: citation.paragraph_name ?? PARAGRAPH_UNSET_LABEL,
quotes: [citation.quote],
})
}
return [...byParagraph.values()]
}
/** How much of the structure has been written, for the header read-out. */
const progress = computed(() => {
if (!paperDoc.value) return { written: 0, total: 0, unmatched: 0 }
@@ -268,33 +315,69 @@ onMounted(load)
:key="paragraph.paper_template_filed_sort"
:paragraph="paragraph"
:citation-index="citationIndex"
:reference-text="referenceText"
@edit="openParagraph"
/>
</div>
</el-card>
<el-card v-if="paperDoc?.citations.length" shadow="never">
<el-card v-if="paperDoc?.references.length" shadow="never">
<template #header>
<div class="paper-head">
<span class="paper-title">参考文献引用</span>
<span class="paper-hint">按正文出现顺序编号,正文中的上标与这里的序号一一对应</span>
<span class="paper-title">参考文献</span>
<span class="paper-hint">
按正文首次出现顺序编号,同一篇文献在多处引用共用同一个序号;条目按 {{ styleLabel }} 排版
</span>
</div>
</template>
<ol class="references">
<li v-for="citation in paperDoc.citations" :key="citation.id" class="reference">
<span class="reference-index">[{{ citation.index }}]</span>
<li v-for="entry in paperDoc.references" :key="entry.index" class="reference">
<span class="reference-index">[{{ entry.index }}]</span>
<div class="reference-body">
<div class="reference-quote">{{ citation.quote }}</div>
<!-- The entry as it prints. Whatever the library is missing shows
up as a shorter entry, so the gap is named underneath rather
than quietly filled in. -->
<p v-if="entry.text" class="reference-text">{{ entry.text }}</p>
<p v-else class="reference-text reference-text--unlinked">
这处引用还没有关联文献库条目,只有引用内容。
</p>
<div class="reference-meta">
<el-tag v-if="citation.reference_id" size="small" effect="plain">
引用 #{{ citation.reference_id }}
<el-tag
v-if="entry.missing.length"
type="warning"
size="small"
effect="plain"
>
缺 {{ entry.missing.join('、') }}
</el-tag>
<el-tag v-else size="small" type="warning" effect="plain">未关联引用 id</el-tag>
<el-button link type="primary" @click="scrollToParagraph(citation.paper_template_filed_sort)">
{{ citation.paragraph_name ?? PARAGRAPH_UNSET_LABEL }}
<el-icon><Right /></el-icon>
</el-button>
<el-tag v-if="!entry.reference_id" type="warning" size="small" effect="plain">
未关联文献
</el-tag>
<span class="reference-places">
<span class="reference-places-label">引用位置</span>
<el-tooltip
v-for="place in places(entry)"
:key="place.sort"
placement="top"
:show-after="200"
>
<template #content>
<div class="place-tip">
<div v-for="(quote, index) in place.quotes" :key="index">
「{{ quote }}」
</div>
</div>
</template>
<el-button link type="primary" @click="scrollToParagraph(place.sort)">
{{ place.name }}
<span v-if="place.quotes.length > 1" class="place-count">
×{{ place.quotes.length }}
</span>
</el-button>
</el-tooltip>
</span>
</div>
</div>
</li>
@@ -446,19 +529,56 @@ onMounted(load)
.reference-body {
min-width: 0;
flex: 1 1 auto;
}
.reference-quote {
/* The entry, printed as the style wrote it: one line of running text, hanging
under its number like a bibliography. */
.reference-text {
margin: 0;
font-size: 13px;
line-height: 1.8;
color: var(--el-text-color-regular);
overflow-wrap: anywhere;
}
.reference-text--unlinked {
color: var(--el-color-warning);
}
.reference-meta {
display: flex;
align-items: center;
gap: 8px;
margin-top: 4px;
flex-wrap: wrap;
}
.reference-places {
display: inline-flex;
align-items: center;
gap: 2px;
flex-wrap: wrap;
font-size: 12px;
color: var(--el-text-color-secondary);
}
.reference-places-label {
margin-right: 2px;
color: var(--el-text-color-placeholder);
}
.place-count {
margin-left: 2px;
color: var(--el-text-color-placeholder);
font-variant-numeric: tabular-nums;
}
.place-tip {
display: flex;
flex-direction: column;
gap: 4px;
max-width: 420px;
line-height: 1.7;
}
</style>