feat(game): 完善成都麻将游戏页面功能
- 添加WebSocket URL构建逻辑和认证令牌刷新功能 - 实现游戏状态显示包括阶段、网络状态、时钟等信息 - 添加游戏桌面背景图片和玩家座位装饰组件 - 重构CSS样式为网格布局提升响应式体验 - 配置环境变量支持API和WebSocket代理目标设置 - 优化WebSocket连接管理增加错误处理机制 - 添加游戏桌墙体和中心计数器等UI元素 - 修复多处字符串国际化和路径处理问题
This commit is contained in:
@@ -39,6 +39,15 @@ function buildUrl(path: string): string {
|
||||
return normalizedPath
|
||||
}
|
||||
|
||||
if (API_BASE_URL.startsWith('/')) {
|
||||
const basePath = API_BASE_URL.startsWith('/') ? API_BASE_URL : `/${API_BASE_URL}`
|
||||
if (normalizedPath === basePath || normalizedPath.startsWith(`${basePath}/`)) {
|
||||
return normalizedPath
|
||||
}
|
||||
|
||||
return `${basePath}${normalizedPath}`
|
||||
}
|
||||
|
||||
// Avoid duplicated API prefix, e.g. base: /api/v1 + path: /api/v1/auth/login
|
||||
try {
|
||||
const baseUrl = new URL(API_BASE_URL)
|
||||
|
||||
@@ -47,6 +47,15 @@ function buildUrl(path: string): string {
|
||||
return normalizedPath
|
||||
}
|
||||
|
||||
if (API_BASE_URL.startsWith('/')) {
|
||||
const basePath = API_BASE_URL.startsWith('/') ? API_BASE_URL : `/${API_BASE_URL}`
|
||||
if (normalizedPath === basePath || normalizedPath.startsWith(`${basePath}/`)) {
|
||||
return normalizedPath
|
||||
}
|
||||
|
||||
return `${basePath}${normalizedPath}`
|
||||
}
|
||||
|
||||
try {
|
||||
const baseUrl = new URL(API_BASE_URL)
|
||||
const basePath = baseUrl.pathname.replace(/\/$/, '')
|
||||
|
||||
Reference in New Issue
Block a user