mirror of
https://github.com/Zippland/Snap-Solver.git
synced 2026-01-19 09:41:15 +08:00
safari debug
This commit is contained in:
11
app.py
11
app.py
@@ -17,7 +17,16 @@ from datetime import datetime
|
||||
import sys
|
||||
|
||||
app = Flask(__name__)
|
||||
socketio = SocketIO(app, cors_allowed_origins="*", ping_timeout=30, ping_interval=5, max_http_buffer_size=50 * 1024 * 1024)
|
||||
socketio = SocketIO(
|
||||
app,
|
||||
cors_allowed_origins="*",
|
||||
ping_timeout=30,
|
||||
ping_interval=5,
|
||||
max_http_buffer_size=50 * 1024 * 1024,
|
||||
async_mode='threading', # 使用threading模式提高兼容性
|
||||
engineio_logger=True, # 启用引擎日志,便于调试
|
||||
logger=True # 启用Socket.IO日志
|
||||
)
|
||||
|
||||
# 添加配置文件路径
|
||||
CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config')
|
||||
|
||||
@@ -117,18 +117,30 @@ class SnapSolver {
|
||||
|
||||
initializeConnection() {
|
||||
try {
|
||||
this.socket = io(window.location.origin, {
|
||||
// 添加日志以便调试
|
||||
console.log('尝试连接WebSocket服务器...');
|
||||
|
||||
// 确保在Safari上使用完整的URL
|
||||
const socketUrl = window.location.protocol === 'https:'
|
||||
? `${window.location.origin}`
|
||||
: window.location.origin;
|
||||
|
||||
console.log('WebSocket连接URL:', socketUrl);
|
||||
|
||||
this.socket = io(socketUrl, {
|
||||
reconnection: true,
|
||||
reconnectionAttempts: 5,
|
||||
reconnectionDelay: 1000,
|
||||
reconnectionDelayMax: 5000,
|
||||
timeout: 20000,
|
||||
autoConnect: true
|
||||
autoConnect: true,
|
||||
transports: ['websocket', 'polling'] // 明确指定传输方式,增加兼容性
|
||||
});
|
||||
|
||||
this.socket.on('connect', () => {
|
||||
console.log('Connected to server');
|
||||
this.updateConnectionStatus('已连接', true);
|
||||
this.captureBtn.disabled = false;
|
||||
});
|
||||
|
||||
this.socket.on('disconnect', () => {
|
||||
|
||||
@@ -3,11 +3,22 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<!-- Safari兼容性设置 -->
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<title>Snap Solver</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
|
||||
<script>
|
||||
// 帮助Safari调试
|
||||
window.onerror = function(message, source, lineno, colno, error) {
|
||||
console.error("Error caught: ", message, "at", source, ":", lineno, ":", colno, error);
|
||||
return false;
|
||||
};
|
||||
</script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.13/cropper.min.js"></script>
|
||||
</head>
|
||||
<body class="app-container">
|
||||
@@ -296,13 +307,17 @@
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 初始化更新检查
|
||||
const updateInfo = {{ update_info|tojson|safe }};
|
||||
if (updateInfo && updateInfo.has_update) {
|
||||
showUpdateNotice(updateInfo);
|
||||
try {
|
||||
const updateInfo = JSON.parse('{{ update_info|tojson|safe }}');
|
||||
if (updateInfo && updateInfo.has_update) {
|
||||
showUpdateNotice(updateInfo);
|
||||
}
|
||||
|
||||
// 24小时后再次检查更新
|
||||
setTimeout(checkForUpdates, 24 * 60 * 60 * 1000);
|
||||
} catch (error) {
|
||||
console.error('更新检查初始化失败:', error);
|
||||
}
|
||||
|
||||
// 24小时后再次检查更新
|
||||
setTimeout(checkForUpdates, 24 * 60 * 60 * 1000);
|
||||
});
|
||||
|
||||
function showUpdateNotice(updateInfo) {
|
||||
@@ -332,8 +347,8 @@
|
||||
|
||||
function checkForUpdates() {
|
||||
fetch('/api/check-update')
|
||||
.then(response => response.json())
|
||||
.then(updateInfo => {
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(updateInfo) {
|
||||
const dismissedVersion = localStorage.getItem('dismissedUpdate');
|
||||
|
||||
// 只有当有更新且用户没有关闭过此版本的通知时才显示
|
||||
@@ -341,7 +356,7 @@
|
||||
showUpdateNotice(updateInfo);
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('检查更新失败:', error));
|
||||
.catch(function(error) { console.error('检查更新失败:', error); });
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user