From 16dcba410dd69d008e99fba78a800aac947211b6 Mon Sep 17 00:00:00 2001 From: "1152958806@qq.com" <1152958806@qq.com> Date: Sat, 23 Sep 2023 00:24:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E8=80=85=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E5=8F=AA=E6=9C=89=E4=B8=80=E6=9D=A1skills=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=BF=9E=E7=BB=AD=E7=82=B9=E5=87=BB=E4=BC=9A=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/assets/js/heo.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/templates/assets/js/heo.js b/templates/assets/js/heo.js index b736886f..8e0cb55e 100644 --- a/templates/assets/js/heo.js +++ b/templates/assets/js/heo.js @@ -434,13 +434,18 @@ var heo = { document.getElementById("toPageButton").href = e) }, changeSayHelloText: function() { - const e = GLOBAL_CONFIG.helloText.length == 0 ? ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"] : GLOBAL_CONFIG.helloText - , t = document.getElementById("author-info__sayhi"); - let o = e[Math.floor(Math.random() * e.length)]; - for (; o === lastSayHello; ) - o = e[Math.floor(Math.random() * e.length)]; - t.textContent = o, - lastSayHello = o + const greetings = GLOBAL_CONFIG.helloText.length == 0 ? ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"] : GLOBAL_CONFIG.helloText + , authorInfoSayHiElement = document.getElementById("author-info__sayhi"); + // 如果只有一个问候语,设置为默认值 + if (greetings.length === 1) { + authorInfoSayHiElement.textContent = greetings[0]; + return; + } + let randomGreeting = greetings[Math.floor(Math.random() * greetings.length)]; + for (; randomGreeting === lastSayHello; ) + randomGreeting = greetings[Math.floor(Math.random() * greetings.length)]; + authorInfoSayHiElement.textContent = randomGreeting, + lastSayHello = randomGreeting }, //匿名评论