Files
unicut/scripts/build.sh
T
jinghui 59241af720 本地化改造:免登录 + 本机 AI + 离线可用
在上游 gitee.com/676015863/unicut 基础上做的自托管改造,使其可脱离官方账号体系
与 CDN 独立运行。详见 CHANGELOG.md。

主要能力
- 免登录:GUEST_USER 直接使用核心功能,checkAuth 不再拦截
- 本机 AI:对话 mimo-v2.6-flash(同源 /newapi/v1)、视觉 deepseek-v4-flash-vision-exp、
  生图 /omniai、生视频 /civideo;密钥仅存服务端(nginx 占位符 + entrypoint 注入)
- AI 一键出片:图片+标题 → AI 文案 → 人声/语速/情绪 → 确认生成直接排时间轴,
  并支持转场、图片运镜、字幕位置/大小/配色/入场动画
- 离线可用:工程数据 IndexedDB + 项目文件 JSON 双写;官方素材走同源 /cdn/ 反代;
  无 OPFS 时素材回落 IndexedDB files 表

修复
- 账号类接口本地短路,不再反复弹「Header parameter [authorization] cannot be empty」
- isFSApiSupported 改取值判断,修 OPFS 判定错误导致卡在文件夹引导页
- 模板素材统一 /cdn/ 改写 + nginx 兜底转发,修缩略图全裂
- 剔除素材已失效的模板(上游 CDN 已删,点开必卡 loading 50%)
- 补齐 SDK 内置 4 张滤镜贴图,修画布卡 loading 0%
- 封面上传失败不再中断整次保存

品牌与页面
- 「云剪」改为 UniCut
- 首页删除收费标准栏目;顶部菜单移除 GitHub/Gitee;底部栏整体下线

安全
- .env 与 public/local-ai.json(含密钥)已在 .gitignore,不入库
- public/local-ai.json.example 仅含占位符
2026-10-26 18:18:41 +08:00

81 lines
2.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
#
# UniCut 站点构建发布脚本(带断网 lint 门禁)
#
# bash scripts/build.sh
#
# 流程:拿构建锁 → 刷新本地素材 → 构建镜像 → 发布容器 → 导出产物跑 lint → curl 健康检查
#
# 环境变量:
# SKIP_LOCALIZE=1 跳过素材下载(默认会跑 scripts/localize-assets.py,可重复执行、已存在则跳过)
# SKIP_LINT=1 跳过产物 lint(只做构建发布)
#
# 说明:构建锁放在 /tmp/unicut_build.lock,避免多个任务并发 build 互相覆盖镜像与容器;
# 构建日志统一写 /tmp/unicut_build_site.log。
set -euo pipefail
SRC=/vol1/1000/HD1/docker/unicut-src
LOCK=/tmp/unicut_build.lock
LOG=/tmp/unicut_build_site.log
SITE=https://127.0.0.1:3005
WAIT_MAX=${LOCK_WAIT_MAX:-600}
cd "$SRC"
# ---------- 1. 构建锁 ----------
waited=0
until mkdir "$LOCK" 2>/dev/null; do
if [ "$waited" -ge "$WAIT_MAX" ]; then
echo "[build] 等待构建锁超时($LOCK 已被占用 ${WAIT_MAX}s)" >&2
exit 1
fi
echo "[build] 构建锁被占用,${waited}s 后重试…"
sleep 15
waited=$((waited + 15))
done
trap 'rmdir "$LOCK" 2>/dev/null || true' EXIT
echo "[build] 拿到构建锁(等待了 ${waited}s)"
# ---------- 2. 本地素材(可重复执行) ----------
if [ "${SKIP_LOCALIZE:-0}" != "1" ]; then
echo "[build] 刷新本地素材 scripts/localize-assets.py"
python3 scripts/localize-assets.py || echo "[build] 素材刷新有失败项,继续构建(详见 data-quality/reports/site/assets-localize.json)"
fi
# ---------- 3. 构建 + 发布 ----------
echo "[build] docker compose build unicut(日志:$LOG)"
{
docker compose build unicut
docker compose up -d --no-build unicut
} 2>&1 | tee "$LOG"
# ---------- 4. 导出产物并跑断网 lint ----------
if [ "${SKIP_LINT:-0}" != "1" ]; then
DIST=$(mktemp -d /tmp/unicut-dist-XXXXXX)
docker exec unicut tar -C /usr/share/nginx/html -cf - . | tar -C "$DIST" -xf -
echo "[build] 断网 lint:dist 导出到 $DIST"
set +e
python3 data-quality/scripts/site/00_lint_dist.py --dist "$DIST" 2>&1 | tee -a "$LOG"
LINT_RC=${PIPESTATUS[0]}
set -e
else
LINT_RC=0
fi
# ---------- 5. 健康检查:首页与详情页必须 200 ----------
echo "[build] 健康检查 $SITE"
for path in / /article/local-deploy-guide /article/offline-ready /offline-notice.html; do
code=$(curl -sk -o /dev/null -w '%{http_code}' "$SITE$path")
echo "[build] $code $SITE$path"
if [ "$code" != "200" ]; then
echo "[build] ❌ $path 返回 $code" >&2
exit 1
fi
done
if [ "$LINT_RC" -ne 0 ]; then
echo "[build] ❌ 断网 lint 未通过(external_refs != 0),详见上方报告" >&2
exit "$LINT_RC"
fi
echo "[build] ✅ 构建、发布、lint、健康检查全部通过"