From 974f20e035c1299aaed4dd0750302f188ff0668e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=87=8C=E6=B1=90?= Date: Tue, 6 May 2025 19:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86https=E4=B8=8Bws?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- static/js/dashboard.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.env b/.env index 950108f..f1c83c4 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ S3_ENDPOINT=http://hk.meowdream.cn:5246 S3_ACCESS_KEY=s7R9zBdnQcw6FtR8Wr0J -S3_SECRET_KEY=FoobOUNWN7fDL7Zh0fkXP3d0plP +S3_SECRET_KEY=FoobOUNWN7fDL7Zh0fkXP3d0plP/GOvzdv84baw3 S3_BUCKET=image MONGO_URI=mongodb://hk.meowdream.cn:27017 MONGO_DB=catism_image \ No newline at end of file diff --git a/static/js/dashboard.js b/static/js/dashboard.js index 0eab2e1..1dc4569 100644 --- a/static/js/dashboard.js +++ b/static/js/dashboard.js @@ -164,7 +164,8 @@ function fetchUserTheme() { function initWebSocket() { const userKey = localStorage.getItem('userKey'); - socket = new WebSocket(`ws://${window.location.host}/ws/user-info?key=${userKey}`); + const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'; + socket = new WebSocket(`${protocol}://${window.location.host}/ws/user-info?key=${userKey}`); // 初始化时获取并应用主题 fetchUserTheme().then(theme => { @@ -208,7 +209,8 @@ function reconnectWebSocket() { setTimeout(() => { const userKey = localStorage.getItem('userKey'); - socket = new WebSocket(`ws://${window.location.host}/ws/user-info?key=${userKey}`); + const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'; + socket = new WebSocket(`${protocol}://${window.location.host}/ws/user-info?key=${userKey}`); socket.onopen = function() { reconnectAttempts = 0; console.log('WebSocket重新连接成功');