fix: 修正 JavaScript 字符串转义问题(使用双反斜杠)
问题分析: - Flask render_template_string 会解析字符串中的转义序列 - Python 字符串 '\n' 在渲染后变成真实的换行符 - 导致 JavaScript 语法错误 修复方案: - 使用双反斜杠 '\\n' - 渲染后得到正确的 JavaScript 字符串 '\n' - 避免换行符直接出现在 JavaScript 代码中
This commit is contained in:
BIN
__pycache__/app.cpython-312.pyc
Normal file
BIN
__pycache__/app.cpython-312.pyc
Normal file
Binary file not shown.
2
app.py
2
app.py
@@ -2522,7 +2522,7 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
|
||||
if (!desktopNotifyEnabled || Notification.permission !== 'granted') return;
|
||||
|
||||
const notification = new Notification('⚠️ 系统资源告警', {
|
||||
body: warnings.join('\n'),
|
||||
body: warnings.join('\\n'),
|
||||
icon: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">📊</text></svg>',
|
||||
tag: 'system-alert',
|
||||
requireInteraction: false
|
||||
|
||||
12
logs/app.log
12
logs/app.log
@@ -1,8 +1,8 @@
|
||||
[2026-06-01 11:40:58] ==================================================
|
||||
[2026-06-01 11:40:58] 项目服务管理面板 v2.0.0 启动
|
||||
[2026-06-01 11:40:58] 访问地址: http://localhost:16022
|
||||
[2026-06-01 11:40:58] 进程PID: 774683
|
||||
[2026-06-01 11:40:58] ==================================================
|
||||
[2026-06-01 11:46:32] ==================================================
|
||||
[2026-06-01 11:46:32] 项目服务管理面板 v2.0.0 启动
|
||||
[2026-06-01 11:46:32] 访问地址: http://localhost:16022
|
||||
[2026-06-01 11:46:32] 进程PID: 775569
|
||||
[2026-06-01 11:46:32] ==================================================
|
||||
* Serving Flask app 'app'
|
||||
* Debug mode: off
|
||||
[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||
@@ -10,4 +10,4 @@
|
||||
* Running on http://127.0.0.1:16022
|
||||
* Running on http://192.168.0.101:16022
|
||||
[33mPress CTRL+C to quit[0m
|
||||
127.0.0.1 - - [01/Jun/2026 11:41:03] "GET / HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [01/Jun/2026 11:46:50] "GET / HTTP/1.1" 200 -
|
||||
|
||||
Reference in New Issue
Block a user