首页书脊添加来源
This commit is contained in:
@@ -18,6 +18,8 @@ export interface SpecialRecommendItem {
|
||||
summary?: string
|
||||
author?: string
|
||||
publishYear?: string
|
||||
/** 来源馆(version_resource.source_library) */
|
||||
sourceLibrary?: string
|
||||
/** 封面图片(special_resource.cover_url) */
|
||||
coverUrl?: string
|
||||
/** 全文地址(version_resource.fulltext_url) */
|
||||
@@ -50,6 +52,8 @@ export interface SpecialResource {
|
||||
category?: string
|
||||
coverUrl?: string
|
||||
ebookUrl?: string
|
||||
/** 来源馆(special_resource.source_library) */
|
||||
sourceLibrary?: string
|
||||
sortNo?: number
|
||||
status?: number
|
||||
}
|
||||
|
||||
@@ -61,6 +61,10 @@ function titleOf(it: SpecialRecommendItem) {
|
||||
return it.title || it.name || ''
|
||||
}
|
||||
|
||||
function sourceOf(it: SpecialRecommendItem) {
|
||||
return (it.sourceLibrary || '').trim()
|
||||
}
|
||||
|
||||
/* 拉取特藏列表,为每本书随机分配姿态与呼吸延迟,使节奏互不同步 */
|
||||
async function fetchSpecials() {
|
||||
try {
|
||||
@@ -81,13 +85,16 @@ function openSpecial(it: SpecialRecommendItem) {
|
||||
router.push({ path: '/special', query: { id: String(it.id ?? '') } })
|
||||
}
|
||||
|
||||
const hoverIndex = ref(-1)
|
||||
const hoverKey = ref('')
|
||||
const shelfPaused = ref(false)
|
||||
|
||||
/* X 轴推挤:悬停某本书时,左侧书本左推、右侧书本右推 */
|
||||
function wrapperStyle(i: number) {
|
||||
if (hoverIndex.value < 0) return {}
|
||||
if (i < hoverIndex.value) return { transform: 'translateX(-40px)' }
|
||||
if (i > hoverIndex.value) return { transform: 'translateX(40px)' }
|
||||
/* X 轴推挤:悬停某本书时,同一排左侧书本左推、右侧书本右推 */
|
||||
function wrapperStyle(copy: number, i: number) {
|
||||
const prefix = `${copy}-`
|
||||
if (!hoverKey.value.startsWith(prefix)) return {}
|
||||
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)' }
|
||||
}
|
||||
|
||||
@@ -213,15 +220,27 @@ onBeforeUnmount(pause)
|
||||
</section>
|
||||
</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
|
||||
v-for="(e, i) in specials"
|
||||
:key="e.id ?? i"
|
||||
:key="`${copy}-${e.id ?? i}`"
|
||||
class="book-wrapper"
|
||||
:style="[wrapperStyle(i), { '--delay': bookMeta[i]?.delay || '0s' }]"
|
||||
@mouseenter="hoverIndex = i"
|
||||
@mouseleave="hoverIndex = -1"
|
||||
:style="[wrapperStyle(copy, i), { '--delay': bookMeta[i]?.delay || '0s' }]"
|
||||
@mouseenter="hoverKey = `${copy}-${i}`"
|
||||
@mouseleave="hoverKey = ''"
|
||||
@click="openSpecial(e)"
|
||||
>
|
||||
<!-- 中层:随机倾斜 + 呼吸悬浮 -->
|
||||
@@ -234,13 +253,22 @@ onBeforeUnmount(pause)
|
||||
}"
|
||||
>
|
||||
<!-- 内层:书本本体,悬停时飞出转正 -->
|
||||
<div class="book" :style="{ backgroundColor: bookMeta[i]?.color || '#2c4d40' }">
|
||||
<span class="book-title">{{ titleOf(e) }}</span>
|
||||
<div
|
||||
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 class="book-shadow" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="shelf-empty">暂无特藏推荐,可在资源管理中将版本资源标记为特藏</p>
|
||||
</div>
|
||||
@@ -513,17 +541,40 @@ onBeforeUnmount(pause)
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
}
|
||||
|
||||
/* ---------- 快捷入口:3D 悬浮书架 ---------- */
|
||||
/* ---------- 快捷入口:3D 悬浮书架,横向循环滚动 ---------- */
|
||||
.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;
|
||||
justify-content: center;
|
||||
align-items: flex-end;
|
||||
gap: 18px;
|
||||
margin-top: 30px;
|
||||
padding: 30px 16px 0;
|
||||
padding: 36px 9px 0;
|
||||
perspective: 1200px;
|
||||
}
|
||||
|
||||
@keyframes shelfMarquee {
|
||||
from {
|
||||
transform: translateX(0);
|
||||
}
|
||||
to {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 外层:仅负责悬停时的 X 轴推挤位移 */
|
||||
.book-wrapper {
|
||||
flex: none;
|
||||
@@ -594,22 +645,30 @@ onBeforeUnmount(pause)
|
||||
box-shadow: 0 34px 64px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
/* 竖排烫金书名(楷体 + 锐利金属倒角),过长自动截断 */
|
||||
.book-title {
|
||||
/* 书脊文字:书名竖排在上,来源在书名下侧横向居中 */
|
||||
.book-copy {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
inset: 10px 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: 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 会把开头那列放到最右,看着像反了) */
|
||||
writing-mode: vertical-lr;
|
||||
font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif;
|
||||
font-size: 15px;
|
||||
line-height: 1.15;
|
||||
letter-spacing: 5px;
|
||||
color: var(--brand-gold);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 10px 0;
|
||||
text-shadow:
|
||||
-0.5px -0.5px 0px rgba(255, 255, 255, 0.8),
|
||||
1px 1px 0px #704e10,
|
||||
@@ -617,6 +676,28 @@ onBeforeUnmount(pause)
|
||||
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 {
|
||||
margin: 30px 0 0;
|
||||
text-align: center;
|
||||
@@ -743,6 +824,7 @@ onBeforeUnmount(pause)
|
||||
|
||||
/* ---------- 响应式 ---------- */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.shelf-track,
|
||||
.book-inner,
|
||||
.book-shadow::before,
|
||||
.hero-text h1,
|
||||
@@ -754,9 +836,8 @@ onBeforeUnmount(pause)
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.shelf {
|
||||
flex-wrap: wrap;
|
||||
row-gap: 22px;
|
||||
.shelf-track {
|
||||
animation-duration: 28s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -774,7 +855,7 @@ onBeforeUnmount(pause)
|
||||
display: none;
|
||||
}
|
||||
|
||||
.shelf {
|
||||
.shelf-group {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
@@ -788,7 +869,11 @@ onBeforeUnmount(pause)
|
||||
|
||||
.book-title {
|
||||
font-size: 13px;
|
||||
letter-spacing: 5px;
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
|
||||
.book-source {
|
||||
font-size: 9px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user