fix: 后端ws不再raise无连接错误;修复定时逻辑
This commit is contained in:
@@ -966,7 +966,7 @@ class AppConfig(GlobalConfig):
|
|||||||
async def send_json(self, data: dict) -> None:
|
async def send_json(self, data: dict) -> None:
|
||||||
"""通过WebSocket发送JSON数据"""
|
"""通过WebSocket发送JSON数据"""
|
||||||
if Config.websocket is None:
|
if Config.websocket is None:
|
||||||
raise RuntimeError("WebSocket 未连接")
|
logger.warning("WebSocket 未连接")
|
||||||
else:
|
else:
|
||||||
await Config.websocket.send_json(data)
|
await Config.websocket.send_json(data)
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class _MainTimer:
|
|||||||
|
|
||||||
await asyncio.sleep(3600)
|
await asyncio.sleep(3600)
|
||||||
|
|
||||||
|
@logger.catch()
|
||||||
async def timed_start(self):
|
async def timed_start(self):
|
||||||
"""定时启动代理任务"""
|
"""定时启动代理任务"""
|
||||||
|
|
||||||
@@ -85,10 +86,14 @@ class _MainTimer:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# 避免重复调起任务
|
# 避免重复调起任务
|
||||||
if curtime == Config.get("Data", "LastTimeStarted"):
|
if curtime == queue.get("Data", "LastTimedStart"):
|
||||||
|
logger.debug("已启动过任务,跳过本任务")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for time_set in queue.TimeSet.values():
|
for time_set in queue.TimeSet.values():
|
||||||
|
logger.debug(
|
||||||
|
f"检查定时任务:{time_set.get('Info', 'Time')}, 启用状态:{time_set.get('Info', 'Enabled')}"
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
time_set.get("Info", "Enabled")
|
time_set.get("Info", "Enabled")
|
||||||
and curtime[11:16] == time_set.get("Info", "Time")
|
and curtime[11:16] == time_set.get("Info", "Time")
|
||||||
@@ -108,6 +113,8 @@ class _MainTimer:
|
|||||||
async def set_silence(self):
|
async def set_silence(self):
|
||||||
"""静默模式通过模拟老板键来隐藏模拟器窗口"""
|
"""静默模式通过模拟老板键来隐藏模拟器窗口"""
|
||||||
|
|
||||||
|
logger.debug("检查静默模式")
|
||||||
|
|
||||||
if (
|
if (
|
||||||
len(Config.if_ignore_silence) > 0
|
len(Config.if_ignore_silence) > 0
|
||||||
and Config.get("Function", "IfSilence")
|
and Config.get("Function", "IfSilence")
|
||||||
@@ -140,5 +147,7 @@ class _MainTimer:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"模拟按键时出错: {e}")
|
logger.exception(f"模拟按键时出错: {e}")
|
||||||
|
|
||||||
|
logger.debug("静默模式检查完毕")
|
||||||
|
|
||||||
|
|
||||||
MainTimer = _MainTimer()
|
MainTimer = _MainTimer()
|
||||||
|
|||||||
Reference in New Issue
Block a user