From cf97de94234e875c5bc32edde9ed796185cc2e94 Mon Sep 17 00:00:00 2001 From: soehi <811446351@qq.com> Date: Sun, 22 Nov 2026 23:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E5=88=B0=20982f0df=EF=BC=9A?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E5=85=B1=E4=BA=AB=E9=80=BB=E8=BE=91=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=80=BC=E7=8F=AD=E6=8F=90=E9=86=92=E5=9B=9E?= =?UTF-8?q?=E6=89=A7=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CENTER.md | 8 +-- dist/assets/styles.css | 32 ++-------- dist/index.html | 15 ++--- dist/js/app.js | 113 +++++++-------------------------- server/center.py | 105 +----------------------------- server/center_duty.py | 6 +- server/models.py | 10 +-- tests/test_center_tutorials.py | 67 ------------------- 8 files changed, 42 insertions(+), 314 deletions(-) delete mode 100644 tests/test_center_tutorials.py diff --git a/CENTER.md b/CENTER.md index 7b2e2d8..f80f362 100644 --- a/CENTER.md +++ b/CENTER.md @@ -1,12 +1,6 @@ # 赋能中心一楼 -导航中的“赋能中心一楼”整合活动记录、独立值班、物品清点与借出登记、展厅使用登记和设备使用教程。原有活动、账号和招生就业服务队值班功能保留。 - -## 设备使用教程 - -“设备使用教程”标签页提供视频上传、按教室号或设备名搜索、在线播放和本人删除。登录成员均可上传或观看,上传时需填写教室号和设备名,支持 MP4、WebM、MOV、M4V,单个文件不超过 500MB。 - -视频保存在业务数据库同目录的 `uploads/tutorials/`,不会出现在静态 `/uploads` 公开目录中;上传、列表、播放均需要登录,仅上传者可删除。浏览器通过登录请求取得视频,关闭播放弹层后释放临时视频资源。新增教程记录由启动时的表结构检查自动创建,不修改已有业务数据。部署备份继续保留整个 data 目录,包括教程视频。 +导航中的“赋能中心一楼”整合活动记录、独立值班、物品清点与借出登记。原有活动、账号和招生就业服务队值班功能保留。 ## 赋能中心一楼值班 diff --git a/dist/assets/styles.css b/dist/assets/styles.css index 1584874..9873533 100644 --- a/dist/assets/styles.css +++ b/dist/assets/styles.css @@ -19,8 +19,7 @@ --shadow: 0 2px 5px rgba(35, 64, 48, .025); } -* { box-sizing: border-box; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } -.btn, button { font: inherit; } +* { box-sizing: border-box; } html, body { margin: 0; @@ -99,7 +98,6 @@ textarea { width: 100%; resize: vertical; } .topbar-user { display: flex; align-items: center; gap: 10px; white-space: nowrap; } #topbar-name { font-weight: 600; font-size: 14px; } .menu-toggle { display: none; background: none; border: none; font-size: 20px; } -.new-activity-short { display: none; } /* ---------- 布局 ---------- */ .container { max-width: 1160px; margin: 0 auto; padding: 40px 28px 72px; } @@ -398,8 +396,6 @@ form input, form select, form textarea, .form-card input, .form-card select { wi /* ---------- 响应式 ---------- */ @media (max-width: 760px) { - :root { font-size: 14px; } - body { font-size: 14px; } #nav { display: none; position: absolute; @@ -517,12 +513,10 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .brand-mark { width: 26px; height: 28px; } .topbar-user { margin-left: auto; } .menu-toggle { display: grid; place-items: center; width: 42px; height: 42px; margin-left: 0; color: var(--ink); border-radius: 8px; } - #nav { padding: 4px 10px 8px; z-index: 1; } - #nav a { padding: 10px; font-size: 14px; } - #nav a:last-child { border-top: 1px solid var(--line); margin-top: 4px; } - #new-activity-btn { flex: none; font-size: 13px; padding: 9px 12px; white-space: nowrap; } - .new-activity-label { display: none; } - .new-activity-short { display: inline; } + #nav { padding: 12px 16px; box-shadow: 0 8px 12px #263c3508; } + #nav a { padding: 12px; } + #logout-btn { min-height: 42px; } + #new-activity-btn { font-size: 13px; padding: 9px 10px; } .container { padding: 28px 16px 56px; } .page-head { align-items: stretch; gap: 20px; } .page-head > div:first-child { width: 100%; } @@ -536,18 +530,9 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .stat:nth-child(even), .stat:last-child { border-right: 0; } .stat b { font-size: 25px; } .acard { padding: 20px; } - .acard-actions .btn { min-height: 40px; } - .photo-preview-summary { min-height: 40px; padding: 6px 10px; } - .photo-preview-summary [data-photo-preview] { min-height: 34px; padding-block: 2px; } .acard-meta { gap: 8px 10px; margin-top: 12px; } - .acard-meta .tag.cat { display: none; } .meta-item { max-width: 100%; } - .acard h3 { font-size: 17px; line-height: 1.4; } - .acard-desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; line-height: 1.6; } - .acard-actions .btn:not(.primary) { padding-inline: 10px; } .acard-actions .btn { min-height: 42px; } - .acard-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } - .acard-actions .btn { justify-content: center; padding-inline: 6px; white-space: nowrap; } .member-grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); } #members-table { table-layout: fixed; } #members-table th, #members-table td { padding: 12px 8px; font-size: 13px; overflow-wrap: anywhere; } @@ -556,8 +541,6 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .form-card { padding: 22px; } .modal-mask { padding: 16px 10px; } .modal { padding: 22px 18px; } - .center-tabs { gap: 4px; } - .center-tabs .tab { flex: 0 0 auto; padding-inline: 10px; font-size: 13px; white-space: nowrap; } .p-list li { flex-wrap: wrap; } .add-member-row input { min-width: 0; } } @@ -628,7 +611,7 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .center-shortcuts p { margin:5px 0 0; color:var(--muted); font-size:13px; } .center-shortcut-actions { display:flex; flex-wrap:wrap; gap:10px; } .center-shortcut-actions a { text-decoration:none; display:inline-flex; align-items:center; } -.center-tabs { max-width:none; margin-bottom:24px; } +.center-tabs { max-width:500px; margin-bottom:24px; } .center-check-status { padding:18px 20px; background:var(--primary-soft); border:1px solid #d5e5da; border-radius:12px; margin-bottom:20px; } .center-subhead { margin-top:32px; } .center-duty-head { display:flex; align-items:flex-end; justify-content:space-between; flex-wrap:wrap; gap:18px; margin-bottom:18px; } @@ -735,7 +718,4 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s .center-history { margin-top:28px; } .center-history summary { cursor:pointer; padding:12px 0; } .center-history .acard { margin-top:12px; } -.tutorial-video { display:block; width:100%; max-height:70vh; margin-top:18px; background:#151b17; border-radius:10px; } -.tutorial-actions { display:flex; align-items:center; gap:10px; margin-top:14px; } -.tutorial-upload-status { min-height:24px; } @media (min-width:761px) and (max-width:1000px) { .topbar-inner { flex-wrap:wrap; } #nav { order:3; flex-basis:100%; } } diff --git a/dist/index.html b/dist/index.html index b4a33fc..3621d44 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ WorkLog · 活动记录 - +
@@ -16,7 +16,7 @@
- + @@ -175,7 +175,7 @@

