feat(web): 海选按场景分组 + 删场景点位页签 + 演出真实底图 + 破缓存
- 海选审核左侧改两列:场景列(按新字段 ir.scene 手动归类聚合,含全部/未分类) + 该场景事件列 - 删独立「场景/点位」页签(pointview.js 保留未引用) - 演出配置 Timeline 接真实场景俯视底图(setupShot 覆盖投影范围 + drawStage 叠图,复用 /api/pointsets 的 shot) - 事件 meta 加「所属场景」归类输入框(datalist 提示已有场景名) - db: events 加 scene 列 + 旧库 ALTER 迁移;upsert 镜像 ir.scene;list 返回 - app.py: 首页按文件 mtime 给 js/css 注入 ?v= 破浏览器缓存(根治新html配旧缓存js崩溃→弹口令)
This commit is contained in:
22
web/app.py
22
web/app.py
@ -13,13 +13,14 @@ import datetime
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import secrets
|
||||
import sys
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
from fastapi import FastAPI, Request, Response
|
||||
from fastapi.responses import JSONResponse, FileResponse, StreamingResponse
|
||||
from fastapi.responses import JSONResponse, FileResponse, StreamingResponse, HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
_HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
@ -339,9 +340,26 @@ async def export_zip():
|
||||
|
||||
|
||||
# ---------- 静态前端 ----------
|
||||
def _stamp_static_refs(html):
|
||||
"""给 index.html 里引用的本地 js/css 加 ?v=<文件mtime> 破浏览器缓存。
|
||||
只给改过的文件 bump 版本号(mtime 变才变)→ 改前端不必手动改版本、也不会再出现
|
||||
新 html 配旧缓存 js 的崩溃。外链(//)与已带 ?查询串的引用跳过。"""
|
||||
def repl(m):
|
||||
attr, ref = m.group(1), m.group(2)
|
||||
if ref.startswith("http") or ref.startswith("//"):
|
||||
return m.group(0)
|
||||
fp = os.path.join(_STATIC_DIR, ref)
|
||||
if os.path.isfile(fp):
|
||||
return '%s="%s?v=%d"' % (attr, ref, int(os.path.getmtime(fp)))
|
||||
return m.group(0)
|
||||
return re.sub(r'(src|href)="([^"?]+\.(?:js|css))"', repl, html)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def index():
|
||||
return FileResponse(os.path.join(_STATIC_DIR, "index.html"))
|
||||
with open(os.path.join(_STATIC_DIR, "index.html"), encoding="utf-8") as f:
|
||||
html = f.read()
|
||||
return HTMLResponse(_stamp_static_refs(html))
|
||||
|
||||
|
||||
app.mount("/", StaticFiles(directory=_STATIC_DIR), name="static")
|
||||
|
||||
Reference in New Issue
Block a user