模块:沙盒/Kurgenera/welcome
跳转到导航
跳转到搜索
local p = {}
function p.welcome(frame)
local hour = (tonumber(os.date("!%H")) + 8) % 24
local greetingText = ""
local bgColor = ""
local textColor = ""
if hour >= 5 and hour < 7 then
greetingText = "晨光熹微🌱 愿你拥有好心情!"
bgColor = "#c8e6c9"
textColor = "#1b5e20"
elseif hour >= 7 and hour < 12 then
greetingText = "早上好!☕ 愿您拥有美好的一天。"
bgColor = "#e8f5e9"
textColor = "#2e7d32"
elseif hour >= 11 and hour < 13 then
greetingText = "中午好!🍲 吃顿好的犒劳自己。"
bgColor = "#ffb74d"
textColor = "#5d4037"
elseif hour >= 13 and hour < 17 then
greetingText = "下午好!🌞 感谢您的来访。"
bgColor = "#fff3e0"
textColor = "#ef6c00"
elseif hour >= 17 and hour < 18 then
greetingText = "傍晚好!🌇 记得抬头看看天空。"
bgColor = "#fff3e0"
textColor = "#ef6c00"
elseif hour >= 18 and hour < 23 then
greetingText = "晚上好!🌙 欢迎您在此休息片刻。"
bgColor = "#e3f2fd"
textColor = "#1565c0"
else
greetingText = "深夜了,注意休息。💻 很高兴您能来。"
bgColor = "#263238"
textColor = "#eceff1"
end
local res = mw.html.create('div')
res
:css('padding', '15px')
:css('border-radius', '5px')
:css('font-size', '1.2em')
:css('text-align', 'center')
:css('background-color', bgColor)
:css('color', textColor)
:css('position', 'relative') -- 为备注定位做准备
:tag('strong')
:wikitext(greetingText)
:done() -- 结束 strong 标签
res:tag('div')
:css('text-align', 'right')
:css('font-size', '0.6em') -- 缩小字号
:css('opacity', '0.7') -- 半透明效果,显得更有质感
:css('margin-top', '5px')
:wikitext("当前显示时间基于 UTC+8")
return tostring(res)
end
return p