Merge pull request #15 from Snarl3908/custom

feat: 首页打字机动画完全可配置,TypeWriteList 为空或注释时不再渲染标签和动画
This commit is contained in:
是小韩啊 2025-06-06 10:17:15 +08:00 committed by GitHub
commit cce2791c3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 3 deletions

View File

@ -8,5 +8,7 @@ import "./MainHeader.less";
<img src="/assets/images/lazy-loading.webp" data-vh-lz-src={SITE_INFO.Avatar} alt="avatar" />
</div>
<h3 class="auther">{SITE_INFO.Author || "-"}</h3>
{Array.isArray(SITE_INFO.TypeWriteList) && SITE_INFO.TypeWriteList.length > 0 && (
<p class="desc"></p>
</div>
)}
</div>

View File

@ -73,7 +73,7 @@ import "@/styles/ArticleBase.less";
</main>
<footer>
<!-- 打赏组件 -->
<Reward />
{SITE_CONFIG.Reward && (SITE_CONFIG.Reward.AliPay || SITE_CONFIG.Reward.WeChat) && <Reward />}
<!-- 版权©️信息 -->
<Copyright site={Site} id={post.data.id} title={post.data.title} sitename={Title} time={fmtTime(post.data.date, "YYYY-MM-DD A")} auther={Author} />
<!-- 底部谷歌广告 -->

View File

@ -80,7 +80,7 @@ const indexInit = async (only: boolean = true) => {
// Han Analytics 统计
HanAnalyticsInit();
// 打字效果
only && TypeWriteInit();
only && Array.isArray(SITE_INFO.TypeWriteList) && SITE_INFO.TypeWriteList.length > 0 && TypeWriteInit();
// 泡泡🫧效果
PaoPaoInit();
// 预加载搜索数据

View File

@ -3,6 +3,8 @@ export default () => {
const writeDom = document.querySelector('.header-main>.desc');
if (!writeDom) return;
const TypeWriteList = SITE_INFO.TypeWriteList;
// 如果 TypeWriteList 不是数组或没有内容则不执行动画
if (!Array.isArray(TypeWriteList) || TypeWriteList.length === 0) return;
let TypeWriteListIndex = 0;
let index = 0;
let isDeleting = false;