diff --git a/Dockerfile b/Dockerfile index ed231de..ce9aab2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,26 @@ FROM python:3.11-slim WORKDIR /app COPY requirements.txt /app/requirements.txt -# 国内服务器从默认PyPI下载大型识别组件可能超时;可用构建参数覆盖源。 +# 大型识别组件下载时可能短暂断线。优先使用构建参数指定的源, +# 失败后自动切换到官方 PyPI,并保留 BuildKit 下载缓存。 ARG PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ +ARG PIP_FALLBACK_INDEX_URL=https://pypi.org/simple/ +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_DEFAULT_TIMEOUT=300 \ + PIP_RETRIES=10 \ + PIP_PROGRESS_BAR=off RUN --mount=type=cache,target=/root/.cache/pip \ - python -m pip install --disable-pip-version-check --retries 3 --timeout 120 \ - --index-url "${PIP_INDEX_URL}" -r /app/requirements.txt + set -eu; \ + for index_url in "${PIP_INDEX_URL}" "${PIP_FALLBACK_INDEX_URL}"; do \ + echo "Installing Python dependencies from ${index_url}"; \ + if python -m pip install --prefer-binary --no-input \ + --retries "${PIP_RETRIES}" --timeout "${PIP_DEFAULT_TIMEOUT}" \ + --index-url "${index_url}" -r /app/requirements.txt; then \ + exit 0; \ + fi; \ + echo "Dependency download failed from ${index_url}; trying the next source"; \ + done; \ + exit 1 RUN python -c "import PIL, rapidocr, onnxruntime, cv2" COPY server /app/server diff --git a/UPGRADE.md b/UPGRADE.md index 59c0654..81aade8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -21,8 +21,8 @@ ## Coolify / Docker 构建依赖下载失败 -如果日志已成功检出 Git 提交,但停在 `pip install`,并出现 `files.pythonhosted.org` 下载缓慢或 `Temporary failure in name resolution`,失败发生在构建机下载依赖的阶段。镜像构建默认使用 HTTPS 阿里云 PyPI 镜像,并通过 BuildKit 缓存下载包,减少大型课表识别组件反复下载;构建时会检查 Pillow、RapidOCR、ONNX Runtime 和 OpenCV 能否导入。 +如果日志已成功检出 Git 提交,但停在 `pip install`,并出现 `files.pythonhosted.org` 下载缓慢、`Broken pipe` 或 `Temporary failure in name resolution`,失败发生在构建机下载依赖的阶段。镜像构建默认使用 HTTPS 阿里云 PyPI 镜像,并通过 BuildKit 缓存下载包,减少大型课表识别组件反复下载。每个依赖源会以 300 秒超时和 10 次连接重试安装;主源失败时自动尝试官方 PyPI。构建最后会检查 Pillow、RapidOCR、ONNX Runtime 和 OpenCV 能否导入。 -需要其他源时通过 Docker 构建参数 `PIP_INDEX_URL` 覆盖,例如官方源 `https://pypi.org/simple/`。使用 BuildKit 构建(Coolify 已默认启用)。重新部署时继续挂载原有 `/app/data`,保留原环境变量,不开启 `FORCE_SEED=1`。 +需要其他源时通过 Docker 构建参数 `PIP_INDEX_URL` 覆盖,备用源可通过 `PIP_FALLBACK_INDEX_URL` 设置,例如把任意一项改为 `https://pypi.org/simple/`。使用 BuildKit 构建(Coolify 已默认启用)。重新部署时继续挂载原有 `/app/data`,保留原环境变量,不开启 `FORCE_SEED=1`。 生产环境关闭 `WORKLOG_DEV_MODE` 并保留有效的 SMTP 配置;邮件链接的公网地址通过 `WORKLOG_BASE_URL` 设置。包内仅提供 `.env.example` 配置示例,不包含本机凭据和数据库。 diff --git a/dist/assets/styles.css b/dist/assets/styles.css index a3ad3ae..5bedc2b 100644 --- a/dist/assets/styles.css +++ b/dist/assets/styles.css @@ -580,14 +580,21 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .settings-divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0; } @media (max-width: 520px) { .duty-reminder-row { flex-wrap: wrap; } .duty-row-actions { width: 100%; } } -.activity-photos { display:flex; gap:10px; flex-wrap:wrap; margin:14px 0; } +.photo-preview { margin:14px 0; } +.photo-preview-summary { display:flex; align-items:center; flex-wrap:wrap; gap:10px; padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#f7faf8; color:var(--muted); font-size:13px; } +.photo-preview-summary strong { color:var(--text); } +.selected-photo-summary:empty { display:none; } +.activity-photos { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:10px; margin:12px 0 0; } .activity-photos:empty { display:none; } .activity-materials { margin:12px 0; display:flex; flex-direction:column; gap:8px; } .activity-materials > div { display:flex; flex-wrap:wrap; align-items:center; gap:8px; } .upload-progress { margin:16px 0; padding:12px 14px; border:1px solid var(--line); border-radius:10px; background:var(--primary-soft); } .upload-progress p { margin:0 0 8px; font-size:13px; overflow-wrap:anywhere; } .upload-progress progress { display:block; width:100%; height:12px; accent-color:var(--primary); } -.activity-photos img { width:120px; height:90px; object-fit:cover; border-radius:8px; border:1px solid var(--line); cursor:zoom-in; } +.activity-photos img { display:block; width:100%; aspect-ratio:4/3; height:auto; object-fit:cover; border-radius:8px; border:1px solid var(--line); cursor:zoom-in; background:#edf2ee; } +.activity-photos img.photo-loading { background:linear-gradient(110deg,#edf2ee 8%,#f8faf8 18%,#edf2ee 33%); background-size:200% 100%; animation:photo-shimmer 1.4s linear infinite; } +.activity-photos img.photo-error { display:grid; place-items:center; padding:10px; color:var(--muted); font-size:12px; cursor:default; } +@keyframes photo-shimmer { to { background-position-x:-200%; } } .center-toolbar { margin-bottom:24px; } .center-export { margin:0 0 24px; padding:16px 20px; border:1px solid var(--line); background:var(--card); border-radius:12px; } .center-export summary { cursor:pointer; font-weight:600; } diff --git a/dist/js/app.js b/dist/js/app.js index 09e9b13..61d851d 100644 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -403,6 +403,49 @@ return esc(/[\u4e00-\u9fff]/.test(s) ? s.slice(0, 1) : s.slice(0, 2).toUpperCase()); }; + function photoGallery(ids, label = '活动照片') { + const unique = [...new Set((ids || []).filter(Boolean))]; + if (!unique.length) return ''; + return `
${esc(a.description).slice(0, 160)}${a.description.length > 160 ? "…" : ""}
` : ""} ${a.record_type === 'center' ? '赋能中心一楼活动记录' : ''} ${materialButtons(a)} - ${(a.photo_ids || []).length ? `可直接多选相册照片或拍照,每次最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张不超过${CENTER_PHOTO_MAX_MB}MB。
+可直接多选相册照片或拍照,每次最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张不超过${CENTER_PHOTO_MAX_MB}MB。
需要附PDF、Word、Excel等文档时再上传ZIP,最大${CENTER_ZIP_MAX_MB}MB,可不含照片。
`; } @@ -877,10 +919,34 @@ const preview = $('#' + prefix + '-selected-photos'); preview.replaceChildren(); form.photos.setCustomValidity(form.photos.files.length > CENTER_PHOTO_BATCH_LIMIT ? `每次最多上传${CENTER_PHOTO_BATCH_LIMIT}张照片,请重新选择` : ''); if (form.photos.files.length > CENTER_PHOTO_BATCH_LIMIT) { form.photos.reportValidity(); box.classList.add('hidden'); return; } - for (const file of form.photos.files) { - const img = document.createElement('img'), url = URL.createObjectURL(file); - previewUrls.push(url); img.src = url; img.alt = file.name; preview.append(img); - } + const files = [...form.photos.files]; + if (!files.length) return; + preview.innerHTML = `照片和ZIP至少选择一种。编辑时会保留原照片和附件,所选内容追加保存。
照片和ZIP至少选择一种。编辑时会保留原照片和附件,所选内容追加保存。