mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 17:10:43 +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 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
103 lines
3.3 KiB
Python
103 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""生成 Windows .ico 和安卓图标,用 _build/icon_source.png 作为源图。
|
|
|
|
原来是自己画一个蓝色圆角方块(lanremote.ui.make_icon_image)。
|
|
现在改成用作者给的那张图。
|
|
|
|
产物:
|
|
windows/app.ico 给 PyInstaller
|
|
android/res/drawable-{m,h,xh,xxh,xxx}dpi/ic_launcher.png
|
|
(并删掉旧的矢量 res/drawable/ic_launcher.xml,不然同名资源会冲突)
|
|
|
|
源图是方形线稿,安卓启动图标习惯留点边距,所以缩到 88% 再居中放。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
SOURCE = ROOT / "_build" / "icon_source.png"
|
|
ICO = ROOT / "windows" / "app.ico"
|
|
RES = ROOT / "android" / "res"
|
|
PREVIEW = ROOT / "_build" / "icon_preview.png"
|
|
|
|
ANDROID_SIZES = {
|
|
"drawable-mdpi": 48,
|
|
"drawable-hdpi": 72,
|
|
"drawable-xhdpi": 96,
|
|
"drawable-xxhdpi": 144,
|
|
"drawable-xxxhdpi": 192,
|
|
}
|
|
|
|
ICO_SIZES = [16, 24, 32, 48, 64, 128, 256]
|
|
|
|
|
|
def load_source():
|
|
from PIL import Image
|
|
if not SOURCE.is_file():
|
|
raise SystemExit(f"找不到图标源图:{SOURCE}")
|
|
return Image.open(SOURCE).convert("RGBA")
|
|
|
|
|
|
def square(image):
|
|
"""居中裁成正方形,缩放才不会变形。"""
|
|
width, height = image.size
|
|
side = min(width, height)
|
|
left = (width - side) // 2
|
|
top = (height - side) // 2
|
|
return image.crop((left, top, left + side, top + side))
|
|
|
|
|
|
def rounded(image, size: int, radius_ratio: float = 0.22):
|
|
"""缩到 size 并做圆角。"""
|
|
from PIL import Image, ImageDraw
|
|
scaled = image.resize((size, size), Image.LANCZOS)
|
|
mask = Image.new("L", (size, size), 0)
|
|
ImageDraw.Draw(mask).rounded_rectangle(
|
|
(0, 0, size - 1, size - 1), radius=int(size * radius_ratio), fill=255)
|
|
out = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
|
out.paste(scaled, (0, 0), mask)
|
|
return out
|
|
|
|
|
|
def main() -> int:
|
|
from PIL import Image
|
|
|
|
source = square(load_source())
|
|
print(f" 源图: {SOURCE.name} {source.size[0]}x{source.size[1]}")
|
|
|
|
# ---------- 1. Windows .ico ----------
|
|
ICO.parent.mkdir(parents=True, exist_ok=True)
|
|
rounded(source, 256).save(ICO, format="ICO",
|
|
sizes=[(s, s) for s in ICO_SIZES])
|
|
print(f" windows/app.ico {ICO.stat().st_size} 字节 "
|
|
f"({', '.join(str(s) for s in ICO_SIZES)})")
|
|
|
|
# ---------- 2. 安卓图标 ----------
|
|
for folder, size in ANDROID_SIZES.items():
|
|
target_dir = RES / folder
|
|
target_dir.mkdir(parents=True, exist_ok=True)
|
|
inner = int(size * 0.88) # 留边
|
|
icon = rounded(source, inner)
|
|
canvas = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
|
offset = (size - inner) // 2
|
|
canvas.paste(icon, (offset, offset), icon)
|
|
canvas.save(target_dir / "ic_launcher.png")
|
|
print(f" {folder}/ic_launcher.png {size}x{size}")
|
|
|
|
# ---------- 3. 删掉旧矢量图(同名会冲突)----------
|
|
old_xml = RES / "drawable" / "ic_launcher.xml"
|
|
if old_xml.is_file():
|
|
old_xml.unlink()
|
|
print(" 删掉旧的 res/drawable/ic_launcher.xml(矢量图)")
|
|
|
|
# ---------- 4. 预览 ----------
|
|
rounded(source, 256).save(PREVIEW)
|
|
print(f" 预览: {PREVIEW.name}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|