首页书脊添加来源

This commit is contained in:
2026-10-26 19:24:28 +08:00
parent 7d87511790
commit 6998d6c805
7 changed files with 133 additions and 30 deletions
@@ -66,7 +66,8 @@ public class VersionResource implements Serializable {
@Schema(description = "所属任务年份(必备)") @Schema(description = "所属任务年份(必备)")
private String taskYear; private String taskYear;
@Schema(description = "来源馆(必备)") @TableField("source_library")
@Schema(description = "来源馆(必备),对应 version_resource.source_library")
private String sourceLibrary; private String sourceLibrary;
@Schema(description = "来源馆地址(必备,IP:端口或域名)") @Schema(description = "来源馆地址(必备,IP:端口或域名)")
@@ -44,6 +44,9 @@ public class SpecialRecommendVO implements Serializable {
@Schema(description = "下载/电子版地址(special_resource.ebook_url,version_resource 场景取全文地址)") @Schema(description = "下载/电子版地址(special_resource.ebook_url,version_resource 场景取全文地址)")
private String ebookUrl; private String ebookUrl;
@Schema(description = "来源馆(version_resource.source_library)")
private String sourceLibrary;
@Schema(description = "数据来源:VERSION=version_resource特藏标记 / MANUAL=special_resource手工维护") @Schema(description = "数据来源:VERSION=version_resource特藏标记 / MANUAL=special_resource手工维护")
private String source; private String source;
} }
@@ -40,6 +40,10 @@ public class SpecialResource implements Serializable {
@Schema(description = "电子版下载地址") @Schema(description = "电子版下载地址")
private String ebookUrl; private String ebookUrl;
@TableField("source_library")
@Schema(description = "来源馆,对应 special_resource.source_library")
private String sourceLibrary;
@Schema(description = "排序号") @Schema(description = "排序号")
private Integer sortNo; private Integer sortNo;
@@ -129,6 +129,7 @@ public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, Speci
vo.setNote(r.getNote()); vo.setNote(r.getNote());
vo.setAuthor(r.getAuthor()); vo.setAuthor(r.getAuthor());
vo.setPublishYear(r.getPublishYear()); vo.setPublishYear(r.getPublishYear());
vo.setSourceLibrary(r.getSourceLibrary());
vo.setFulltextUrl(r.getFulltextUrl()); vo.setFulltextUrl(r.getFulltextUrl());
// version_resource 无封面与电子版字段,下载地址用全文地址兜底 // version_resource 无封面与电子版字段,下载地址用全文地址兜底
vo.setEbookUrl(r.getFulltextUrl()); vo.setEbookUrl(r.getFulltextUrl());
@@ -143,6 +144,7 @@ public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, Speci
vo.setNote(s.getSummary()); vo.setNote(s.getSummary());
vo.setCoverUrl(s.getCoverUrl()); vo.setCoverUrl(s.getCoverUrl());
vo.setEbookUrl(s.getEbookUrl()); vo.setEbookUrl(s.getEbookUrl());
vo.setSourceLibrary(s.getSourceLibrary());
vo.setSource("MANUAL"); vo.setSource("MANUAL");
return vo; return vo;
} }
@@ -0,0 +1,4 @@
-- 特藏推荐表补来源馆,首页书脊下侧展示该字段。
ALTER TABLE special_resource ADD COLUMN IF NOT EXISTS source_library VARCHAR(256);
COMMENT ON COLUMN special_resource.source_library IS '来源馆';
+4
View File
@@ -18,6 +18,8 @@ export interface SpecialRecommendItem {
summary?: string summary?: string
author?: string author?: string
publishYear?: string publishYear?: string
/** 来源馆(version_resource.source_library) */
sourceLibrary?: string
/** 封面图片(special_resource.cover_url) */ /** 封面图片(special_resource.cover_url) */
coverUrl?: string coverUrl?: string
/** 全文地址(version_resource.fulltext_url) */ /** 全文地址(version_resource.fulltext_url) */
@@ -50,6 +52,8 @@ export interface SpecialResource {
category?: string category?: string
coverUrl?: string coverUrl?: string
ebookUrl?: string ebookUrl?: string
/** 来源馆(special_resource.source_library) */
sourceLibrary?: string
sortNo?: number sortNo?: number
status?: number status?: number
} }
+114 -29
View File
@@ -61,6 +61,10 @@ function titleOf(it: SpecialRecommendItem) {
return it.title || it.name || '' return it.title || it.name || ''
} }
function sourceOf(it: SpecialRecommendItem) {
return (it.sourceLibrary || '').trim()
}
/* 拉取特藏列表,为每本书随机分配姿态与呼吸延迟,使节奏互不同步 */ /* 拉取特藏列表,为每本书随机分配姿态与呼吸延迟,使节奏互不同步 */
async function fetchSpecials() { async function fetchSpecials() {
try { try {
@@ -81,13 +85,16 @@ function openSpecial(it: SpecialRecommendItem) {
router.push({ path: '/special', query: { id: String(it.id ?? '') } }) router.push({ path: '/special', query: { id: String(it.id ?? '') } })
} }
const hoverIndex = ref(-1) const hoverKey = ref('')
const shelfPaused = ref(false)
/* X 轴推挤:悬停某本书时,左侧书本左推、右侧书本右推 */ /* X 轴推挤:悬停某本书时,同一排左侧书本左推、右侧书本右推 */
function wrapperStyle(i: number) { function wrapperStyle(copy: number, i: number) {
if (hoverIndex.value < 0) return {} const prefix = `${copy}-`
if (i < hoverIndex.value) return { transform: 'translateX(-40px)' } if (!hoverKey.value.startsWith(prefix)) return {}
if (i > hoverIndex.value) return { transform: 'translateX(40px)' } const hi = Number(hoverKey.value.slice(prefix.length))
if (i < hi) return { transform: 'translateX(-40px)' }
if (i > hi) return { transform: 'translateX(40px)' }
return { transform: 'translateX(0px)' } return { transform: 'translateX(0px)' }
} }
@@ -213,15 +220,27 @@ onBeforeUnmount(pause)
</section> </section>
</div> </div>
<!-- 特藏书架:一本书 = 一条特藏,点击查看特藏详情 --> <!-- 特藏书架:横向循环滚动,悬停暂停,点击进入特藏详情 -->
<div v-if="specials.length" class="shelf"> <div
v-if="specials.length"
class="shelf"
@mouseenter="shelfPaused = true"
@mouseleave="shelfPaused = false; hoverKey = ''"
>
<div class="shelf-track" :class="{ paused: shelfPaused }">
<div
v-for="copy in 2"
:key="copy"
class="shelf-group"
:aria-hidden="copy === 2 ? 'true' : undefined"
>
<div <div
v-for="(e, i) in specials" v-for="(e, i) in specials"
:key="e.id ?? i" :key="`${copy}-${e.id ?? i}`"
class="book-wrapper" class="book-wrapper"
:style="[wrapperStyle(i), { '--delay': bookMeta[i]?.delay || '0s' }]" :style="[wrapperStyle(copy, i), { '--delay': bookMeta[i]?.delay || '0s' }]"
@mouseenter="hoverIndex = i" @mouseenter="hoverKey = `${copy}-${i}`"
@mouseleave="hoverIndex = -1" @mouseleave="hoverKey = ''"
@click="openSpecial(e)" @click="openSpecial(e)"
> >
<!-- 中层:随机倾斜 + 呼吸悬浮 --> <!-- 中层:随机倾斜 + 呼吸悬浮 -->
@@ -234,13 +253,22 @@ onBeforeUnmount(pause)
}" }"
> >
<!-- 内层:书本本体,悬停时飞出转正 --> <!-- 内层:书本本体,悬停时飞出转正 -->
<div class="book" :style="{ backgroundColor: bookMeta[i]?.color || '#2c4d40' }"> <div
<span class="book-title">{{ titleOf(e) }}</span> class="book"
:class="{ 'has-source': sourceOf(e) }"
:style="{ backgroundColor: bookMeta[i]?.color || '#2c4d40' }"
>
<div class="book-copy">
<span class="book-title">{{ titleOf(e) }}</span>
<span v-if="sourceOf(e)" class="book-source" :title="sourceOf(e)">{{ sourceOf(e) }}</span>
</div>
</div> </div>
</div> </div>
<!-- 底层:与呼吸同步的投影 --> <!-- 底层:与呼吸同步的投影 -->
<div class="book-shadow" /> <div class="book-shadow" />
</div> </div>
</div>
</div>
</div> </div>
<p v-else class="shelf-empty">暂无特藏推荐,可在资源管理中将版本资源标记为特藏</p> <p v-else class="shelf-empty">暂无特藏推荐,可在资源管理中将版本资源标记为特藏</p>
</div> </div>
@@ -513,17 +541,40 @@ onBeforeUnmount(pause)
color: rgba(255, 255, 255, 0.45); color: rgba(255, 255, 255, 0.45);
} }
/* ---------- 快捷入口:3D 悬浮书架 ---------- */ /* ---------- 快捷入口:3D 悬浮书架,横向循环滚动 ---------- */
.shelf { .shelf {
margin-top: 30px;
overflow: hidden;
mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.shelf-track {
display: flex;
width: max-content;
animation: shelfMarquee 36s linear infinite;
&.paused {
animation-play-state: paused;
}
}
.shelf-group {
display: flex; display: flex;
justify-content: center;
align-items: flex-end; align-items: flex-end;
gap: 18px; gap: 18px;
margin-top: 30px; padding: 36px 9px 0;
padding: 30px 16px 0;
perspective: 1200px; perspective: 1200px;
} }
@keyframes shelfMarquee {
from {
transform: translateX(0);
}
to {
transform: translateX(-50%);
}
}
/* 外层:仅负责悬停时的 X 轴推挤位移 */ /* 外层:仅负责悬停时的 X 轴推挤位移 */
.book-wrapper { .book-wrapper {
flex: none; flex: none;
@@ -594,22 +645,30 @@ onBeforeUnmount(pause)
box-shadow: 0 34px 64px rgba(0, 0, 0, 0.6); box-shadow: 0 34px 64px rgba(0, 0, 0, 0.6);
} }
/* 竖排烫金书名(楷体 + 锐利金属倒角),过长自动截断 */ /* 书脊文字:书名竖排在上,来源在书名下侧横向居中 */
.book-title { .book-copy {
position: absolute; position: absolute;
inset: 0; inset: 10px 4px;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 6px;
min-height: 0;
}
.book-title {
flex: 0 1 auto;
max-height: 100%;
min-height: 0;
overflow: hidden;
/* vertical-lr:每列自上而下,多列时从左往右排(rl 会把开头那列放到最右,看着像反了) */ /* vertical-lr:每列自上而下,多列时从左往右排(rl 会把开头那列放到最右,看着像反了) */
writing-mode: vertical-lr; writing-mode: vertical-lr;
font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif; font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif;
font-size: 15px; font-size: 15px;
line-height: 1.15;
letter-spacing: 5px; letter-spacing: 5px;
color: var(--brand-gold); color: var(--brand-gold);
overflow: hidden;
text-overflow: ellipsis;
padding: 10px 0;
text-shadow: text-shadow:
-0.5px -0.5px 0px rgba(255, 255, 255, 0.8), -0.5px -0.5px 0px rgba(255, 255, 255, 0.8),
1px 1px 0px #704e10, 1px 1px 0px #704e10,
@@ -617,6 +676,28 @@ onBeforeUnmount(pause)
2px 2px 3px rgba(0, 0, 0, 0.9); 2px 2px 3px rgba(0, 0, 0, 0.9);
} }
.has-source .book-title {
max-height: 62%;
}
.book-source {
flex: 0 0 auto;
width: 100%;
writing-mode: horizontal-tb;
text-align: center;
font-size: 10px;
line-height: 1.25;
letter-spacing: 0;
color: rgba(255, 248, 220, 0.9);
border-top: 1px solid rgba(232, 201, 122, 0.55);
padding-top: 4px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
}
.shelf-empty { .shelf-empty {
margin: 30px 0 0; margin: 30px 0 0;
text-align: center; text-align: center;
@@ -743,6 +824,7 @@ onBeforeUnmount(pause)
/* ---------- 响应式 ---------- */ /* ---------- 响应式 ---------- */
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.shelf-track,
.book-inner, .book-inner,
.book-shadow::before, .book-shadow::before,
.hero-text h1, .hero-text h1,
@@ -754,9 +836,8 @@ onBeforeUnmount(pause)
} }
@media (max-width: 1080px) { @media (max-width: 1080px) {
.shelf { .shelf-track {
flex-wrap: wrap; animation-duration: 28s;
row-gap: 22px;
} }
} }
@@ -774,7 +855,7 @@ onBeforeUnmount(pause)
display: none; display: none;
} }
.shelf { .shelf-group {
gap: 12px; gap: 12px;
} }
@@ -788,7 +869,11 @@ onBeforeUnmount(pause)
.book-title { .book-title {
font-size: 13px; font-size: 13px;
letter-spacing: 5px; letter-spacing: 3px;
}
.book-source {
font-size: 9px;
} }
} }
</style> </style>