修复 v0.5 审查问题: platform 改名, 协议健壮性, CJK 匹配, VBS 引号, interception API

Browse Source
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yws
2026-10-02 01:39:06 +00:00
co-authored by Claude Opus 5.5
parent 176570e7cd
commit 809a7fb017
12 changed files with 667 additions and 360 deletions
+34
View File
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""Linux 截图提供者:X11 (PIL ImageGrab / scrot 兜底)。
Wayland 下 ImageGrab 不可用,需额外方案(见 README)。
"""
import os
import shutil
import subprocess
import tempfile
import time
class LinuxScreenshotProvider:
def grab(self):
# 1) PIL ImageGrab (X11)
try:
from PIL import ImageGrab
img = ImageGrab.grab()
path = os.path.join(tempfile.gettempdir(), 'lc_shot_%s.png' % time.strftime('%H%M%S'))
img.save(path)
return {'ok': True, 'path': path}
except Exception:
pass
# 2) scrot / import (ImageMagick) / gnome-screenshot 兜底
for cmd in (['scrot', '-z'], ['import', '-window', 'root'], ['gnome-screenshot', '-f']):
if shutil.which(cmd[0]):
path = os.path.join(tempfile.gettempdir(), 'lc_shot_%s.png' % time.strftime('%H%M%S'))
try:
subprocess.run(cmd + [path], check=True, timeout=20)
if os.path.exists(path):
return {'ok': True, 'path': path}
except Exception:
continue
return {'ok': False, 'error': 'no working screenshot method on this Linux (need X11 + PIL/scrot)'}