程序读取:GET /api/center/data;字段说明:GET /api/center/schema。均需使用本人登录令牌。

-
+
@@ -210,11 +210,6 @@
打开金山文档
-
@@ -363,7 +358,7 @@ - + diff --git a/dist/js/app.js b/dist/js/app.js index 6bf11a0..26fba3c 100644 --- a/dist/js/app.js +++ b/dist/js/app.js @@ -26,7 +26,6 @@ }); const fmtDay = (ms) => new Date(ms).toLocaleDateString("zh-CN", { year: "numeric", month: "2-digit", day: "2-digit" }); - const formatBytes = bytes => bytes >= MB ? `${(bytes / MB).toFixed(1)} MB` : `${Math.max(1, Math.ceil(bytes / 1024))} KB`; const STATUS_LABEL = { joined: "已确认", attended: "已参加", absent: "缺席" }; const toLocalInput = (ms) => { @@ -422,10 +421,15 @@ }); // ------------------------------------------------------------- 顶栏 + $("#brand").addEventListener("click", () => show("feed")); + $("#new-activity-btn").addEventListener("click", () => openActivityForm(null, state.view === 'center' ? 'center' : 'normal')); $("#menu-toggle").addEventListener("click", () => { const open = $("#nav").classList.toggle("open"); $("#menu-toggle").setAttribute("aria-expanded", String(open)); }); + $$("#nav a").forEach((a) => + a.addEventListener("click", (e) => { e.preventDefault(); show(a.dataset.view); }) + ); // ------------------------------------------------------------- 活动卡片 const initials = (name) => { @@ -516,7 +520,6 @@

