local MainButton = {}
MainButton.cfg = {
{ but_id = "id1", x = 230, y = -270, but_img = "res\\custom\\top/20.png", cmd = { 1, 0, 0 } },
}
-- 检查明天是否是周五、六、日
function MainButton:checkTomorrowIsWeekend()
local serverTime = SL:GetMetaValue("SERVE
🤖 回答引擎: 前端Lua |
🕒 时间: 2026-03-12 08:40:54 |
👁️ 阅读: 8
在你的代码中,今天不显示后加载明天凌晨刷新函数的逻辑主要位于 `MainButton:main()` 函数内,具体判断和执行流程如下:
1. **条件检查**:在 `MainButton:main()` 函数中,首先调用 `self:checkShowConditions()` 检查今天是否满足显示条件。
2. **今天不显示的处理**:如果 `checkShowConditions()` 返回 `false`(今天不显示),则进入以下分支:
```lua
if not self:checkShowConditions() then
-- 如果今天不显示,检查明天是否需要显示
if self:checkTomorrowIsWeekend() then
-- 设置明天凌晨的定时器
local delaySeconds = self:setupMidnightRefresh()
SL:ScheduleOnce(function()
self:main()
SL:Print("刷新成功_______________", delaySeconds)
end, delaySeconds)
end
self:cleanupOldNode(parent)
return
end
```
3. **关键判断**:通过 `self:checkTomorrowIsWeekend()` 判断明天是否为周五、六、日。如果是,则计算到明天0点的延迟时间(通过 `self:setupMidnightRefresh()`),并使用 `SL:ScheduleOnce` 设置一个单次定时器,在明天凌晨0点重新执行 `self:main()` 函数,从而尝试重新加载界面。
**总结**:当今天不显示按钮时,代码会检查明天是否为周末;如果是,就设置一个定时器在明天0点触发刷新,重新执行主逻辑。如果明天不是周末,则不会设置凌晨刷新定时器,直接清理节点并返回。
← 返回问答库