refactor: say good night to YukiReflection

This commit is contained in:
2025-06-17 18:37:05 +08:00
parent d4ccd19ecd
commit 47d590d6a1
4 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import { defineClientConfig } from '@vuepress/client'
import { h, onMounted, watch } from 'vue'
import DeprecatedBanner from './components/DeprecatedBanner.vue'
import { useRoute } from 'vue-router'
export default defineClientConfig({
rootComponents: [
() => h(DeprecatedBanner)
],
setup() {
const route = useRoute()
const adjustLayout = () => {
requestAnimationFrame(() => {
const banner = document.querySelector('.deprecated-banner') as HTMLElement
const height = banner?.clientHeight ?? 0
const themeContainer = document.querySelector('.theme-container') as HTMLElement
const navbar = document.querySelector('.navbar') as HTMLElement
const sidebar = document.querySelector('.sidebar') as HTMLElement
if (height > 0) {
if (themeContainer) themeContainer.style.paddingTop = `${height}px`
if (navbar) navbar.style.marginTop = `${height}px`
if (sidebar) sidebar.style.marginTop = `${height}px`
}
})
}
onMounted(() => {
adjustLayout()
})
watch(() => route.path, () => {
adjustLayout()
})
}
})

View File

@@ -0,0 +1,35 @@
<template>
<div class="deprecated-banner">
YukiReflection is deprecated, Start trying <a href="https://github.com/HighCapable/KavaRef" target="_blank"
rel="noopener">KavaRef</a> now!&nbsp
YukiReflection 已被弃用立即尝试 <a href="https://github.com/HighCapable/KavaRef/blob/main/README-zh-CN.md"
target="_blank" rel="noopener">KavaRef</a>
</div>
</template>
<style scoped>
.deprecated-banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #ffdddd;
color: #a00000;
text-align: center;
padding: 12px 24px;
font-weight: bold;
font-size: 16px;
z-index: 9999;
}
.deprecated-banner a {
color: #a00000;
text-decoration: underline;
font-weight: bold;
}
.deprecated-banner a:hover {
color: #600000;
}
</style>