${visTag}${statusTag} - ${isCenter ? '一楼记录' : ''} ${full ? `已满 ${a.capacity} 人` : ""} 📅 ${fmtDate(a.start_at)} ${a.location ? `📍 ${esc(a.location)}` : ""} @@ -524,11 +527,12 @@
${a.description ? `

${esc(a.description).slice(0, 160)}${a.description.length > 160 ? "…" : ""}

` : ""} + ${a.record_type === 'center' ? '赋能中心一楼活动记录' : ''} ${materialButtons(a)} ${photoGallery(a.photo_ids)}
- ${isCenter ? `${a.organizer ? `由 ${esc(a.organizer.display_name)} 记录` : '全员可见'}` : `${faces}${more}${a.participant_count} 人${opts.showOrganizer && a.organizer ? ` · ${esc(a.organizer.display_name)} 记录` : ""}`} + ${isCenter ? `仅作记录 · 全员可见${a.organizer ? ` · ${esc(a.organizer.display_name)} 记录` : ''}` : `${faces}${more}${a.participant_count} 人${opts.showOrganizer && a.organizer ? ` · ${esc(a.organizer.display_name)} 记录` : ""}`}
${actions.join("")}
@@ -891,33 +895,28 @@ return uploadFile('/api/center/materials', 'POST', file, onProgress, 'application/zip'); } - function uploadFile(path, method, file, onProgress, contentType, fields) { + function uploadFile(path, method, file, onProgress, contentType) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); materialUpload = xhr; xhr.open(method, path); xhr.setRequestHeader('Authorization', `Bearer ${getToken()}`); - if (contentType) xhr.setRequestHeader('Content-Type', contentType); + xhr.setRequestHeader('Content-Type', contentType); xhr.timeout = 10 * 60 * 1000; xhr.upload.onprogress = event => onProgress(event.loaded, event.lengthComputable ? event.total : file.size); xhr.upload.onload = () => onProgress(file.size, file.size); xhr.onload = () => { let result; try { result = JSON.parse(xhr.responseText); } catch { result = {}; } - if (xhr.status >= 200 && xhr.status < 300 && (result.id || result.timetable || result.ok)) resolve(result); + if (xhr.status >= 200 && xhr.status < 300 && (result.id || result.timetable)) resolve(result); else reject(new Error(xhr.status === 413 ? (typeof result.detail === 'string' ? result.detail : '上传文件过大,请检查大小限制') : apiErrorMessage(result.detail, xhr.status))); }; - xhr.onerror = () => reject(new Error('照片或附件没有上传成功:网络中断或文件过大(每张照片≤8MB、ZIP≤100MB)')); + xhr.onerror = () => reject(new Error('上传失败,请检查网络后重试')); xhr.ontimeout = () => reject(new Error('上传超时,请重试')); xhr.onabort = () => reject(new Error('上传已取消')); xhr.onloadend = () => { if (materialUpload === xhr) materialUpload = null; }; onProgress(0, file.size); - if (fields) { - const data = new FormData(); - Object.entries(fields).forEach(([key, value]) => data.append(key, value)); - data.append('video', file); - xhr.send(data); - } else xhr.send(file); + xhr.send(file); }); } @@ -938,11 +937,11 @@ } } - function centerUploadFields(prefix, photoLabel = '照片') { - return ` -

可选JPG、PNG、WebP,自动转成统一JPEG;最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张≤${CENTER_PHOTO_MAX_MB}MB。

+ function centerUploadFields(prefix) { + return ` +

可直接多选相册照片或拍照,支持JPG、PNG、WebP并自动转为统一JPEG;每次最多${CENTER_PHOTO_BATCH_LIMIT}张(含ZIP内照片),每张不超过${CENTER_PHOTO_MAX_MB}MB。

-

有PDF、Word、Excel等文档时打包成ZIP,最大${CENTER_ZIP_MAX_MB}MB。

`; +

需要附PDF、Word、Excel等文档时再上传ZIP,最大${CENTER_ZIP_MAX_MB}MB,可不含照片。

`; } function bindCenterUploads(form, box, label, meter, prefix) { @@ -1050,12 +1049,11 @@ // ---- 新建 / 编辑活动 function openActivityForm(existing = null, defaultType = 'normal') { const isEdit = !!existing; - const isCenter = existing?.record_type === 'center' || defaultType === 'center'; modal(` -

${isEdit ? "编辑工作" : (isCenter ? "记录一楼活动" : "记录一项工作")}

- +

${isEdit ? "编辑工作" : "记录一项工作"}

+
- +
@@ -1063,9 +1061,9 @@
- + - +