diff --git a/.env b/.env index 3e950b1..fcab86e 100644 --- a/.env +++ b/.env @@ -2,4 +2,4 @@ VITE_REQUEST_BASE_URL=https://wzpmc.cn:18080 # VITE_REQUEST_BASE_URL=http://172.16.114.84:58082 VITE_WEBSOCKET_BASE_URL=wss://wzpmc.cn:18080 # VITE_WEBSOCKET_BASE_URL=ws://172.16.114.84:58082 -VITE_GAME_2048_DEBUG=true +VITE_GAME_2048_DEBUG=false diff --git a/src/components/game2048/Game2048.vue b/src/components/game2048/Game2048.vue index 37bab42..b7f39c5 100644 --- a/src/components/game2048/Game2048.vue +++ b/src/components/game2048/Game2048.vue @@ -295,8 +295,8 @@ let enteredBackgroundTileCount = 0; */ let maxId = 0; const tileGrid = reactive([]); -const tileAddFutureMap = new FutureMap(); -const tileTransitionFutureMap = new FutureMap(); +const tileAddFutureMap = new FutureMap(); +const tileTransitionFutureMap = new FutureMap(); const tileBackgroundColorMapping: Record = { 2: 'rgb(238, 228, 218)', 4: 'rgb(237, 224, 200)', diff --git a/src/components/game2048/Game2048Score.vue b/src/components/game2048/Game2048Score.vue index 068375a..bc4f695 100644 --- a/src/components/game2048/Game2048Score.vue +++ b/src/components/game2048/Game2048Score.vue @@ -4,7 +4,7 @@ 最高数字
-
{{ displayedScore }}
+
{{ score }}
@@ -43,13 +43,15 @@ import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'; const props = defineProps<{ score: number; }>(); -const displayedScore = ref(props.score); +const score = ref(props.score); const scoreDiv = ref(); const scoreQueue = new AsyncQueue(); let isUnmounted = false; watch( () => props.score, (score) => { + console.log(score); + scoreQueue.push(score); }, ); @@ -57,13 +59,13 @@ onMounted(async () => { let continuouslyRolling = false; while (!isUnmounted) { try { - const score = await scoreQueue.shift(); + const s = await scoreQueue.shift(); await scoreDiv.value?.animate([{ transform: 'none' }, { transform: 'translateY(-100%)' }], { easing: continuouslyRolling ? 'linear' : 'ease-in', fill: 'forwards', duration: 100 / (scoreQueue.size + 1 + Number(continuouslyRolling)), }).finished; - displayedScore.value = score; + score.value = s; await nextTick(); continuouslyRolling = scoreQueue.size > 0; await scoreDiv.value?.animate([{ transform: 'translateY(100%)' }, { transform: 'none' }], { diff --git a/src/components/game2048/Game2048ScoreDigit.vue b/src/components/game2048/Game2048ScoreDigit.vue new file mode 100644 index 0000000..4bac8bc --- /dev/null +++ b/src/components/game2048/Game2048ScoreDigit.vue @@ -0,0 +1,72 @@ + + + + diff --git a/src/components/game2048/Game2048ScoreV2.vue b/src/components/game2048/Game2048ScoreV2.vue new file mode 100644 index 0000000..902b3d8 --- /dev/null +++ b/src/components/game2048/Game2048ScoreV2.vue @@ -0,0 +1,135 @@ + + + + + diff --git a/src/components/game2048/Game2048V2.vue b/src/components/game2048/Game2048V2.vue index d6baec1..305a74f 100644 --- a/src/components/game2048/Game2048V2.vue +++ b/src/components/game2048/Game2048V2.vue @@ -57,6 +57,25 @@ line-height: 1; } +