修复WebSocket身份认证问题

- 添加WebSocketAuthInterceptor处理token认证
- 修改WebSocket连接逻辑,支持token传递
- 统一用户身份识别,确保登录用户使用USER类型
- 修复前端环境变量配置,统一WebSocket URL
- 添加Token测试页面用于验证功能
- 更新聊天消息处理逻辑,正确识别用户身份

解决了登录用户发送消息时同时保存GUEST和USER两种类型数据的问题
This commit is contained in:
2025-07-24 17:51:38 +08:00
parent 6560e66959
commit 847f5126cf
30 changed files with 1447 additions and 216 deletions
@@ -2,7 +2,7 @@
# Local Development Environment Configuration
server:
port: 8080
port: 19089
spring:
# 数据库配置 - 本地MySQL
@@ -2,7 +2,7 @@
# Production Environment Configuration
server:
port: 8080
port: 19089
spring:
# 数据库配置 - 生产MySQL
@@ -0,0 +1,66 @@
# 测试环境配置
# Test Environment Configuration
server:
port: 19089
spring:
# 数据库配置 - 测试MySQL
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://47.111.10.27:3306/emotion?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: EmotionMuseum2025*#
hikari:
minimum-idle: 5
maximum-pool-size: 30
auto-commit: true
idle-timeout: 300000
pool-name: EmotionHikariCP-Test
max-lifetime: 1800000
connection-timeout: 30000
validation-timeout: 3000
leak-detection-threshold: 60000
# Redis配置 - 测试Redis
redis:
host: localhost
port: 6379
timeout: 3000ms
database: 1
lettuce:
pool:
max-active: 10
max-wait: -1ms
max-idle: 8
min-idle: 2
time-between-eviction-runs: 30s
# 日志配置 - 测试环境
logging:
level:
com.emotion: debug
org.springframework.security: info
org.springframework.web: info
org.mybatis: info
root: info
file:
name: /data/logs/emotion-museum/emotion-single-test.log
max-size: 100MB
max-history: 30
# 测试环境特定配置
emotion:
# 文件上传路径 - 测试环境
upload:
path: /data/uploads/emotion-museum-test
# 测试模式配置
test:
mock-enabled: false
debug-mode: true
performance-monitoring: true
# 雪花算法配置
snowflake:
machine-id: 2
@@ -1,5 +1,5 @@
server:
port: 8080
port: 19089
servlet:
context-path: /api