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:
@@ -116,7 +116,14 @@ export interface PaperParagraph {
|
|||||||
|
|
||||||
/** One citation as it appears in the 参考文献 list. */
|
/** One citation as it appears in the 参考文献 list. */
|
||||||
export interface PaperCitation extends Citation {
|
export interface PaperCitation extends Citation {
|
||||||
/** The number shown in the text as `[index]`, in reading order. */
|
/**
|
||||||
|
* The number shown in the text as `[index]`, in reading order.
|
||||||
|
*
|
||||||
|
* It is the number of the **work**, not of the citation: a paper that cites
|
||||||
|
* the same article in three sentences prints `[7]` three times and lists the
|
||||||
|
* article once. Everything that numbers citations reads it from here, so the
|
||||||
|
* markers and the list cannot disagree.
|
||||||
|
*/
|
||||||
index: number
|
index: number
|
||||||
sentence_id: number
|
sentence_id: number
|
||||||
sentence_content: string
|
sentence_content: string
|
||||||
@@ -124,11 +131,35 @@ export interface PaperCitation extends Citation {
|
|||||||
paragraph_name: string | null
|
paragraph_name: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One entry of the 参考文献 list: one work, however often it is cited.
|
||||||
|
*
|
||||||
|
* `text` is the whole entry as it prints, already formatted by the server in
|
||||||
|
* `reference_style`. A client prints it verbatim — assembling a bibliography
|
||||||
|
* from fields is a second implementation of a rule, and the two would drift.
|
||||||
|
*/
|
||||||
|
export interface PaperReference {
|
||||||
|
/** The number the text shows as `[index]`. */
|
||||||
|
index: number
|
||||||
|
/** The library row it came from, or `null` for a citation written before the
|
||||||
|
* literature was entered — `text` is empty in that case, and nothing is
|
||||||
|
* invented to fill it. */
|
||||||
|
reference_id: number | null
|
||||||
|
text: string
|
||||||
|
/** What a complete entry still lacks, in Chinese — 责任者、出版年、DOI… */
|
||||||
|
missing: string[]
|
||||||
|
/** Every place in the text that cites it, in reading order. */
|
||||||
|
citations: PaperCitation[]
|
||||||
|
}
|
||||||
|
|
||||||
/** The whole paper as it reads. */
|
/** The whole paper as it reads. */
|
||||||
export interface PaperDocument {
|
export interface PaperDocument {
|
||||||
paper: PaperDetail
|
paper: PaperDetail
|
||||||
paragraphs: PaperParagraph[]
|
paragraphs: PaperParagraph[]
|
||||||
citations: PaperCitation[]
|
citations: PaperCitation[]
|
||||||
|
references: PaperReference[]
|
||||||
|
/** The citation style the entries were written in, e.g. `springer`. */
|
||||||
|
reference_style: string
|
||||||
warnings: string[]
|
warnings: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +249,16 @@ export async function getPaperDocument(id: number): Promise<PaperDocument> {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Display names for the citation styles the server can print. */
|
||||||
|
export const REFERENCE_STYLE_LABELS: Record<string, string> = {
|
||||||
|
springer: 'Springer 基本格式',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The label for a style token, falling back to the token itself. */
|
||||||
|
export function referenceStyleLabel(style: string): string {
|
||||||
|
return REFERENCE_STYLE_LABELS[style] ?? style
|
||||||
|
}
|
||||||
|
|
||||||
export async function createPaper(payload: PaperPayload): Promise<PaperDetail> {
|
export async function createPaper(payload: PaperPayload): Promise<PaperDetail> {
|
||||||
const { data } = await http.post<PaperDetail>('/papers', payload)
|
const { data } = await http.post<PaperDetail>('/papers', payload)
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ const props = defineProps<{
|
|||||||
paragraph: PaperParagraph
|
paragraph: PaperParagraph
|
||||||
/** Citation id -> the number shown in the text, assigned by reading order. */
|
/** Citation id -> the number shown in the text, assigned by reading order. */
|
||||||
citationIndex: Record<number, number>
|
citationIndex: Record<number, number>
|
||||||
|
/** Reference id -> its formatted entry, so a marker can say what it points at. */
|
||||||
|
referenceText: Record<number, string>
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{ edit: [paragraph: PaperParagraph] }>()
|
defineEmits<{ edit: [paragraph: PaperParagraph] }>()
|
||||||
@@ -106,12 +108,19 @@ const anchor = computed(() => `paragraph-${props.paragraph.paper_template_filed_
|
|||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="cite-tip">
|
<div class="cite-tip">
|
||||||
<div class="cite-tip-head">
|
<div class="cite-tip-head">[{{ citationIndex[citation.id] ?? '?' }}]</div>
|
||||||
[{{ citationIndex[citation.id] ?? '?' }}]
|
<!-- What the number means: the entry as the bibliography prints
|
||||||
<span v-if="citation.reference_id">引用 #{{ citation.reference_id }}</span>
|
it, not its database id. -->
|
||||||
<span v-else class="cite-tip-unlinked">未关联引用 id</span>
|
<div
|
||||||
|
v-if="citation.reference_id != null && referenceText[citation.reference_id]"
|
||||||
|
class="cite-tip-entry"
|
||||||
|
>
|
||||||
|
{{ referenceText[citation.reference_id] }}
|
||||||
</div>
|
</div>
|
||||||
<div class="cite-tip-quote">{{ citation.quote }}</div>
|
<div v-else class="cite-tip-unlinked">
|
||||||
|
这处引用还没有关联文献库条目
|
||||||
|
</div>
|
||||||
|
<div class="cite-tip-quote">「{{ citation.quote }}」</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<sup class="cite-mark">{{ citationIndex[citation.id] ?? '?' }}</sup>
|
<sup class="cite-mark">{{ citationIndex[citation.id] ?? '?' }}</sup>
|
||||||
@@ -222,7 +231,7 @@ const anchor = computed(() => `paragraph-${props.paragraph.paper_template_filed_
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cite-tip {
|
.cite-tip {
|
||||||
max-width: 320px;
|
max-width: 380px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cite-tip-head {
|
.cite-tip-head {
|
||||||
@@ -232,7 +241,15 @@ const anchor = computed(() => `paragraph-${props.paragraph.paper_template_filed_
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The bibliography entry: the whole point of the tooltip. It is set as a
|
||||||
|
paragraph of running text because that is how it prints in the list. */
|
||||||
|
.cite-tip-entry {
|
||||||
|
margin-top: 4px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
.cite-tip-unlinked {
|
.cite-tip-unlinked {
|
||||||
|
margin-top: 4px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
Delete,
|
Delete,
|
||||||
Edit,
|
Edit,
|
||||||
Refresh,
|
Refresh,
|
||||||
Right,
|
|
||||||
Switch,
|
Switch,
|
||||||
Warning,
|
Warning,
|
||||||
} from '@element-plus/icons-vue'
|
} from '@element-plus/icons-vue'
|
||||||
@@ -41,8 +40,10 @@ import {
|
|||||||
getPaperDocument,
|
getPaperDocument,
|
||||||
PAPER_STATUS_LABELS,
|
PAPER_STATUS_LABELS,
|
||||||
PAPER_STATUS_TAG,
|
PAPER_STATUS_TAG,
|
||||||
|
referenceStyleLabel,
|
||||||
type PaperDocument,
|
type PaperDocument,
|
||||||
type PaperParagraph,
|
type PaperParagraph,
|
||||||
|
type PaperReference,
|
||||||
} from '@/api/papers'
|
} from '@/api/papers'
|
||||||
import PaperFormDialog from '@/components/papers/PaperFormDialog.vue'
|
import PaperFormDialog from '@/components/papers/PaperFormDialog.vue'
|
||||||
import ParagraphEditDialog from '@/components/papers/ParagraphEditDialog.vue'
|
import ParagraphEditDialog from '@/components/papers/ParagraphEditDialog.vue'
|
||||||
@@ -77,6 +78,52 @@ const citationIndex = computed<Record<number, number>>(() => {
|
|||||||
return map
|
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. */
|
/** How much of the structure has been written, for the header read-out. */
|
||||||
const progress = computed(() => {
|
const progress = computed(() => {
|
||||||
if (!paperDoc.value) return { written: 0, total: 0, unmatched: 0 }
|
if (!paperDoc.value) return { written: 0, total: 0, unmatched: 0 }
|
||||||
@@ -268,33 +315,69 @@ onMounted(load)
|
|||||||
:key="paragraph.paper_template_filed_sort"
|
:key="paragraph.paper_template_filed_sort"
|
||||||
:paragraph="paragraph"
|
:paragraph="paragraph"
|
||||||
:citation-index="citationIndex"
|
:citation-index="citationIndex"
|
||||||
|
:reference-text="referenceText"
|
||||||
@edit="openParagraph"
|
@edit="openParagraph"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-card v-if="paperDoc?.citations.length" shadow="never">
|
<el-card v-if="paperDoc?.references.length" shadow="never">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="paper-head">
|
<div class="paper-head">
|
||||||
<span class="paper-title">参考文献引用</span>
|
<span class="paper-title">参考文献</span>
|
||||||
<span class="paper-hint">按正文出现顺序编号,正文中的上标与这里的序号一一对应</span>
|
<span class="paper-hint">
|
||||||
|
按正文首次出现顺序编号,同一篇文献在多处引用共用同一个序号;条目按 {{ styleLabel }} 排版
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<ol class="references">
|
<ol class="references">
|
||||||
<li v-for="citation in paperDoc.citations" :key="citation.id" class="reference">
|
<li v-for="entry in paperDoc.references" :key="entry.index" class="reference">
|
||||||
<span class="reference-index">[{{ citation.index }}]</span>
|
<span class="reference-index">[{{ entry.index }}]</span>
|
||||||
<div class="reference-body">
|
<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">
|
<div class="reference-meta">
|
||||||
<el-tag v-if="citation.reference_id" size="small" effect="plain">
|
<el-tag
|
||||||
引用 #{{ citation.reference_id }}
|
v-if="entry.missing.length"
|
||||||
|
type="warning"
|
||||||
|
size="small"
|
||||||
|
effect="plain"
|
||||||
|
>
|
||||||
|
缺 {{ entry.missing.join('、') }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
<el-tag v-else size="small" type="warning" effect="plain">未关联引用 id</el-tag>
|
<el-tag v-if="!entry.reference_id" type="warning" size="small" effect="plain">
|
||||||
<el-button link type="primary" @click="scrollToParagraph(citation.paper_template_filed_sort)">
|
未关联文献
|
||||||
{{ citation.paragraph_name ?? PARAGRAPH_UNSET_LABEL }}
|
</el-tag>
|
||||||
<el-icon><Right /></el-icon>
|
<span class="reference-places">
|
||||||
</el-button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -446,19 +529,56 @@ onMounted(load)
|
|||||||
|
|
||||||
.reference-body {
|
.reference-body {
|
||||||
min-width: 0;
|
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;
|
font-size: 13px;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
color: var(--el-text-color-regular);
|
color: var(--el-text-color-regular);
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reference-text--unlinked {
|
||||||
|
color: var(--el-color-warning);
|
||||||
|
}
|
||||||
|
|
||||||
.reference-meta {
|
.reference-meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
margin-top: 4px;
|
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>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user