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重新连接成功');