feat(upload): 分片断点续传 + 前端静态资源去 CDN 化
1) 分片上传(routes/chunked.py) - POST /api/upload/init 建会话,校验表单/字段/扩展名/体积 - POST /api/upload/chunk 单片上传,幂等可重传,http body 直写磁盘 - GET /api/upload/status 查询已收分片 - POST /api/upload/complete 按序合并 + sha256 校验 + 清理分片 - /api/submit 新增 field fileTokens 挂载已上传文件(零拷贝 os.replace) - 过期会话(24h)由定时任务清理 2) 弱网下的样式可靠性 - Tailwind Play CDN / GSAP 改为本地自托管(static/js/vendor/) - vendor 资源 1 年 immutable 缓存,自家 css/js 1 小时 - CSS link 失败自动带 ?r= 重试一次 - status 页加关键内联样式兜底,极端情况下仍可读 3) 大文件落盘沿用流式写入(无 400MB 内存峰值)
This commit is contained in:
@@ -4,3 +4,4 @@ data/
|
|||||||
*.zip
|
*.zip
|
||||||
*.log
|
*.log
|
||||||
.temp/
|
.temp/
|
||||||
|
.venv/
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ from routes.files import bp as files_bp, init_app_state as files_init
|
|||||||
from routes.presets import bp as presets_bp
|
from routes.presets import bp as presets_bp
|
||||||
from routes.users import bp as users_bp
|
from routes.users import bp as users_bp
|
||||||
from routes.export import bp as export_bp
|
from routes.export import bp as export_bp
|
||||||
|
from routes.chunked import bp as chunked_bp, cleanup_stale_uploads
|
||||||
|
|
||||||
app.register_blueprint(auth_bp)
|
app.register_blueprint(auth_bp)
|
||||||
app.register_blueprint(pages_bp)
|
app.register_blueprint(pages_bp)
|
||||||
@@ -212,6 +213,7 @@ app.register_blueprint(submissions_bp)
|
|||||||
app.register_blueprint(presets_bp)
|
app.register_blueprint(presets_bp)
|
||||||
app.register_blueprint(users_bp)
|
app.register_blueprint(users_bp)
|
||||||
app.register_blueprint(export_bp)
|
app.register_blueprint(export_bp)
|
||||||
|
app.register_blueprint(chunked_bp)
|
||||||
app.register_blueprint(files_bp)
|
app.register_blueprint(files_bp)
|
||||||
|
|
||||||
# 注入全局状态到 files 蓝图
|
# 注入全局状态到 files 蓝图
|
||||||
@@ -304,6 +306,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
scheduler.add_job(cleanup_expired_forms_task, 'cron', hour=2, minute=0)
|
scheduler.add_job(cleanup_expired_forms_task, 'cron', hour=2, minute=0)
|
||||||
scheduler.add_job(cleanup_temp_zip_files, 'cron', hour='*/1')
|
scheduler.add_job(cleanup_temp_zip_files, 'cron', hour='*/1')
|
||||||
|
scheduler.add_job(cleanup_stale_uploads, 'cron', minute=17)
|
||||||
scheduler.add_job(cleanup_expired_sessions, 'cron', hour=3, minute=0)
|
scheduler.add_job(cleanup_expired_sessions, 'cron', hour=3, minute=0)
|
||||||
scheduler.add_job(
|
scheduler.add_job(
|
||||||
lambda: collect_metrics_snapshot(_active_requests_counter, get_online_users_count),
|
lambda: collect_metrics_snapshot(_active_requests_counter, get_online_users_count),
|
||||||
@@ -327,6 +330,24 @@ def monitor_before_request():
|
|||||||
_active_requests_counter['count'] += 1
|
_active_requests_counter['count'] += 1
|
||||||
|
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def static_cache_headers(response):
|
||||||
|
"""弱网下的静态资源策略。
|
||||||
|
|
||||||
|
vendor/ 里的文件版本固定(tailwind 3.4.17、gsap 3.12.2),可以永久缓存:
|
||||||
|
一旦加载成功,之后断网也不会再丢样式。
|
||||||
|
自家 css/js 用 1 小时缓存,兼顾“发版后能及时更新”和“少一次往返”。
|
||||||
|
单文件加载失败时,模板上的 onerror 会带 ?r= 时间戳重试一次。
|
||||||
|
"""
|
||||||
|
path = request.path or ""
|
||||||
|
if path.startswith("/static/js/vendor/"):
|
||||||
|
response.headers["Cache-Control"] = "public, max-age=31536000, immutable"
|
||||||
|
elif path.startswith("/static/"):
|
||||||
|
# Flask 的 send_from_directory 默认写 no-cache,这里必须直接覆盖
|
||||||
|
response.headers["Cache-Control"] = "public, max-age=3600"
|
||||||
|
return response
|
||||||
|
|
||||||
|
# vendor_immutable_cache
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def monitor_after_request(response):
|
def monitor_after_request(response):
|
||||||
"""请求结束:减计数 + 记录API调用统计"""
|
"""请求结束:减计数 + 记录API调用统计"""
|
||||||
|
|||||||
+52
@@ -1261,6 +1261,58 @@ def save_file_stream(form_id, file_storage, filename, original_name=None, mime_t
|
|||||||
return file_id
|
return file_id
|
||||||
|
|
||||||
|
|
||||||
|
def attach_uploaded_file(form_id, src_path, filename, original_name=None, mime_type=None,
|
||||||
|
field_name=None, submission_id=None):
|
||||||
|
"""把已经上传并合并好的文件(分片上传的产物)挂到 files 表。
|
||||||
|
|
||||||
|
与 save_file_stream 的区别:内容已经在磁盘上,这里只做登记 + 原子移动,
|
||||||
|
不再复制一遍,所以 400MB 也能瞬间完成。
|
||||||
|
"""
|
||||||
|
size = os.path.getsize(src_path)
|
||||||
|
|
||||||
|
with get_db_connection() as conn:
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute(
|
||||||
|
"INSERT INTO files "
|
||||||
|
"(form_id, submission_id, filename, original_name, file_size, mime_type, "
|
||||||
|
" file_data, uploaded_at, field_name) "
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
(
|
||||||
|
form_id,
|
||||||
|
submission_id,
|
||||||
|
filename,
|
||||||
|
original_name,
|
||||||
|
size,
|
||||||
|
mime_type,
|
||||||
|
b"",
|
||||||
|
datetime.now().isoformat(),
|
||||||
|
field_name,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
file_id = cursor.lastrowid
|
||||||
|
|
||||||
|
rel_path = f"{form_id}/{file_id}.bin"
|
||||||
|
abs_path = _disk_path(rel_path)
|
||||||
|
os.makedirs(os.path.dirname(abs_path), exist_ok=True)
|
||||||
|
try:
|
||||||
|
# 同一文件系统内 os.replace 是原子且零拷贝;跨设备退化为复制
|
||||||
|
try:
|
||||||
|
os.replace(src_path, abs_path)
|
||||||
|
except OSError:
|
||||||
|
import shutil
|
||||||
|
shutil.copyfileobj(open(src_path, 'rb'), open(abs_path, 'wb'), 4 * 1024 * 1024)
|
||||||
|
os.remove(src_path)
|
||||||
|
except BaseException:
|
||||||
|
try:
|
||||||
|
os.remove(abs_path)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
cursor.execute("DELETE FROM files WHERE id = ?", (file_id,))
|
||||||
|
raise
|
||||||
|
cursor.execute("UPDATE files SET file_path = ? WHERE id = ?", (rel_path, file_id))
|
||||||
|
return file_id
|
||||||
|
|
||||||
|
|
||||||
def get_file(file_id):
|
def get_file(file_id):
|
||||||
"""获取单个文件(file_data 从磁盘读取)"""
|
"""获取单个文件(file_data 从磁盘读取)"""
|
||||||
with get_db_connection() as conn:
|
with get_db_connection() as conn:
|
||||||
|
|||||||
@@ -0,0 +1,328 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
分片(断点续传)上传。
|
||||||
|
|
||||||
|
为什么需要:单个 400MB 的 POST 在移动网络/家宽上要跑几分钟到十几分钟,任何一端的
|
||||||
|
读超时(Traefik 60s、手机系统、运营商)都会把整个请求作废,客户端只能从头再传。
|
||||||
|
切片后每片只有几 MB,失败只重传那一片。
|
||||||
|
|
||||||
|
接口(与现有 /api/submit 并存,老客户端不受影响):
|
||||||
|
|
||||||
|
POST /api/upload/init {formId, field, filename, size, chunkSize?}
|
||||||
|
→ {upload_id, chunk_size, expires_in}
|
||||||
|
POST /api/upload/chunk ?upload_id=..&index=.. 原始字节 body
|
||||||
|
→ {ok, index, received, total_received, complete}
|
||||||
|
GET /api/upload/status ?upload_id=..
|
||||||
|
→ {received:[...], missing:[...], complete}
|
||||||
|
POST /api/upload/complete {upload_id}
|
||||||
|
→ {ok, upload_id, size, sha256}
|
||||||
|
|
||||||
|
最后提交时把 fileTokens={"字段名": upload_id, ...} 一起 POST 到 /api/submit,
|
||||||
|
服务端把已拼好的文件挂到提交记录上(不再走 multipart 传文件)。
|
||||||
|
|
||||||
|
存储:data/chunks/<upload_id>/part_<index>,完成后拼成 assembled.bin。
|
||||||
|
过期:默认 24 小时,由 app.py 的定时任务清理。
|
||||||
|
"""
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from flask import Blueprint, jsonify, request
|
||||||
|
|
||||||
|
from config import DATA_DIR
|
||||||
|
from database import attach_uploaded_file, get_form
|
||||||
|
from utils.helpers import get_client_ip # noqa: F401 (与提交接口一致的客户端 IP 口径)
|
||||||
|
|
||||||
|
bp = Blueprint('chunked', __name__)
|
||||||
|
|
||||||
|
CHUNKS_DIR = os.path.join(os.fspath(DATA_DIR), 'chunks')
|
||||||
|
DEFAULT_CHUNK_SIZE = 8 * 1024 * 1024 # 8MB/片:弱网下单片几十秒,重传代价可接受
|
||||||
|
MAX_CHUNK_SIZE = 32 * 1024 * 1024
|
||||||
|
MAX_CHUNKS = 20000
|
||||||
|
TTL_SECONDS = 24 * 3600
|
||||||
|
|
||||||
|
_UPLOAD_ID_RE = re.compile(r'^[0-9a-f]{32}$')
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 工具函数
|
||||||
|
|
||||||
|
def _upload_dir(upload_id: str) -> str:
|
||||||
|
if not _UPLOAD_ID_RE.match(upload_id or ''):
|
||||||
|
raise ValueError('upload_id 不合法')
|
||||||
|
return os.path.join(CHUNKS_DIR, upload_id)
|
||||||
|
|
||||||
|
|
||||||
|
def _meta_path(upload_id: str) -> str:
|
||||||
|
return os.path.join(_upload_dir(upload_id), 'meta.json')
|
||||||
|
|
||||||
|
|
||||||
|
def _read_meta(upload_id: str) -> dict:
|
||||||
|
path = _meta_path(upload_id)
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
raise FileNotFoundError('上传会话不存在或已过期')
|
||||||
|
with open(path, encoding='utf-8') as f:
|
||||||
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
def _write_meta(upload_id: str, meta: dict) -> None:
|
||||||
|
path = _meta_path(upload_id)
|
||||||
|
tmp = path + '.tmp'
|
||||||
|
with open(tmp, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(meta, f, ensure_ascii=False)
|
||||||
|
f.flush()
|
||||||
|
os.fsync(f.fileno())
|
||||||
|
os.replace(tmp, path)
|
||||||
|
|
||||||
|
|
||||||
|
def _check_field(form: dict, field_name: str, filename: str, size: int):
|
||||||
|
"""校验字段存在、扩展名允许、体积不超限。返回该字段配置。"""
|
||||||
|
file_fields = [f for f in form.get('fields', []) if f.get('type') == 'file']
|
||||||
|
field = next((f for f in file_fields if f.get('name') == field_name), None)
|
||||||
|
if field is None:
|
||||||
|
raise ValueError(f'表单里没有文件字段 {field_name}')
|
||||||
|
|
||||||
|
ext = (filename.rsplit('.', 1)[-1] if '.' in filename else '').lower()
|
||||||
|
allowed = field.get('allowedExts') or form.get('allowedExts') or []
|
||||||
|
if allowed and ext not in [e.lower() for e in allowed]:
|
||||||
|
raise ValueError(f'不支持的格式: {ext}')
|
||||||
|
|
||||||
|
limit = form.get('maxSize') or 0
|
||||||
|
if limit and size > limit:
|
||||||
|
raise ValueError(f'文件大小超过限制(上限 {limit // 1048576}MB)')
|
||||||
|
return field
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 接口
|
||||||
|
|
||||||
|
@bp.route('/api/upload/init', methods=['POST'])
|
||||||
|
def upload_init():
|
||||||
|
body = request.get_json(silent=True) or {}
|
||||||
|
form_id = (body.get('formId') or '').strip()
|
||||||
|
field_name = (body.get('field') or '').strip()
|
||||||
|
filename = (body.get('filename') or '').strip()
|
||||||
|
try:
|
||||||
|
size = int(body.get('size') or 0)
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return jsonify(ok=False, message='size 必须是整数'), 400
|
||||||
|
|
||||||
|
if not form_id or not field_name or not filename:
|
||||||
|
return jsonify(ok=False, message='formId / field / filename 必填'), 400
|
||||||
|
if size <= 0:
|
||||||
|
return jsonify(ok=False, message='size 必须大于 0'), 400
|
||||||
|
|
||||||
|
form = get_form(form_id)
|
||||||
|
if not form:
|
||||||
|
return jsonify(ok=False, message='表单配置不存在或已过期'), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
_check_field(form, field_name, filename, size)
|
||||||
|
except ValueError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 400
|
||||||
|
|
||||||
|
chunk_size = int(body.get('chunkSize') or DEFAULT_CHUNK_SIZE)
|
||||||
|
chunk_size = max(256 * 1024, min(chunk_size, MAX_CHUNK_SIZE))
|
||||||
|
total = (size + chunk_size - 1) // chunk_size
|
||||||
|
if total > MAX_CHUNKS:
|
||||||
|
return jsonify(ok=False, message='分片数量过多,请增大 chunkSize'), 400
|
||||||
|
|
||||||
|
upload_id = uuid.uuid4().hex
|
||||||
|
os.makedirs(_upload_dir(upload_id), exist_ok=True)
|
||||||
|
_write_meta(upload_id, {
|
||||||
|
'upload_id': upload_id,
|
||||||
|
'form_id': form_id,
|
||||||
|
'field': field_name,
|
||||||
|
'filename': filename,
|
||||||
|
'size': size,
|
||||||
|
'chunk_size': chunk_size,
|
||||||
|
'total': total,
|
||||||
|
'created': int(time.time()),
|
||||||
|
'ip': request.headers.get('X-Forwarded-For', request.remote_addr or '').split(',')[0].strip(),
|
||||||
|
'complete': False,
|
||||||
|
'sha256': None,
|
||||||
|
})
|
||||||
|
return jsonify(ok=True, upload_id=upload_id, chunk_size=chunk_size,
|
||||||
|
total_chunks=total, expires_in=TTL_SECONDS)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/api/upload/chunk', methods=['POST'])
|
||||||
|
def upload_chunk():
|
||||||
|
upload_id = (request.args.get('upload_id') or '').strip()
|
||||||
|
try:
|
||||||
|
index = int(request.args.get('index'))
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return jsonify(ok=False, message='index 必须是整数'), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
meta = _read_meta(upload_id)
|
||||||
|
except ValueError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 400
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 404
|
||||||
|
|
||||||
|
if meta.get('complete'):
|
||||||
|
return jsonify(ok=False, message='该上传已完成,请勿重复分片'), 409
|
||||||
|
if index < 0 or index >= meta['total']:
|
||||||
|
return jsonify(ok=False, message=f'index 越界(0..{meta["total"] - 1})'), 400
|
||||||
|
|
||||||
|
# 单片体积上限:最后一片可能不满
|
||||||
|
expected = min(meta['chunk_size'], meta['size'] - index * meta['chunk_size'])
|
||||||
|
data = request.get_data(cache=False)
|
||||||
|
if len(data) > expected:
|
||||||
|
return jsonify(ok=False, message=f'分片过大({len(data)} > {expected})'), 400
|
||||||
|
if len(data) == 0:
|
||||||
|
return jsonify(ok=False, message='分片为空'), 400
|
||||||
|
|
||||||
|
path = os.path.join(_upload_dir(upload_id), f'part_{index}')
|
||||||
|
tmp = path + '.tmp'
|
||||||
|
with open(tmp, 'wb') as f:
|
||||||
|
f.write(data)
|
||||||
|
f.flush()
|
||||||
|
os.fsync(f.fileno())
|
||||||
|
os.replace(tmp, path) # 幂等:同一片重传直接覆盖
|
||||||
|
|
||||||
|
received = _received_indexes(upload_id, meta['total'])
|
||||||
|
return jsonify(ok=True, index=index, received=len(received),
|
||||||
|
total_received=sum(os.path.getsize(os.path.join(_upload_dir(upload_id), f'part_{i}'))
|
||||||
|
for i in received),
|
||||||
|
complete=len(received) == meta['total'])
|
||||||
|
|
||||||
|
|
||||||
|
def _received_indexes(upload_id: str, total: int) -> list:
|
||||||
|
d = _upload_dir(upload_id)
|
||||||
|
out = []
|
||||||
|
for i in range(total):
|
||||||
|
if os.path.isfile(os.path.join(d, f'part_{i}')):
|
||||||
|
out.append(i)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/api/upload/status', methods=['GET'])
|
||||||
|
def upload_status():
|
||||||
|
upload_id = (request.args.get('upload_id') or '').strip()
|
||||||
|
try:
|
||||||
|
meta = _read_meta(upload_id)
|
||||||
|
except ValueError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 400
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 404
|
||||||
|
|
||||||
|
received = _received_indexes(upload_id, meta['total'])
|
||||||
|
missing = [i for i in range(meta['total']) if i not in received]
|
||||||
|
return jsonify(ok=True, upload_id=upload_id, size=meta['size'],
|
||||||
|
chunk_size=meta['chunk_size'], total_chunks=meta['total'],
|
||||||
|
received=received, missing=missing,
|
||||||
|
complete=meta.get('complete', False) or not missing)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route('/api/upload/complete', methods=['POST'])
|
||||||
|
def upload_complete():
|
||||||
|
body = request.get_json(silent=True) or {}
|
||||||
|
upload_id = (body.get('upload_id') or '').strip()
|
||||||
|
try:
|
||||||
|
meta = _read_meta(upload_id)
|
||||||
|
except ValueError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 400
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
return jsonify(ok=False, message=str(e)), 404
|
||||||
|
|
||||||
|
if meta.get('complete'):
|
||||||
|
return jsonify(ok=True, upload_id=upload_id, size=meta['size'],
|
||||||
|
sha256=meta.get('sha256'), already=True)
|
||||||
|
|
||||||
|
received = _received_indexes(upload_id, meta['total'])
|
||||||
|
missing = [i for i in range(meta['total']) if i not in received]
|
||||||
|
if missing:
|
||||||
|
return jsonify(ok=False, message='还有分片未上传', missing=missing[:50],
|
||||||
|
missing_count=len(missing)), 409
|
||||||
|
|
||||||
|
d = _upload_dir(upload_id)
|
||||||
|
assembled = os.path.join(d, 'assembled.bin')
|
||||||
|
tmp = assembled + '.tmp'
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
written = 0
|
||||||
|
try:
|
||||||
|
with open(tmp, 'wb') as out:
|
||||||
|
for i in range(meta['total']):
|
||||||
|
with open(os.path.join(d, f'part_{i}'), 'rb') as part:
|
||||||
|
while True:
|
||||||
|
chunk = part.read(4 * 1024 * 1024)
|
||||||
|
if not chunk:
|
||||||
|
break
|
||||||
|
out.write(chunk)
|
||||||
|
digest.update(chunk)
|
||||||
|
written += len(chunk)
|
||||||
|
out.flush()
|
||||||
|
os.fsync(out.fileno())
|
||||||
|
except BaseException:
|
||||||
|
try:
|
||||||
|
os.remove(tmp)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
raise
|
||||||
|
|
||||||
|
if written != meta['size']:
|
||||||
|
os.remove(tmp)
|
||||||
|
return jsonify(ok=False,
|
||||||
|
message=f'合并后大小不符(实际 {written},声明 {meta["size"]})'), 400
|
||||||
|
|
||||||
|
os.replace(tmp, assembled)
|
||||||
|
for i in range(meta['total']): # 合并成功后清掉分片,省磁盘
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(d, f'part_{i}'))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
meta['complete'] = True
|
||||||
|
meta['sha256'] = digest.hexdigest()
|
||||||
|
meta['completed_at'] = int(time.time())
|
||||||
|
_write_meta(upload_id, meta)
|
||||||
|
return jsonify(ok=True, upload_id=upload_id, size=written, sha256=meta['sha256'])
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 供 /api/submit 使用
|
||||||
|
|
||||||
|
def consume_upload(upload_id: str, form_id: str, field_name: str):
|
||||||
|
"""校验并返回待挂载的 assembled 文件路径(不移动,由 attach_uploaded_file 负责)。"""
|
||||||
|
meta = _read_meta(upload_id)
|
||||||
|
if not meta.get('complete'):
|
||||||
|
raise ValueError('分片尚未合并完成')
|
||||||
|
if meta.get('form_id') != form_id:
|
||||||
|
raise ValueError('该上传不属于当前表单')
|
||||||
|
if meta.get('field') != field_name:
|
||||||
|
raise ValueError('该上传不属于当前字段')
|
||||||
|
path = os.path.join(_upload_dir(upload_id), 'assembled.bin')
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
raise ValueError('合并文件丢失,请重新上传')
|
||||||
|
return path, meta
|
||||||
|
|
||||||
|
|
||||||
|
def discard_upload(upload_id: str) -> None:
|
||||||
|
try:
|
||||||
|
shutil.rmtree(_upload_dir(upload_id), ignore_errors=True)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_stale_uploads() -> int:
|
||||||
|
"""清理超过 TTL 的分片会话(含未完成和已挂载但遗留的目录)。"""
|
||||||
|
if not os.path.isdir(CHUNKS_DIR):
|
||||||
|
return 0
|
||||||
|
now = time.time()
|
||||||
|
removed = 0
|
||||||
|
for name in os.listdir(CHUNKS_DIR):
|
||||||
|
path = os.path.join(CHUNKS_DIR, name)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
age = now - os.path.getmtime(path)
|
||||||
|
except OSError:
|
||||||
|
continue
|
||||||
|
if age > TTL_SECONDS:
|
||||||
|
shutil.rmtree(path, ignore_errors=True)
|
||||||
|
removed += 1
|
||||||
|
return removed
|
||||||
+47
-1
@@ -296,9 +296,55 @@ def submit_form():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 处理文件上传 - 存储为BLOB
|
# 处理文件上传 - 存储为BLOB
|
||||||
from database import save_file, save_file_stream
|
from database import save_file, save_file_stream, attach_uploaded_file
|
||||||
|
from routes.chunked import consume_upload, discard_upload
|
||||||
|
# 分片上传:客户端把文件切片传完并 complete 后,这里用 token 挂载,
|
||||||
|
# 不再走 multipart 重复上传一遍。
|
||||||
|
import json as _json_tokens
|
||||||
|
try:
|
||||||
|
file_tokens = _json_tokens.loads(request.form.get('fileTokens') or '{}')
|
||||||
|
if not isinstance(file_tokens, dict):
|
||||||
|
file_tokens = {}
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
file_tokens = {}
|
||||||
|
|
||||||
for field in form['fields']:
|
for field in form['fields']:
|
||||||
if field['type'] == 'file':
|
if field['type'] == 'file':
|
||||||
|
token = (file_tokens.get(field['name']) or '').strip()
|
||||||
|
if token:
|
||||||
|
try:
|
||||||
|
src_path, meta = consume_upload(token, form_id, field['name'])
|
||||||
|
except (ValueError, FileNotFoundError) as e:
|
||||||
|
return jsonify(success=False, message=f'分片上传无效:{e}'), 400
|
||||||
|
|
||||||
|
ext = (meta['filename'].rsplit('.', 1)[-1] if '.' in meta['filename'] else '').lower()
|
||||||
|
if anonymous_mode:
|
||||||
|
base_name = f"匿名_{full_id[5:9]}"
|
||||||
|
else:
|
||||||
|
base_name = f"{student_name}{full_id}"
|
||||||
|
if has_multiple_files:
|
||||||
|
filename = f"{base_name}_{field['name']}.{ext}"
|
||||||
|
else:
|
||||||
|
filename = f"{base_name}.{ext}"
|
||||||
|
|
||||||
|
file_id = attach_uploaded_file(
|
||||||
|
form_id=form_id,
|
||||||
|
src_path=src_path,
|
||||||
|
filename=filename,
|
||||||
|
original_name=meta['filename'],
|
||||||
|
mime_type=meta.get('mime_type') or 'application/octet-stream',
|
||||||
|
field_name=field['name'],
|
||||||
|
submission_id=submission_id,
|
||||||
|
)
|
||||||
|
new_file_ids.append(file_id)
|
||||||
|
uploaded_files.append(filename)
|
||||||
|
try:
|
||||||
|
insert_business_metric('files_uploaded', meta['size'])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
discard_upload(token) # 会话用完即删,避免残留
|
||||||
|
continue
|
||||||
|
|
||||||
file = request.files.get(field['name'])
|
file = request.files.get(field['name'])
|
||||||
if file and file.filename:
|
if file and file.filename:
|
||||||
ext = file.filename.rsplit('.', 1)[-1].lower()
|
ext = file.filename.rsplit('.', 1)[-1].lower()
|
||||||
|
|||||||
Vendored
+11
File diff suppressed because one or more lines are too long
Vendored
+83
File diff suppressed because one or more lines are too long
+2
-2
@@ -7,7 +7,7 @@
|
|||||||
<title>502 Bad Gateway</title>
|
<title>502 Bad Gateway</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS (CDN) -->
|
<!-- Tailwind CSS (CDN) -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP (CDN) -->
|
<!-- GSAP (CDN) -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
|
|
||||||
<!-- 鍐呰仈 CSS锛圕SS 鍙橀噺 + 涓撳睘鏍峰紡锛?-->
|
<!-- 鍐呰仈 CSS锛圕SS 鍙橀噺 + 涓撳睘鏍峰紡锛?-->
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>管理后台</title>
|
<title>管理后台</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -33,12 +33,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>新建表单</title>
|
<title>新建表单</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -37,16 +37,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/gsap-fallback.js"></script>
|
<script src="/static/js/gsap-fallback.js"></script>
|
||||||
<!-- SortableJS for drag and drop -->
|
<!-- SortableJS for drag and drop -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/form-experience.css">
|
<link rel="stylesheet" href="/static/css/form-experience.css" onerror="this.onerror=null;this.href='/static/css/form-experience.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
<script src="/static/js/form-components.js"></script>
|
<script src="/static/js/form-components.js"></script>
|
||||||
<script src="/static/js/webhook-settings.js"></script>
|
<script src="/static/js/webhook-settings.js"></script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>数据库管理</title>
|
<title>数据库管理</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -35,12 +35,12 @@
|
|||||||
<!-- ECharts for data visualization -->
|
<!-- ECharts for data visualization -->
|
||||||
<script src="/static/js/echart.js"></script>
|
<script src="/static/js/echart.js"></script>
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
+6
-6
@@ -7,7 +7,7 @@
|
|||||||
<title>编辑表单</title>
|
<title>编辑表单</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -37,16 +37,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/gsap-fallback.js"></script>
|
<script src="/static/js/gsap-fallback.js"></script>
|
||||||
<!-- SortableJS for drag and drop -->
|
<!-- SortableJS for drag and drop -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/form-experience.css">
|
<link rel="stylesheet" href="/static/css/form-experience.css" onerror="this.onerror=null;this.href='/static/css/form-experience.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
<script src="/static/js/form-components.js"></script>
|
<script src="/static/js/form-components.js"></script>
|
||||||
<script src="/static/js/webhook-settings.js"></script>
|
<script src="/static/js/webhook-settings.js"></script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>出错了 - 表单管理系统</title>
|
<title>出错了 - 表单管理系统</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -54,12 +54,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP -->
|
<!-- GSAP -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title id="pageTitle">表单提交</title>
|
<title id="pageTitle">表单提交</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -32,15 +32,15 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<!-- GSAP for premium animations -->
|
<!-- GSAP for premium animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/gsap-fallback.js"></script>
|
<script src="/static/js/gsap-fallback.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<script src="/static/js/morph-card.js?v=8"></script>
|
<script src="/static/js/morph-card.js?v=8"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/form-experience.css">
|
<link rel="stylesheet" href="/static/css/form-experience.css" onerror="this.onerror=null;this.href='/static/css/form-experience.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
<script src="/static/js/markdown.js"></script>
|
<script src="/static/js/markdown.js"></script>
|
||||||
<script src="/static/js/form-link-preset.js"></script>
|
<script src="/static/js/form-link-preset.js"></script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>登录 - 表单管理系统</title>
|
<title>登录 - 表单管理系统</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -23,18 +23,18 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP -->
|
<!-- GSAP -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
|
|
||||||
<!-- Particles -->
|
<!-- Particles -->
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
|
|
||||||
<!-- Toast -->
|
<!-- Toast -->
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
|
|
||||||
<!-- Basic & Common Styles -->
|
<!-- Basic & Common Styles -->
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<!-- Common JS (theme init, utils) -->
|
<!-- Common JS (theme init, utils) -->
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>系统监控</title>
|
<title>系统监控</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -28,12 +28,12 @@
|
|||||||
<!-- ECharts -->
|
<!-- ECharts -->
|
||||||
<script src="/static/js/echart.js"></script>
|
<script src="/static/js/echart.js"></script>
|
||||||
<!-- GSAP -->
|
<!-- GSAP -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/toast.css">
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/vendor/charwrapper.min.js"></script>
|
<script src="/static/vendor/charwrapper.min.js"></script>
|
||||||
<script src="https://unpkg.com/split-type@0.3.4/umd/index.min.js"></script>
|
<script src="https://unpkg.com/split-type@0.3.4/umd/index.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<title>名单预设管理 - 表单管理系统</title>
|
<title>名单预设管理 - 表单管理系统</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP -->
|
<!-- GSAP -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
|
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
+17
-4
@@ -11,7 +11,7 @@
|
|||||||
<title>表单状态</title>
|
<title>表单状态</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -39,11 +39,24 @@
|
|||||||
<!-- ECharts for data visualization -->
|
<!-- ECharts for data visualization -->
|
||||||
<script src="/static/js/echart.js"></script>
|
<script src="/static/js/echart.js"></script>
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<style id="critical-fallback">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
/* 弱网兜底:即使外部 CSS/JS 全部失败,页面仍是可读的深色卡片布局,
|
||||||
|
不会退化成无样式的一长串文字。Tailwind 加载成功后会接管细节样式。 */
|
||||||
|
html, body { background: #0b1220; color: #e5e7eb; margin: 0; }
|
||||||
|
body { font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
|
||||||
|
body > * { max-width: 1100px; margin: 0 auto; }
|
||||||
|
h1, h2, h3 { line-height: 1.3; }
|
||||||
|
table { border-collapse: collapse; width: 100%; }
|
||||||
|
th, td { padding: 8px 10px; border-bottom: 1px solid #1f2a3a; text-align: left; font-size: 14px; }
|
||||||
|
a { color: #7dd3fc; }
|
||||||
|
button { font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid #334155;
|
||||||
|
background: #16233a; color: #e5e7eb; cursor: pointer; }
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<title>用户管理 - 表单管理系统</title>
|
<title>用户管理 - 表单管理系统</title>
|
||||||
|
|
||||||
<!-- Tailwind CSS -->
|
<!-- Tailwind CSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = {
|
||||||
darkMode: 'class',
|
darkMode: 'class',
|
||||||
@@ -36,11 +36,11 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- GSAP for animations -->
|
<!-- GSAP for animations -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
||||||
<script src="/static/js/particles.js"></script>
|
<script src="/static/js/particles.js"></script>
|
||||||
<script src="/static/js/toast.js"></script>
|
<script src="/static/js/toast.js"></script>
|
||||||
<link rel="stylesheet" href="/static/css/basic.css">
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
||||||
<link rel="stylesheet" href="/static/css/common.css">
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
||||||
<script src="/static/js/common.js"></script>
|
<script src="/static/js/common.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in New Issue
Block a user