惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Latest news
Latest news
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
L
LINUX DO - 热门话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
V
V2EX
博客园 - 司徒正美
B
Blog RSS Feed
AWS News Blog
AWS News Blog
MyScale Blog
MyScale Blog
Scott Helme
Scott Helme
Cisco Talos Blog
Cisco Talos Blog
Last Week in AI
Last Week in AI
NISL@THU
NISL@THU
博客园 - Franky
P
Proofpoint News Feed
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
S
Schneier on Security
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
G
GRAHAM CLULEY
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
WordPress大学
WordPress大学
The Hacker News
The Hacker News
T
Threatpost
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Microsoft Azure Blog
Microsoft Azure Blog
T
The Exploit Database - CXSecurity.com
Engineering at Meta
Engineering at Meta
罗磊的独立博客
T
The Blog of Author Tim Ferriss
D
Darknet – Hacking Tools, Hacker News & Cyber Security
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
K
Kaspersky official blog
SecWiki News
SecWiki News
云风的 BLOG
云风的 BLOG
美团技术团队
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
B
Blog
S
Security Affairs

Hyde Blog

Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog 关于我 关于我 Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog Hyde Blog
Hyde Blog
Hyde · 2025-10-26 · via Hyde Blog

网页标题切换 原创

创建 ​

  • docs\.vitepress\theme\components\目录下创建TitleChange.vue文件,并添加以下代码

vue

<template>
  <!-- 这是一个功能组件,不渲染任何DOM元素 -->
  <div style="display: none;"></div>
</template>

<script setup lang="ts">
import { ref, onBeforeUnmount, onMounted } from 'vue'
import { useEventListener } from 'vitepress-theme-teek'

const props = defineProps({
    hiddenTitle: {
        type: String,
        default: 'w(゚Д゚)w 不要走!再看看嘛!'
    },
    returnTitle: {
        type: String,
        default: '♪(^∇^*)欢迎回来!'
    }
})

const originTitle = ref('')
const titleTimer = ref<ReturnType<typeof setTimeout>>()
const stopListener = ref<() => void>()

onMounted(() => {
    originTitle.value = document.title

    const handleVisibilityChange = () => {
        if (document.hidden) {
            document.title = props.hiddenTitle
            clearTimeout(titleTimer.value)
        } else {
            document.title = props.returnTitle
            titleTimer.value = setTimeout(() => {
                document.title = originTitle.value
            }, 2000)
        }
    }

    stopListener.value = useEventListener(document, 'visibilitychange', handleVisibilityChange)
})

onBeforeUnmount(() => {
    stopListener.value?.()
    clearTimeout(titleTimer.value)
})
</script>

使用 ​

  • docs\.vitepress\theme\components\目录下的TeekLayoutProvider.vue引入并使用

vue

<script setup lang="ts" name="TeekLayoutProvider">
// @ts-ignore
import TitleChange from "./TitleChange.vue"; //导入网页标题变化
</script>

<template>
  <Teek.Layout>
    <template #layout-top>
      <!--网页标题切换组件  -->
      <TitleChange />
    </template>
    其他组件...
  </Teek.Layout>
</template>