From 872ad8cf3b63a5bfa224b7f742ef067e820df2ba Mon Sep 17 00:00:00 2001
From: govin
Date: Tue, 22 Sep 2026 17:55:20 +0800
Subject: [PATCH] frontend: add the reference library, its tags, and a way in
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
参考文献 now sits in the header to the right of 论文 and 模板 — the library is
drawn *from* rather than worked in, so it is a button one step away. Its
own second-level menu marks out 文献列表 / 新增文献 / 标签管理 and then lists
the tags themselves, read from their store, so a label can be picked
straight from the rail.
A tag in the rail links to `/references?tag=`, which makes the query
parameter part of the view rather than hidden filter state: the table's own
selector writes the same parameter, so the two cannot disagree and a
filtered view is a link someone can be sent.
The form keeps the order the feature intends — a tag is created before it
is applied, so no stored reference can point at a label that is not there —
and the citation count in a row opens the answer it exists to give (which
paper, which paragraph, which quoted passage).
Tag colours are painted from the row rather than a class map: the palette
is the writer's, and the chip has to be that hue in the table, in the rail
and in the picker.
---
frontend/src/App.vue | 21 +-
frontend/src/api/referenceTags.ts | 129 +++
frontend/src/api/references.ts | 301 ++++++
frontend/src/components/SectionAside.vue | 187 +++-
.../references/ReferenceCitationsDialog.vue | 128 +++
.../references/ReferenceFormDialog.vue | 875 ++++++++++++++++++
.../src/components/references/TagChip.vue | 59 ++
.../components/references/TagFormDialog.vue | 200 ++++
frontend/src/router/index.ts | 20 +-
frontend/src/stores/referenceTags.ts | 73 ++
.../views/references/ReferenceListView.vue | 568 ++++++++++++
.../src/views/references/TagManageView.vue | 303 ++++++
12 files changed, 2837 insertions(+), 27 deletions(-)
create mode 100644 frontend/src/api/referenceTags.ts
create mode 100644 frontend/src/api/references.ts
create mode 100644 frontend/src/components/references/ReferenceCitationsDialog.vue
create mode 100644 frontend/src/components/references/ReferenceFormDialog.vue
create mode 100644 frontend/src/components/references/TagChip.vue
create mode 100644 frontend/src/components/references/TagFormDialog.vue
create mode 100644 frontend/src/stores/referenceTags.ts
create mode 100644 frontend/src/views/references/ReferenceListView.vue
create mode 100644 frontend/src/views/references/TagManageView.vue
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 7926a77..66bdfab 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -2,10 +2,10 @@
/**
* Application shell.
*
- * Three bands, in this order: a header holding the mark, the two top-level
- * sections, and the mark again at the far right; then the row below it, which
- * is the second-level menu on the left followed by the content area. The menu
- * is present only on routes that declare a `section` in their meta.
+ * Three bands, in this order: a header holding the mark, the top-level sections,
+ * and the mark again at the far right; then the row below it, which is the
+ * second-level menu on the left followed by the content area. The menu is
+ * present only on routes that declare a `section` in their meta.
*/
import { computed } from 'vue'
import { RouterView, RouterLink, useRoute } from 'vue-router'
@@ -18,10 +18,18 @@ import { useAppStore } from '@/stores/app'
const route = useRoute()
const appStore = useAppStore()
-/** The two top-level sections. `index` is the path `el-menu` routes to. */
+/**
+ * The top-level sections. `index` is the path `el-menu` routes to.
+ *
+ * 参考文献 sits to the right of 论文 and 模板 because it is a different kind of
+ * thing: the writing surface and the templates are worked *in*, while the
+ * library is drawn *from* — one button away rather than one more thing to
+ * choose between.
+ */
const TOP_MENU = [
{ index: '/papers', label: '论文' },
{ index: '/templates', label: '模板' },
+ { index: '/references', label: '参考文献' },
] as const
/**
@@ -29,7 +37,8 @@ const TOP_MENU = [
*
* Derived from the path rather than tracked in state, so browser back/forward
* and a pasted deep link both leave the header highlighting the right entry.
- * `/templates/list` and `/templates/fields` both resolve to `/templates`.
+ * `/templates/list` and `/templates/fields` both resolve to `/templates`, and
+ * `/references/tags` resolves to `/references`.
*/
const activeTop = computed(() => {
const match = TOP_MENU.find(
diff --git a/frontend/src/api/referenceTags.ts b/frontend/src/api/referenceTags.ts
new file mode 100644
index 0000000..c3fa08c
--- /dev/null
+++ b/frontend/src/api/referenceTags.ts
@@ -0,0 +1,129 @@
+import http from './client'
+import type { BatchDeleteResult, PageQuery, PageResult } from './types'
+
+/**
+ * Reference tags (文献标签) — the writer's own labels on the literature.
+ *
+ * A tag is *made first and applied second*: a reference is created with
+ * `tag_ids`, never with tag names, so a typo cannot invent a label. This module
+ * is the first half of that flow; `references.ts` is the second.
+ *
+ * A tag never prints in a reference list — it exists so a library of a few
+ * hundred entries can be narrowed to the handful that matter for the paragraph
+ * being written. That is why it is a separate table from the document's own
+ * 关键词, which are transcribed from the article and do print.
+ */
+
+/** A tag as the pickers and the chips need it: no counts, no timestamps. */
+export interface ReferenceTagRef {
+ id: number
+ name: string
+ /** Canonical `#RRGGBB`, normalised by the API on write. */
+ color: string
+}
+
+/** A tag as the tag table shows it. */
+export interface ReferenceTag extends ReferenceTagRef {
+ note: string | null
+ /** How many references carry this label. Computed on read. */
+ reference_count: number
+ created_at: string
+ updated_at: string
+}
+
+export interface ReferenceTagPayload {
+ name: string
+ color: string
+ note: string | null
+}
+
+export interface ReferenceTagQuery extends PageQuery {
+ page?: number
+ page_size?: number
+}
+
+/**
+ * The colours the picker offers.
+ *
+ * Chips are the only place a tag colour is ever read, and a table of labels is
+ * read at a glance — so the palette is a small set of hues that stay legible
+ * against the tag's own tinted background, plus two greys for labels that are
+ * meant to recede.
+ */
+export const TAG_COLOR_PRESETS = [
+ '#409EFF',
+ '#67C23A',
+ '#E6A23C',
+ '#F56C6C',
+ '#9B59B6',
+ '#14B8A6',
+ '#8C8C8C',
+ '#1F1F1F',
+] as const
+
+/** The label a tag with no colour of its own gets. */
+export const DEFAULT_TAG_COLOR = '#409EFF'
+
+export async function listReferenceTags(
+ query: ReferenceTagQuery = {},
+): Promise> {
+ const params: Record = {}
+ if (query.keyword) params.keyword = query.keyword
+ if (query.page) params.page = query.page
+ if (query.page_size) params.page_size = query.page_size
+
+ const { data } = await http.get>('/reference-tags', { params })
+ return data
+}
+
+/** The API caps `page_size` at 500; a picker wants every label, so it loops. */
+const TAG_PAGE_SIZE = 200
+
+/**
+ * Fetch every tag, following pagination.
+ *
+ * The reference form and the shell's rail both want the whole library: a picker
+ * that showed one page would hide the label the writer is looking for, and the
+ * rail would show a partial list that looks complete.
+ */
+export async function fetchAllReferenceTags(keyword?: string): Promise {
+ const all: ReferenceTag[] = []
+ let page = 1
+
+ for (;;) {
+ const result = await listReferenceTags({ keyword, page, page_size: TAG_PAGE_SIZE })
+ all.push(...result.items)
+ if (page >= result.pages || result.items.length === 0) {
+ return all
+ }
+ page += 1
+ }
+}
+
+export async function createReferenceTag(
+ payload: ReferenceTagPayload,
+): Promise {
+ const { data } = await http.post('/reference-tags', payload)
+ return data
+}
+
+export async function updateReferenceTag(
+ id: number,
+ payload: Partial,
+): Promise {
+ const { data } = await http.patch(`/reference-tags/${id}`, payload)
+ return data
+}
+
+export async function deleteReferenceTag(id: number): Promise {
+ await http.delete(`/reference-tags/${id}`)
+}
+
+export async function batchDeleteReferenceTags(
+ ids: number[],
+): Promise {
+ const { data } = await http.post('/reference-tags/batch-delete', {
+ ids,
+ })
+ return data
+}
diff --git a/frontend/src/api/references.ts b/frontend/src/api/references.ts
new file mode 100644
index 0000000..24635b3
--- /dev/null
+++ b/frontend/src/api/references.ts
@@ -0,0 +1,301 @@
+import http from './client'
+import type { ReferenceTagRef } from './referenceTags'
+import type { BatchDeleteResult, PageQuery, PageResult } from './types'
+
+/**
+ * The reference library (参考文献) — the literature a paper cites.
+ *
+ * One row is one document the writer has read: a journal article, a book, a
+ * patent, a standard, a dataset. It is **global**, not owned by a paper, because
+ * the same article is cited from several papers; the citation itself (which
+ * sentence quotes which passage) lives on the paper side.
+ *
+ * The fields are the intersection of the formats a Chinese journal paper has to
+ * survive — CSL JSON, GB/T 7714-2015, BibTeX/RIS — which is what the labels on
+ * the form mirror. Contributors arrive as an ordered list and replace the stored
+ * list wholesale, exactly like a template's placements.
+ */
+
+/**
+ * The document types this library holds.
+ *
+ * `marker` is the GB/T 7714 文献类型标志 a reference list prints after the
+ * title, which is why it is carried here rather than derived per view.
+ */
+export const REFERENCE_TYPE_OPTIONS = [
+ { value: 'journal-article', label: '期刊论文', marker: 'J' },
+ { value: 'book', label: '专著', marker: 'M' },
+ { value: 'book-chapter', label: '析出文献', marker: 'M' },
+ { value: 'conference-paper', label: '会议论文', marker: 'C' },
+ { value: 'thesis', label: '学位论文', marker: 'D' },
+ { value: 'patent', label: '专利', marker: 'P' },
+ { value: 'standard', label: '标准', marker: 'S' },
+ { value: 'report', label: '报告', marker: 'R' },
+ { value: 'newspaper-article', label: '报纸文章', marker: 'N' },
+ { value: 'web-page', label: '网页', marker: 'EB/OL' },
+ { value: 'dataset', label: '数据集', marker: 'DS' },
+ { value: 'software', label: '计算机程序', marker: 'CP' },
+ { value: 'preprint', label: '预印本', marker: 'EB/OL' },
+ { value: 'other', label: '其他', marker: 'Z' },
+] as const
+
+export type ReferenceType = (typeof REFERENCE_TYPE_OPTIONS)[number]['value']
+
+const TYPE_LABELS = new Map(
+ REFERENCE_TYPE_OPTIONS.map((option) => [option.value as string, option.label]),
+)
+const TYPE_MARKERS = new Map(
+ REFERENCE_TYPE_OPTIONS.map((option) => [option.value as string, option.marker]),
+)
+
+/** The Chinese name of a type token, falling back to the token itself. */
+export function referenceTypeLabel(type: string): string {
+ return TYPE_LABELS.get(type) ?? type
+}
+
+/** The GB/T 7714 marker of a type token, or `''` for one we do not know. */
+export function referenceTypeMarker(type: string): string {
+ return TYPE_MARKERS.get(type) ?? ''
+}
+
+/** 语种 — decides which of the two titles a style prints first. */
+export const REFERENCE_LANGUAGE_OPTIONS = [
+ { value: 'zh', label: '中文' },
+ { value: 'en', label: '英文' },
+ { value: 'ja', label: '日文' },
+ { value: 'other', label: '其他' },
+] as const
+
+/** 责任者角色 — what prints after a name (编 / 译 / 主编). */
+export const REFERENCE_AUTHOR_ROLE_OPTIONS = [
+ { value: 'author', label: '作者' },
+ { value: 'editor', label: '编者' },
+ { value: 'translator', label: '译者' },
+ { value: 'compiler', label: '汇编' },
+] as const
+
+/** A stored contributor of a reference. */
+export interface ReferenceAuthor {
+ id: number
+ /** Print order, ascending. */
+ sort: number
+ /** What prints: 「张三」, "John Smith", 「世界卫生组织」. */
+ name: string
+ /** Optional halves, for styles that invert or initialise a name. */
+ family_name: string | null
+ given_name: string | null
+ role: string
+}
+
+/** A contributor as the form sends it. */
+export interface ReferenceAuthorInput {
+ name: string
+ family_name: string | null
+ given_name: string | null
+ role: string
+ sort?: number | null
+}
+
+/** A reference as it appears in the library table. */
+export interface ReferenceListItem {
+ id: number
+ type: string
+ title: string
+ subtitle: string | null
+ container_title: string | null
+ /** 出版者 — the "where" for a book, a thesis or a report, which has no container. */
+ publisher: string | null
+ publication_year: number | null
+ volume: string | null
+ issue: string | null
+ pages: string | null
+ doi: string | null
+ /** The printed author line, already truncated for a row by the API. */
+ authors_line: string
+ author_count: number
+ tags: ReferenceTagRef[]
+ /** How many sentences cite it. */
+ citation_count: number
+ created_at: string
+ updated_at: string
+}
+
+/**
+ * A reference with everything the table does not need.
+ *
+ * The list row deliberately drops the abstract, the note and the contributor
+ * rows; the form needs them, so editing fetches this shape by id.
+ */
+export interface ReferenceDetail {
+ id: number
+ type: string
+ title: string
+ subtitle: string | null
+ title_translated: string | null
+ title_short: string | null
+ container_title: string | null
+ container_title_short: string | null
+ series_title: string | null
+ series_number: string | null
+ edition: string | null
+ volume: string | null
+ issue: string | null
+ pages: string | null
+ article_number: string | null
+ publisher: string | null
+ publisher_place: string | null
+ event_title: string | null
+ event_place: string | null
+ event_date: string | null
+ publication_year: number | null
+ publication_month: number | null
+ publication_day: number | null
+ accessed_date: string | null
+ doi: string | null
+ isbn: string | null
+ issn: string | null
+ url: string | null
+ patent_country: string | null
+ patent_number: string | null
+ standard_number: string | null
+ report_number: string | null
+ arxiv_id: string | null
+ abstract: string | null
+ keywords: string | null
+ note: string | null
+ citation_key: string | null
+ language: string | null
+ authors: ReferenceAuthor[]
+ tags: ReferenceTagRef[]
+ citation_count: number
+ created_at: string
+ updated_at: string
+}
+
+/** One sentence that cites a reference — the reverse lookup. */
+export interface ReferenceCitation {
+ citation_id: number
+ sentence_id: number
+ sentence_content: string
+ /** 引用内容 — the passage the sentence quotes. */
+ quote: string
+ paper_id: number
+ paper_title: string
+ paper_template_filed_sort: number
+ /** The heading the paper's template puts at that position, if any. */
+ paragraph_name: string | null
+}
+
+/** Everything a reference may carry. Only `title` is required. */
+export interface ReferencePayload {
+ type: string
+ title: string
+ subtitle: string | null
+ title_translated: string | null
+ title_short: string | null
+ container_title: string | null
+ container_title_short: string | null
+ series_title: string | null
+ series_number: string | null
+ edition: string | null
+ volume: string | null
+ issue: string | null
+ pages: string | null
+ article_number: string | null
+ publisher: string | null
+ publisher_place: string | null
+ event_title: string | null
+ event_place: string | null
+ event_date: string | null
+ publication_year: number | null
+ publication_month: number | null
+ publication_day: number | null
+ accessed_date: string | null
+ doi: string | null
+ isbn: string | null
+ issn: string | null
+ url: string | null
+ patent_country: string | null
+ patent_number: string | null
+ standard_number: string | null
+ report_number: string | null
+ arxiv_id: string | null
+ abstract: string | null
+ keywords: string | null
+ note: string | null
+ citation_key: string | null
+ language: string | null
+ authors: ReferenceAuthorInput[]
+ tag_ids: number[]
+}
+
+export interface ReferenceQuery extends PageQuery {
+ type?: string | null
+ year?: number | null
+ /** `true` only what is already cited, `false` only what is not. */
+ cited?: boolean | null
+ /** Tag ids; more than one narrows to the rows carrying all of them. */
+ tag_ids?: number[]
+}
+
+export async function listReferences(
+ query: ReferenceQuery = {},
+): Promise> {
+ // Built as a `URLSearchParams` rather than a plain object because the tag
+ // filter repeats its key: `tag=1&tag=2` means "carries both labels", while
+ // the default array serialisation would send `tag[]=1`.
+ const search = new URLSearchParams()
+ const set = (
+ key: string,
+ value: string | number | boolean | null | undefined,
+ ): void => {
+ if (value == null || value === '') return
+ search.set(key, String(value))
+ }
+
+ set('keyword', query.keyword)
+ set('type', query.type)
+ set('year', query.year)
+ set('cited', query.cited)
+ set('page', query.page)
+ set('page_size', query.page_size)
+ for (const tagId of query.tag_ids ?? []) search.append('tag', String(tagId))
+
+ const { data } = await http.get>('/references', {
+ params: search,
+ })
+ return data
+}
+
+export async function getReference(id: number): Promise {
+ const { data } = await http.get(`/references/${id}`)
+ return data
+}
+
+/** Every sentence that cites this reference, with the paper it sits in. */
+export async function listReferenceCitations(id: number): Promise {
+ const { data } = await http.get(`/references/${id}/citations`)
+ return data
+}
+
+export async function createReference(payload: ReferencePayload): Promise {
+ const { data } = await http.post('/references', payload)
+ return data
+}
+
+export async function updateReference(
+ id: number,
+ payload: Partial,
+): Promise {
+ const { data } = await http.patch(`/references/${id}`, payload)
+ return data
+}
+
+export async function deleteReference(id: number): Promise {
+ await http.delete(`/references/${id}`)
+}
+
+export async function batchDeleteReferences(ids: number[]): Promise {
+ const { data } = await http.post('/references/batch-delete', { ids })
+ return data
+}
diff --git a/frontend/src/components/SectionAside.vue b/frontend/src/components/SectionAside.vue
index 7e93ee2..1b6c58d 100644
--- a/frontend/src/components/SectionAside.vue
+++ b/frontend/src/components/SectionAside.vue
@@ -4,22 +4,36 @@
*
* It is driven by `route.meta.section`, so the menu a URL belongs to is a
* property of the route table rather than of component state — deep linking to
- * `/templates/fields` or `/papers/12` shows the right menu on first paint, and
- * the aside disappears on routes that declare no section (the welcome page).
+ * `/templates/fields`, `/papers/12` or `/references?tag=3` shows the right menu
+ * on first paint, and the aside disappears on routes that declare no section
+ * (the welcome page).
*
- * The 论文 menu is the exception to the static list: it carries the papers
- * themselves, so it is read from the store rather than written here. Every page
- * that creates, renames or deletes a paper reloads that store, which is what
- * keeps the menu and the table showing the same thing.
+ * Two menus are exceptions to the static list, and both carry real data rather
+ * than links: 论文 lists the papers themselves, and 参考文献 lists the tags, so
+ * either can be opened straight from the rail. Each is read from its store, and
+ * every page that changes one reloads that store, which is what keeps the rail
+ * and the table showing the same thing.
*/
import { computed, onMounted, ref, watch, type Component } from 'vue'
import { useRoute } from 'vue-router'
-import { Document, Expand, Files, Fold, Plus, Search, Setting } from '@element-plus/icons-vue'
+import {
+ Collection,
+ Document,
+ Expand,
+ Files,
+ Fold,
+ Plus,
+ PriceTag,
+ Search,
+ Setting,
+} from '@element-plus/icons-vue'
import type { PaperListItem } from '@/api/papers'
+import type { ReferenceTag } from '@/api/referenceTags'
import { ASIDE_INSET, asideWidth } from '@/layout'
import { useAppStore } from '@/stores/app'
import { usePapersStore } from '@/stores/papers'
+import { useReferenceTagsStore } from '@/stores/referenceTags'
interface AsideItem {
index: string
@@ -38,6 +52,7 @@ const props = defineProps<{ section: string }>()
const route = useRoute()
const appStore = useAppStore()
const papersStore = usePapersStore()
+const tagsStore = useReferenceTagsStore()
const MENUS: Record = {
papers: {
@@ -56,6 +71,17 @@ const MENUS: Record = {
{ index: '/templates/fields', label: '字段管理', icon: Setting },
],
},
+ // 标签管理 is listed as a page of this section rather than as a fourth
+ // top-level entry: a tag exists to file the literature, so it is managed next
+ // to it.
+ references: {
+ title: '参考文献',
+ items: [
+ { index: '/references', label: '文献列表', icon: Collection },
+ { index: '/references?new=1', label: '新增文献', icon: Plus },
+ { index: '/references/tags', label: '标签管理', icon: PriceTag },
+ ],
+ },
}
const menu = computed(() => MENUS[props.section] ?? null)
@@ -68,13 +94,18 @@ const inset = ASIDE_INSET
/** Filter for the paper list: a rail this narrow cannot show every paper. */
const paperFilter = ref('')
+/** The same problem for the tag list, which grows with the library. */
+const tagFilter = ref('')
+
const papers = computed(() => papersStore.items)
+const tags = computed(() => tagsStore.items)
/**
- * The filter appears only once the list is long enough to need it. Below that
- * it would occupy a menu item's worth of height to hide nothing.
+ * A filter appears only once the list is long enough to need it. Below that it
+ * would occupy a menu item's worth of height to hide nothing.
*/
const filterable = computed(() => papers.value.length > 6)
+const tagsFilterable = computed(() => tags.value.length > 6)
const filteredPapers = computed(() => {
const keyword = paperFilter.value.trim().toLowerCase()
@@ -82,19 +113,41 @@ const filteredPapers = computed(() => {
return papers.value.filter((paper) => paper.title.toLowerCase().includes(keyword))
})
-/** The active entry: either a static one or the paper currently open. */
-const activeIndex = computed(() =>
- route.path === '/papers' && route.query.new ? '/papers?new=1' : route.path,
-)
+const filteredTags = computed(() => {
+ const keyword = tagFilter.value.trim().toLowerCase()
+ if (!keyword) return tags.value
+ return tags.value.filter((tag) => tag.name.toLowerCase().includes(keyword))
+})
-/** Load the menu's list the first time the 论文 section is opened. */
-function ensurePapers(): void {
- if (props.section !== 'papers') return
- if (!papersStore.loaded && !papersStore.loading) void papersStore.reload()
+/**
+ * The active entry.
+ *
+ * The two list menus are entered through a query parameter that *is* the view —
+ * 新建论文 opens the create dialog, a tag narrows the library — so the highlight
+ * has to follow the parameter rather than the path alone.
+ */
+const activeIndex = computed(() => {
+ if (props.section === 'papers' && route.path === '/papers' && route.query.new) {
+ return '/papers?new=1'
+ }
+ if (props.section === 'references' && route.path === '/references' && route.query.tag) {
+ return `/references?tag=${route.query.tag}`
+ }
+ return route.path
+})
+
+/** Load the menu's list the first time its section is opened. */
+function ensureLists(): void {
+ if (props.section === 'papers' && !papersStore.loaded && !papersStore.loading) {
+ void papersStore.reload()
+ }
+ if (props.section === 'references') {
+ void tagsStore.ensureLoaded()
+ }
}
-watch(() => props.section, ensurePapers)
-onMounted(ensurePapers)
+watch(() => props.section, ensureLists)
+onMounted(ensureLists)
@@ -184,6 +237,60 @@ onMounted(ensurePapers)
没有匹配的论文。
+
+
+
+
+
+
+
+
+
+
+ 还没有标签。先在「标签管理」里建几个,用来给文献归档。
+
+
+ 没有匹配的标签。
+
+
@@ -249,6 +356,12 @@ onMounted(ensurePapers)
border-top: 1px solid var(--el-border-color-lighter);
}
+.aside-menu--tags {
+ margin-top: 4px;
+ padding-top: 4px;
+ border-top: 1px solid var(--el-border-color-lighter);
+}
+
/* A collapsed el-menu keeps a fixed 64px width that no longer matches the
56px rail, so the items would sit off-centre. */
.aside-menu.el-menu--collapse {
@@ -302,6 +415,42 @@ onMounted(ensurePapers)
overflow: hidden;
}
+/* A tag in the rail: its colour, its name, and how much carries it — the count
+ is what tells the writer whether a label is worth keeping. */
+.aside-tag {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+
+.aside-tag-dot {
+ flex: 0 0 auto;
+ width: 8px;
+ height: 8px;
+ border-radius: 2px;
+}
+
+.aside-tag-name {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.aside-tag-count {
+ margin-left: auto;
+ padding-left: 6px;
+ font-size: 12px;
+ color: var(--el-text-color-placeholder);
+ font-variant-numeric: tabular-nums;
+}
+
+.aside-menu--tags :deep(.el-menu-item > span) {
+ min-width: 0;
+ overflow: hidden;
+}
+
.aside-empty {
margin: 8px 12px;
font-size: 12px;
diff --git a/frontend/src/components/references/ReferenceCitationsDialog.vue b/frontend/src/components/references/ReferenceCitationsDialog.vue
new file mode 100644
index 0000000..d5a086d
--- /dev/null
+++ b/frontend/src/components/references/ReferenceCitationsDialog.vue
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+ {{ row.paper_title }}
+
+
+
+
+
+ {{ paragraphName(row) }}
+
+
+
+
+ {{ row.sentence_content || '(空行,只挂引用)' }}
+
+
+
+
+
+ {{ row.quote }}
+
+
+
+
+
+
+
+
+
+ 关闭
+
+
+
+
+
diff --git a/frontend/src/components/references/ReferenceFormDialog.vue b/frontend/src/components/references/ReferenceFormDialog.vue
new file mode 100644
index 0000000..dc81662
--- /dev/null
+++ b/frontend/src/components/references/ReferenceFormDialog.vue
@@ -0,0 +1,875 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ typeHint }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ tag.name }}
+ {{ tag.note }}
+
+
+
+
+ 标签是给自己归档用的,不会出现在参考文献表里;输入库里没有的名称会在保存时自动建好。
+ 也可以先去
+ 标签管理
+ 里整理。
+
+
+
+
+
+
+
+ 按引用时打印的顺序排列;姓名是必填的,姓 / 名供需要缩写或倒装的格式使用。
+
+ 添加责任者
+
+
+
+ 还没有责任者。机构作者(如 世界卫生组织)直接填姓名即可。
+
+
+
+
{{ index + 1 }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 年月日各自独立,知道多少填多少:书通常只有年份,报纸文章有日期,专利填公告日期。
+
+
+ 会议(会议论文填这里)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DOI 会按规范存成不带 https://doi.org/ 前缀的形式,粘贴时带前缀也没关系。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+ {{ reference ? '保存修改' : '加入文献库' }}
+
+
+
+
+
+
diff --git a/frontend/src/components/references/TagChip.vue b/frontend/src/components/references/TagChip.vue
new file mode 100644
index 0000000..4828a2c
--- /dev/null
+++ b/frontend/src/components/references/TagChip.vue
@@ -0,0 +1,59 @@
+
+
+
+
+
+ {{ name }}{{ count }}
+
+
+
+
diff --git a/frontend/src/components/references/TagFormDialog.vue b/frontend/src/components/references/TagFormDialog.vue
new file mode 100644
index 0000000..3259069
--- /dev/null
+++ b/frontend/src/components/references/TagFormDialog.vue
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ form.name || '(未命名标签)' }}
+
+ 文献表里就长这样
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 4ae52fa..9fe2c0c 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -3,9 +3,9 @@ import { createRouter, createWebHistory } from 'vue-router'
/**
* Route table.
*
- * `meta.section` groups a route under one of the two top-level entries in the
+ * `meta.section` groups a route under one of the top-level entries in the
* header. The shell reads it to decide whether — and which — second-level menu
- * to render on the right, so a new page only has to declare where it belongs.
+ * to render on the left, so a new page only has to declare where it belongs.
*/
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -48,6 +48,22 @@ const router = createRouter({
component: () => import('@/views/templates/FieldManageView.vue'),
meta: { title: '字段管理', section: 'templates' },
},
+ {
+ // The reference library, reached from the header button to the right of
+ // 论文 and 模板. `?tag=` is a supported state of this page rather than
+ // a separate route: the rail lists the labels and links straight to the
+ // filtered library, and the table's own filter writes the same parameter.
+ path: '/references',
+ name: 'references',
+ component: () => import('@/views/references/ReferenceListView.vue'),
+ meta: { title: '参考文献', section: 'references' },
+ },
+ {
+ path: '/references/tags',
+ name: 'reference-tags',
+ component: () => import('@/views/references/TagManageView.vue'),
+ meta: { title: '标签管理', section: 'references' },
+ },
{
path: '/:pathMatch(.*)*',
name: 'not-found',
diff --git a/frontend/src/stores/referenceTags.ts b/frontend/src/stores/referenceTags.ts
new file mode 100644
index 0000000..38df05e
--- /dev/null
+++ b/frontend/src/stores/referenceTags.ts
@@ -0,0 +1,73 @@
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+
+import { errorMessage } from '@/api/client'
+import { fetchAllReferenceTags, type ReferenceTag } from '@/api/referenceTags'
+
+/**
+ * The tag library, shared by the second-level menu and the pages that change it.
+ *
+ * Same arrangement as the paper list and for the same reason: the rail in the
+ * application shell shows the labels and the reference pages apply them, so
+ * neither owns the list. A page that creates, renames or deletes a tag calls
+ * `reload()` and the rail follows, without the two knowing about each other.
+ *
+ * The reference form reads it too, because a picker wants every label at once —
+ * the API pages the list, this holds the whole of it.
+ *
+ * Deliberately *not* persisted: it is server data, and a stale copy restored
+ * from localStorage would offer labels that no longer exist.
+ */
+export const useReferenceTagsStore = defineStore('referenceTags', () => {
+ const items = ref([])
+ const loading = ref(false)
+ /** Whether a load has ever finished, so an empty list can be told from unloaded. */
+ const loaded = ref(false)
+ const error = ref(null)
+
+ /** Reload the whole library. Concurrent callers share one request. */
+ let inFlight: Promise | null = null
+
+ async function reload(): Promise {
+ if (inFlight) return inFlight
+
+ loading.value = true
+ inFlight = (async () => {
+ try {
+ items.value = await fetchAllReferenceTags()
+ error.value = null
+ loaded.value = true
+ } catch (cause) {
+ error.value = errorMessage(cause)
+ } finally {
+ loading.value = false
+ inFlight = null
+ }
+ })()
+ return inFlight
+ }
+
+ /** Load the library once, unless it is already loaded or loading. */
+ async function ensureLoaded(): Promise {
+ if (loaded.value || loading.value) return
+ await reload()
+ }
+
+ /** The tag with this id, or `undefined` — for painting a chip from an id. */
+ function byId(id: number): ReferenceTag | undefined {
+ return items.value.find((tag) => tag.id === id)
+ }
+
+ /** The tag with this exact name, or `undefined` — used when applying labels. */
+ function byName(name: string): ReferenceTag | undefined {
+ return items.value.find((tag) => tag.name === name)
+ }
+
+ function reset(): void {
+ items.value = []
+ loaded.value = false
+ error.value = null
+ }
+
+ return { items, loading, loaded, error, reload, ensureLoaded, byId, byName, reset }
+})
diff --git a/frontend/src/views/references/ReferenceListView.vue b/frontend/src/views/references/ReferenceListView.vue
new file mode 100644
index 0000000..cae9642
--- /dev/null
+++ b/frontend/src/views/references/ReferenceListView.vue
@@ -0,0 +1,568 @@
+
+
+
+
+
+
+
+
+
+
+
+ (selection = value)"
+ >
+
+
+
+
+
+ {{ row.title }}
+
+ {{ row.subtitle }}
+
+
+
+
+
+ {{ typeLabel(row) }}
+
+
+
+
+
+ {{ row.authors_line }}
+ —
+
+
+
+
+
+ {{ sourceLine(row) }}
+ —
+
+
+
+
+
+ {{ row.publication_year }}
+ —
+
+
+
+
+
+
+
+
+ +{{ row.tags.length - 3 }}
+
+
+ —
+
+
+
+
+
+
+ {{ row.citation_count }} 处
+
+ —
+
+
+
+
+ {{ formatDateTime(row.updated_at) }}
+
+
+
+
+ 编辑
+
+ 引用
+
+ 删除
+
+
+
+
+
+ 新增文献
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/references/TagManageView.vue b/frontend/src/views/references/TagManageView.vue
new file mode 100644
index 0000000..aa896a3
--- /dev/null
+++ b/frontend/src/views/references/TagManageView.vue
@@ -0,0 +1,303 @@
+
+
+
+
+
+
+
+
+
+
+
+ (selection = value)"
+ >
+
+
+
+
+
+
+
+
+
+
+ {{ row.note }}
+ —
+
+
+
+
+
+
+ {{ row.reference_count }} 篇
+
+ 未使用
+
+
+
+
+ {{ formatDateTime(row.updated_at) }}
+
+
+
+
+ 编辑
+ 删除
+
+
+
+
+
+ 新建标签
+
+
+
+
+
+
+
+
+
+
+
+