fix: 后端ws不再raise无连接错误;修复定时逻辑

This commit is contained in:
DLmaster361
2025-09-21 18:09:01 +08:00
parent 1c640c3df8
commit d5331b728d
2 changed files with 11 additions and 2 deletions

View File

@@ -966,7 +966,7 @@ class AppConfig(GlobalConfig):
async def send_json(self, data: dict) -> None:
"""通过WebSocket发送JSON数据"""
if Config.websocket is None:
raise RuntimeError("WebSocket 未连接")
logger.warning("WebSocket 未连接")
else:
await Config.websocket.send_json(data)

View File

@@ -72,6 +72,7 @@ class _MainTimer:
await asyncio.sleep(3600)
@logger.catch()
async def timed_start(self):
"""定时启动代理任务"""
@@ -85,10 +86,14 @@ class _MainTimer:
continue
# 避免重复调起任务
if curtime == Config.get("Data", "LastTimeStarted"):
if curtime == queue.get("Data", "LastTimedStart"):
logger.debug("已启动过任务,跳过本任务")
continue
for time_set in queue.TimeSet.values():
logger.debug(
f"检查定时任务:{time_set.get('Info', 'Time')}, 启用状态:{time_set.get('Info', 'Enabled')}"
)
if (
time_set.get("Info", "Enabled")
and curtime[11:16] == time_set.get("Info", "Time")
@@ -108,6 +113,8 @@ class _MainTimer:
async def set_silence(self):
"""静默模式通过模拟老板键来隐藏模拟器窗口"""
logger.debug("检查静默模式")
if (
len(Config.if_ignore_silence) > 0
and Config.get("Function", "IfSilence")
@@ -140,5 +147,7 @@ class _MainTimer:
except Exception as e:
logger.exception(f"模拟按键时出错: {e}")
logger.debug("静默模式检查完毕")
MainTimer = _MainTimer()