完善多店铺开启多窗口、外观进度条等
This commit is contained in:
@@ -168,6 +168,7 @@ def serve_assets(filename):
|
||||
|
||||
|
||||
@main_bp.route('/new_web_source/<path:filename>')
|
||||
@login_required
|
||||
def serve_new_web_source(filename):
|
||||
"""提供 static 目录及子目录下的静态文件访问。"""
|
||||
filepath = os.path.normpath(os.path.join("new_web_source", filename))
|
||||
@@ -175,6 +176,21 @@ def serve_new_web_source(filename):
|
||||
file_abs = os.path.abspath(filepath)
|
||||
if not file_abs.startswith(static_abs) or not os.path.isfile(file_abs):
|
||||
return '', 404
|
||||
if filename.lower().endswith('.html'):
|
||||
with open(file_abs, 'rb') as f:
|
||||
content = f.read().decode('utf-8', errors='replace')
|
||||
raw_uid = session.get('user_id')
|
||||
uid_value = str(int(raw_uid)) if str(raw_uid or '').isdigit() else '""'
|
||||
uid_script = (
|
||||
"\n<script>"
|
||||
f"window.localStorage.setItem('uid', {uid_value});"
|
||||
"</script>\n"
|
||||
)
|
||||
if '</head>' in content:
|
||||
content = content.replace('</head>', uid_script + '</head>', 1)
|
||||
else:
|
||||
content = uid_script + content
|
||||
return render_template_string(content)
|
||||
return send_file(file_abs, as_attachment=False)
|
||||
|
||||
@main_bp.route('/logo.jpg', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user