mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 13:40:45 +00:00
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""服务端接上新命令:音色列表 / 本机音频列表 / 播放本机音频 / 投图标题。"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SERVER = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\windows"
|
|
r"\lanremote\server.py")
|
|
|
|
OLD_IMAGE = ''' if kind == P.CMD_IMAGE:
|
|
note = self.actions.show_image(str(target))'''
|
|
NEW_IMAGE = ''' if kind == P.CMD_IMAGE:
|
|
note = self.actions.show_image(str(target),
|
|
str(msg.get("title") or ""))'''
|
|
|
|
OLD_SAY = ''' if cmd == P.CMD_SAY:
|
|
note = self.actions.say(str(msg.get("text") or ""))
|
|
self._log(f"[播报] {note}")
|
|
return {"ok": True, "note": note}
|
|
'''
|
|
|
|
NEW_SAY = ''' if cmd == P.CMD_SAY:
|
|
try:
|
|
rate = int(msg.get("rate") or 0)
|
|
except (TypeError, ValueError):
|
|
rate = 0
|
|
note = self.actions.say(str(msg.get("text") or ""),
|
|
str(msg.get("voice") or ""), rate)
|
|
self._log(f"[播报] {note}")
|
|
return {"ok": True, "note": note}
|
|
|
|
if cmd == P.CMD_VOICE_LIST:
|
|
voices = self.actions.list_voices()
|
|
return {"ok": True, "voices": voices,
|
|
"current": str(self.store.get("tts_voice") or "")}
|
|
|
|
if cmd == P.CMD_AUDIO_LIST:
|
|
return {"ok": True,
|
|
"files": self.actions.list_local_audio(),
|
|
"roots": [str(p) for p in self.actions.audio_roots()]}
|
|
|
|
if cmd == P.CMD_PLAY_LOCAL:
|
|
note = self.actions.play_local(str(msg.get("path") or ""))
|
|
self._log(f"[本机播放] {note}")
|
|
return {"ok": True, "note": note}
|
|
'''
|
|
|
|
|
|
def main() -> int:
|
|
text = SERVER.read_text(encoding="utf-8")
|
|
ok = True
|
|
for old, new, tag in ((OLD_IMAGE, NEW_IMAGE, "投图标题"),
|
|
(OLD_SAY, NEW_SAY, "新命令")):
|
|
if old not in text:
|
|
print(f" [失败] {tag} 锚点未匹配")
|
|
ok = False
|
|
else:
|
|
text = text.replace(old, new, 1)
|
|
print(f" {tag}: OK")
|
|
|
|
if ok:
|
|
SERVER.write_text(text, encoding="utf-8")
|
|
|
|
print("\n语法检查:")
|
|
import ast
|
|
try:
|
|
ast.parse(SERVER.read_text(encoding="utf-8"))
|
|
print(" server.py: OK")
|
|
except SyntaxError as exc:
|
|
print(f" server.py: 语法错误 {exc}")
|
|
ok = False
|
|
return 0 if ok else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|