From e5e38649644ab1c3d6f817897ba764f2ccbec02e Mon Sep 17 00:00:00 2001 From: Litrix2 Date: Sat, 1 Mar 2025 11:43:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=AC=AC2=E7=89=882048=E4=B8=BB=E8=A6=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + .eslintrc.cjs | 5 +- env.d.ts | 1 + src/components/game2048/Game2048.vue | 4 +- src/components/game2048/Game2048V2.vue | 521 ++++++++++++------------- src/env.ts | 1 + src/utils/index.ts | 2 +- src/utils/map.ts | 5 + src/utils/table-view.ts | 83 ++++ 9 files changed, 343 insertions(+), 280 deletions(-) create mode 100644 src/utils/map.ts create mode 100644 src/utils/table-view.ts diff --git a/.env b/.env index f1d830a..3e950b1 100644 --- a/.env +++ b/.env @@ -2,3 +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 diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6028908..5ff3728 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -9,12 +9,11 @@ module.exports = { '@vue/eslint-config-typescript', '@vue/eslint-config-prettier/skip-formatting', ], - parserOptions: { - ecmaVersion: 'latest', - }, + parserOptions: { ecmaVersion: 'latest' }, rules: { 'vue/no-unused-vars': 'warn', 'vue/multi-word-component-names': 'off', 'vue/valid-v-for': 'off', + 'no-redeclare': 'off', }, }; diff --git a/env.d.ts b/env.d.ts index 08aae2f..e63b049 100644 --- a/env.d.ts +++ b/env.d.ts @@ -5,4 +5,5 @@ type BooleanString = 'true' | 'false'; interface ImportMetaEnv { readonly VITE_REQUEST_BASE_URL: string; readonly VITE_WEBSOCKET_BASE_URL: string; + readonly VITE_GAME_2048_DEBUG: BooleanString; } diff --git a/src/components/game2048/Game2048.vue b/src/components/game2048/Game2048.vue index cd7463a..f3ca690 100644 --- a/src/components/game2048/Game2048.vue +++ b/src/components/game2048/Game2048.vue @@ -767,10 +767,10 @@ onMounted(async () => { onUnmounted(() => { locked.value = true; isUnmounted = true; - for (const future of chainIterables([ + for (const future of chainIterables( tileAddFutureMap.values(), tileTransitionFutureMap.values(), - ])) { + )) { future.resolve(); } }); diff --git a/src/components/game2048/Game2048V2.vue b/src/components/game2048/Game2048V2.vue index 0bcfd70..6adedd3 100644 --- a/src/components/game2048/Game2048V2.vue +++ b/src/components/game2048/Game2048V2.vue @@ -4,22 +4,21 @@
{{ tile.renderState.number }} +
#{{ tile.id }}
@@ -50,8 +49,183 @@ .bg-tile { background-color: rgb(205, 193, 180); } +.id { + position: absolute; + font-size: 15px; + right: 10px; + bottom: 10px; + line-height: 1; +} - -