fix(app): camera preview distortion — swap sensor W/H for portrait

previewSize 报横向(W>H),竖屏直用会把画面拉扁。交换宽高转纵向比例再
FittedBox cover 铺满(裁切不变形)。397/397 全绿。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-24 16:07:44 +08:00
parent c199d0630c
commit 07761b1b26
9 changed files with 306 additions and 47 deletions
+114
View File
@@ -0,0 +1,114 @@
# /opt/photo-live/deploy/docker-compose-cn.yml —— 正式环境 cn 栈(2026-09-24)。
# 基于 infra/deploy/docker-compose.cn.yml 改造(同 ov 版偏差登记):
# ① 自管 mysql:8.4 + redis:7(1Panel MySQL 是 5.7.44 不满足基线)
# ② 独立桥网络 photo-net(与机上其它项目隔离)
# ③ web 回环端口 18088(避开 1Panel phpMyAdmin 的 8089 段)
# ④ mysql 内存调优:cn 机仅 3.5G(可用 ~1.4G),关 performance_schema、
# buffer pool 显式 128M(另建 2G swap 兜底,见部署记录)
# cn 侧多两个角色:worker(sharp 图片流水线)+ sync(跨境推送/对账/统计回传)。
# sync 需出网可达:OV_API_URL(https 443)与 DATABASE_URL_OV(47.254.176.10:13306,
# 安全组白名单 cn 出口 IP)。
name: photo-live-cn
x-logging: &default-logging
driver: json-file
options: { max-size: "10m", max-file: "3" }
services:
mysql:
image: mysql:8.4
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_bin --performance-schema=OFF --innodb-buffer-pool-size=128M
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: photo_cn
MYSQL_USER: photo_cn
MYSQL_PASSWORD: ${MYSQL_APP_PASSWORD}
volumes:
- mysql-cn-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 5s
retries: 24
restart: unless-stopped
logging: *default-logging
networks: [photo-net]
redis:
image: redis:7-alpine
healthcheck: { test: ["CMD", "redis-cli", "ping"], interval: 5s, retries: 12 }
restart: unless-stopped
logging: *default-logging
networks: [photo-net]
api-cn:
image: ${SERVER_IMAGE}
command: ["api-cn"]
init: true
env_file: .env.production-cn
environment:
PORT: "8080" # 容器内固定;对外经 web 反代
restart: unless-stopped
depends_on:
mysql: { condition: service_healthy }
redis: { condition: service_healthy }
healthcheck:
test: ["CMD", "curl", "-fs", "http://127.0.0.1:8080/v1/health"]
interval: 30s
timeout: 5s
retries: 5
start_period: 20s
logging: *default-logging
networks: [photo-net]
worker:
image: ${SERVER_IMAGE}
command: ["worker"]
init: true
env_file: .env.production-cn
# 无 HTTP 端口:健康面由 restart 策略 + 日志监控承担(RUNBOOK.md)
restart: unless-stopped
depends_on:
mysql: { condition: service_healthy }
redis: { condition: service_healthy }
logging: *default-logging
networks: [photo-net]
sync:
image: ${SERVER_IMAGE}
command: ["sync"]
init: true
env_file: .env.production-cn
# 需出网:OV_API_URL(443) + DATABASE_URL_OV(13306,待安全组放行)
restart: unless-stopped
depends_on:
mysql: { condition: service_healthy }
redis: { condition: service_healthy }
logging: *default-logging
networks: [photo-net]
web:
image: ${WEB_IMAGE}
init: true
environment:
API_UPSTREAM: http://api-cn:8080 # /v1 反代目标(含 WS /v1/realtime)
ROOT_REDIRECT: /admin/ # cn 根路径直达后台
ports:
- "127.0.0.1:18088:80" # 1Panel OpenResty 反代到此(站点已建)
restart: unless-stopped
depends_on:
api-cn: { condition: service_healthy }
healthcheck:
test: ["CMD", "wget", "-qO", "/dev/null", "http://127.0.0.1/"]
interval: 30s
timeout: 5s
retries: 5
start_period: 10s
logging: *default-logging
networks: [photo-net]
volumes:
mysql-cn-data:
networks:
photo-net: { driver: bridge }
+88
View File
@@ -0,0 +1,88 @@
# /opt/photo-live/deploy/docker-compose-ov.yml —— 正式环境 ov 栈(2026-09-24)。
# 基于 infra/deploy/docker-compose-ov.yml 改三点(计划 §2 T0 偏差登记):
# ① 自管 mysql:8.4 + redis:7(1Panel MySQL 是 5.7.44,不满足 8.4/utf8mb4_0900_bin 基线)
# ② 独立桥网络 photo-net(不挂 1panel-network,与机上其它项目隔离)
# ③ web-ov 回环端口 18089(8089 被 1Panel phpMyAdmin 占用)
# ④ mysql 公网映射 13306:cn 侧 sync 跨境直连读库——安全组仅放行 101.37.116.184!
# 同目录配套:.env(SERVER_IMAGE/WEB_IMAGE/MYSQL_ROOT_PASSWORD/MYSQL_APP_PASSWORD)
# 与 .env.production-ov(应用 env,模板=仓库根 .env.production.example-ov)。
name: photo-live-ov
x-logging: &default-logging
driver: json-file
options: { max-size: "10m", max-file: "3" }
services:
mysql:
image: mysql:8.4
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_0900_bin
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: photo_ov
MYSQL_USER: photo_ov
MYSQL_PASSWORD: ${MYSQL_APP_PASSWORD}
ports:
- "0.0.0.0:13306:3306" # 仅安全组白名单 cn IP 可达(阿里云控制台)
volumes:
- mysql-ov-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 5s
retries: 24
restart: unless-stopped
logging: *default-logging
networks: [photo-net]
redis:
image: redis:7-alpine
healthcheck: { test: ["CMD", "redis-cli", "ping"], interval: 5s, retries: 12 }
restart: unless-stopped
logging: *default-logging
networks: [photo-net]
api-ov:
image: ${SERVER_IMAGE}
command: ["api-ov"]
init: true
env_file: .env.production-ov
environment:
PORT_OV: "8081" # main-ov.ts 读 PORT_OV;容器内固定
restart: unless-stopped
depends_on:
mysql: { condition: service_healthy }
redis: { condition: service_healthy }
healthcheck:
test: ["CMD", "curl", "-fs", "http://127.0.0.1:8081/v1/health"]
interval: 30s
timeout: 5s
retries: 5
start_period: 20s
logging: *default-logging
networks: [photo-net]
web-ov:
image: ${WEB_IMAGE}
init: true
environment:
API_UPSTREAM: http://api-ov:8081 # /v1 反代目标(含 WS /v1/realtime)
ROOT_REDIRECT: /index.html # 观众端安全自指
ports:
- "127.0.0.1:18089:80" # 1Panel OpenResty 反代到此(站点已建)
restart: unless-stopped
depends_on:
api-ov: { condition: service_healthy }
healthcheck:
test: ["CMD", "wget", "-qO", "/dev/null", "http://127.0.0.1/"]
interval: 30s
timeout: 5s
retries: 5
start_period: 10s
logging: *default-logging
networks: [photo-net]
volumes:
mysql-ov-data:
networks:
photo-net: { driver: bridge }
+4
View File
@@ -0,0 +1,4 @@
SERVER_IMAGE=photo-live-server:30a3520-20260924
WEB_IMAGE=photo-live-web:30a3520-20260924-cn
MYSQL_ROOT_PASSWORD=2d88f24a008eac264944141c69b61b22dfbd00aaecd133c7
MYSQL_APP_PASSWORD=20a6f359f685b6a0ae725698d722cfc00357503d7a27ecd7
+4
View File
@@ -0,0 +1,4 @@
SERVER_IMAGE=photo-live-server:30a3520-20260924
WEB_IMAGE=photo-live-web:30a3520-20260924-ov
MYSQL_ROOT_PASSWORD=127bd53921e208fbc0f9ff9c0b64a5fa71069ef0b083c617
MYSQL_APP_PASSWORD=70e4a6edc39800bd160723cb62a9a8e6a91d4c8f4c0ce399