halo-theme-hao/templates/modules/common/diytitle.html

22 lines
825 B
HTML
Raw Permalink Normal View History

2024-04-12 06:35:37 +00:00
<!-- 动态标题 -->
<script
th:if="${theme.config.other.diytitle.diytitleEnable}">
var leaveTitle = '[[${theme.config.other.diytitle.leaveTitle}]]';
var backTitle = '[[${theme.config.other.diytitle.backTitle}]]';
var OriginTitile = "[(${siteTitle})]"
var titleTime
document.addEventListener('visibilitychange', function () {
if (document.hidden) {
//离开当前页面时标签显示内容
document.title = leaveTitle
clearTimeout(titleTime)
} else {
//返回当前页面时标签显示内容
document.title = backTitle + OriginTitile
//两秒后变回正常标题
titleTime = setTimeout(function () {
document.title = OriginTitile
}, 2000)
}
})
</script>