feat: 刷新 Access Token(带并发锁)

This commit is contained in:
2026-06-30 09:03:26 +08:00
parent dd97f9cb70
commit b85c3cbd60
4 changed files with 19 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
import { fetchEventSource } from '@microsoft/fetch-event-source' import { fetchEventSource } from '@microsoft/fetch-event-source'
import { ElMessage } from 'element-plus'
/** /**
* SSE 连接客户端 * SSE 连接客户端
@@ -89,6 +90,7 @@ export class SseClient {
return return
} }
this.callbacks.onMessage(message.event, message.data) this.callbacks.onMessage(message.event, message.data)
ElMessage.success(message.event)
}, },
onclose: () => { onclose: () => {

View File

@@ -1,6 +1,9 @@
import mitt from 'mitt' import mitt from 'mitt'
import type { RoomItem } from '@/api/modules/game' import type { RoomItem } from '@/api/modules/game'
/**
* SSE 事件定义
*/
export type SseEvents = { export type SseEvents = {
connected: undefined connected: undefined
error: { message: string; retryCount: number } error: { message: string; retryCount: number }
@@ -10,6 +13,8 @@ export type SseEvents = {
kicked: { roomId: string } kicked: { roomId: string }
game_started: { roomId: string } game_started: { roomId: string }
balance_chg: { balance: number; delta: number } balance_chg: { balance: number; delta: number }
/** 自定义事件类型,用于测试或任意消息推送,数据格式由调用方决定 */
custom: unknown
} }
/** /**

View File

@@ -72,7 +72,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import type { RoomItem, RoomPlayer, RoomStatus } from '@/api/modules/game' import type { RoomItem } from '@/api/modules/game'
import { getAvatarUrl } from '@/utils' import { getAvatarUrl } from '@/utils'
const props = defineProps<{ const props = defineProps<{
@@ -109,7 +109,7 @@ const chairPositions = computed(() => {
positions.push({ positions.push({
left: `${left}px`, left: `${left}px`,
top: `${top}px`, top: `${top}px`
}) })
} }
@@ -164,9 +164,7 @@ function isHost(idx: number): boolean {
function chairTooltip(idx: number): string { function chairTooltip(idx: number): string {
const player = props.room.players[idx] const player = props.room.players[idx]
if (!player) return '' if (!player) return ''
return player.nickname === props.room.creatorName return player.nickname === props.room.creatorName ? `${player.nickname}(房主)` : player.nickname
? `${player.nickname}(房主)`
: player.nickname
} }
</script> </script>
@@ -350,12 +348,7 @@ function chairTooltip(idx: number): string {
height: 76px; height: 76px;
border-radius: 50%; border-radius: 50%;
/* 木质桌面 */ /* 木质桌面 */
background: linear-gradient( background: linear-gradient(145deg, #e8d5b0 0%, #d4a574 40%, #c49060 100%);
145deg,
#e8d5b0 0%,
#d4a574 40%,
#c49060 100%
);
box-shadow: box-shadow:
0 3px 12px rgba(0, 0, 0, 0.15), 0 3px 12px rgba(0, 0, 0, 0.15),
inset 0 1px 2px rgba(255, 255, 255, 0.4); inset 0 1px 2px rgba(255, 255, 255, 0.4);

View File

@@ -135,7 +135,14 @@
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { Setting, EditPen, ArrowRight, Check, DocumentCopy, SwitchButton } from '@element-plus/icons-vue' import {
Setting,
EditPen,
ArrowRight,
Check,
DocumentCopy,
SwitchButton
} from '@element-plus/icons-vue'
import { useAccountStore } from '@/stores' import { useAccountStore } from '@/stores'
import { UserStatus, type UserStatusType } from '@/api/modules/user' import { UserStatus, type UserStatusType } from '@/api/modules/user'
import { getAvatarUrl } from '@/utils' import { getAvatarUrl } from '@/utils'