From fbdb232502c96ef5890e69a60724349b2837e291 Mon Sep 17 00:00:00 2001
From: 24024 <240241002@qq.com>
Date: Fri, 13 Mar 2026 22:28:20 +0800
Subject: [PATCH] =?UTF-8?q?```=20feat(app):=20=E6=B7=BB=E5=8A=A0=E7=A7=BB?=
=?UTF-8?q?=E5=8A=A8=E7=AB=AF=E6=A3=80=E6=B5=8B=E5=92=8C=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 添加request和redirect导入以支持移动端检测
- 实现用户代理检测逻辑,自动重定向移动设备到/mobile页面
- 优化mobile.html模板中的UI布局和标签文本
- 移动端特定功能:调整尺寸选择器显示逻辑,仅在特定模型时显示
- 添加fillSelect工具函数统一处理下拉选项填充
- 集成用户收藏提示词功能,合并系统预设和用户自定义模板
- 改进错误处理机制,在配置加载和历史记录加载中添加try-catch
- 优化历史记录数据显示,适配新的数据结构字段
- 增强成本预览功能,实时计算积分消耗并在UI上展示
```
---
app.py | 7 +-
templates/mobile.html | 222 ++++++++++++++++++++++++++----------------
2 files changed, 145 insertions(+), 84 deletions(-)
diff --git a/app.py b/app.py
index 4440391..f0cd589 100644
--- a/app.py
+++ b/app.py
@@ -1,4 +1,4 @@
-from flask import Flask, render_template, jsonify, Response, stream_with_context
+from flask import Flask, render_template, jsonify, Response, stream_with_context, request, redirect
from config import Config
from extensions import db, redis_client, migrate, s3_client
from blueprints.auth import auth_bp
@@ -142,6 +142,11 @@ def create_app():
@app.route('/')
def index():
+ # 检测是否为移动端访问
+ user_agent = request.headers.get('User-Agent', '').lower()
+ mobile_keywords = ['mobile', 'android', 'iphone', 'ipad', 'ipod', 'windows phone', 'blackberry']
+ if any(keyword in user_agent for keyword in mobile_keywords):
+ return redirect('/mobile')
return render_template('index.html')
@app.route('/ocr')
diff --git a/templates/mobile.html b/templates/mobile.html
index 1f7a060..071a6a4 100644
--- a/templates/mobile.html
+++ b/templates/mobile.html
@@ -189,7 +189,7 @@
-
+
-
-
-
-
+
+
+
+
+
+