Merge branch 'new-race-mode' into test

This commit is contained in:
2026-05-14 17:58:17 +08:00

View File

@@ -19,8 +19,12 @@ const props = defineProps({
}); });
const loading = ref(false); const loading = ref(false);
/** 统一获取当前环境 token用于守卫无有效 token 时不发起接口请求 */
const getToken = () =>
uni.getStorageSync(`${uni.getAccountInfoSync().miniProgram.envVersion}_token`);
onShow(async () => { onShow(async () => {
if (user.value.id) { if (user.value.id && getToken()) {
setTimeout(async () => { setTimeout(async () => {
const state = await getUserGameState(); const state = await getUserGameState();
updateGame(state.gaming, state.roomId); updateGame(state.gaming, state.roomId);
@@ -33,7 +37,8 @@ watch(
async (value) => { async (value) => {
if (!value.id) { if (!value.id) {
updateGame(false, ""); updateGame(false, "");
} else { } else if (getToken()) {
// 有有效 token 时才查询在局状态,避免 token 失效时反复发起无效请求
const state = await getUserGameState(); const state = await getUserGameState();
updateGame(state.gaming, state.roomId); updateGame(state.gaming, state.roomId);
} }