主题功能同步:vivid 页脚补社交按钮排(含源码入口,居中);classic 文章页补右栏目录(滚动高亮)与顶部阅读进度条——快发盒经核实两套 UI 均已存在,无需补

This commit is contained in:
Sakurasan
2026-09-29 01:23:29 +08:00
parent 3eb0aab788
commit c2d5e9db89
5 changed files with 114 additions and 4 deletions
+17 -3
View File
@@ -1,5 +1,5 @@
<script setup>
import { computed, onMounted, ref, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import LeftNav from '../components/LeftNav.vue'
import RightRail from '../components/RightRail.vue'
@@ -33,6 +33,14 @@ function withHeadingIds(html) {
const contentHtml = ref('')
const headings = ref([])
// 顶部阅读进度条(classic):滚动过正文才算数,短文太短不显示
const progress = ref(0)
function onScroll() {
const doc = document.documentElement
const total = doc.scrollHeight - window.innerHeight
progress.value = total > 300 ? Math.min(100, (window.scrollY / total) * 100) : 0
}
async function load() {
loading.value = true
error.value = ''
@@ -52,7 +60,11 @@ async function load() {
}
}
onMounted(load)
onMounted(() => {
load()
window.addEventListener('scroll', onScroll, { passive: true })
})
onBeforeUnmount(() => window.removeEventListener('scroll', onScroll))
watch(() => route.params.slug, load)
const isShort = computed(() => post.value && post.value.kind === 'short')
@@ -71,6 +83,8 @@ const initial = computed(() => (site.author_name || 'O').trim().slice(0, 1).toUp
/>
<div v-else class="shell">
<!-- 阅读进度:贴在视口顶部的细线 -->
<div class="reading-bar" :style="{ width: progress + '%' }" aria-hidden="true"></div>
<div class="layout">
<!-- LeftNav / RightRail 之前 import 了却没渲染,导致整页掉进 236px 的左列。
补上,和 HomeView 的三栏一致。 -->
@@ -146,7 +160,7 @@ const initial = computed(() => (site.author_name || 'O').trim().slice(0, 1).toUp
<!-- 评论区(和 vivid 共用同一个组件,见 components/comments/) -->
<CommentSection v-if="post" :post-id="post.id" />
</main>
<RightRail />
<RightRail :toc="isShort ? [] : headings" />
</div>
</div>
</template>