Add HTTPS reverse proxy guide and PNG icons for real PWA install.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-12 15:00:15 +08:00
parent 1d00c36cd3
commit 21400700c5
8 changed files with 192 additions and 11 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# 从 SVG 生成 PWA 所需 PNG 图标(Chrome 安装条件)
# 用法: bash scripts/gen_pwa_icons.sh
set -euo pipefail
cd "$(dirname "$0")/../pwa/icons"
SVG="icon.svg"
if command -v rsvg-convert &>/dev/null; then
rsvg-convert -w 192 -h 192 "${SVG}" -o icon-192.png
rsvg-convert -w 512 -h 512 "${SVG}" -o icon-512.png
elif command -v convert &>/dev/null; then
convert -background none "${SVG}" -resize 192x192 icon-192.png
convert -background none "${SVG}" -resize 512x512 icon-512.png
elif command -v ffmpeg &>/dev/null; then
ffmpeg -y -f lavfi -i "color=c=0x0f1419:s=512x512" -frames:v 1 icon-512.png 2>/dev/null
ffmpeg -y -f lavfi -i "color=c=0x0f1419:s=192x192" -frames:v 1 icon-192.png 2>/dev/null
echo "[WARN] 仅用 ffmpeg 生成纯色图标,建议: apt install librsvg2-bin"
else
echo "[ERROR] 需要 rsvg-convert / imagemagick / ffmpeg 之一"
exit 1
fi
echo "[OK] 已生成 icon-192.png icon-512.png"
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# 生成本地 HTTPS 自签证书(局域网 PWA 安装用)
# 用法: sudo bash scripts/gen_ssl_cert.sh [服务器局域网IP]
set -euo pipefail
SERVER_IP="${1:-}"
SSL_DIR="/etc/nginx/ssl"
KEY="${SSL_DIR}/trading_studio.key"
CRT="${SSL_DIR}/trading_studio.crt"
if [[ "${EUID:-0}" -ne 0 ]]; then
echo "请使用 root: sudo bash scripts/gen_ssl_cert.sh 192.168.x.x"
exit 1
fi
if [[ -z "${SERVER_IP}" ]]; then
SERVER_IP=$(hostname -I | awk '{print $1}')
echo "[INFO] 未指定 IP,使用: ${SERVER_IP}"
fi
mkdir -p "${SSL_DIR}"
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-keyout "${KEY}" \
-out "${CRT}" \
-subj "/CN=TradingStudio/O=Trading/C=CN" \
-addext "subjectAltName=IP:${SERVER_IP},DNS:trading.local,DNS:localhost"
chmod 600 "${KEY}"
echo "[OK] 证书已生成:"
echo " ${CRT}"
echo " ${KEY}"
echo ""
echo "手机/平板首次访问 HTTPS 需点「继续访问」信任自签证书,之后即可安装 App。"