Skip to content

Commit 475be08

Browse files
committed
update start menu
1 parent e389595 commit 475be08

9 files changed

Lines changed: 203 additions & 46 deletions

File tree

public/texture/logo.png

5.37 KB
Loading

src/App.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<section class="game-container" :class="{ 'global-dragging': isMouseDown && dragStartSquare }"
33
:style="{ '--piece-scale': pieceScale }">
44

5-
<GameSetup v-if="showSetup" @start="handleGameSetupStart" />
5+
<GameSetup v-if="showSetup" @start="handleGameSetupStart" @remote="handleRemoteGame" />
66

77
<!-- 棋盘主面板 -->
88
<BoardPanel :board="board" :current-turn="currentTurn" :selected-square="selectedSquare"
@@ -40,7 +40,6 @@
4040
<!-- 设置弹窗 Modal -->
4141
<SettingsModal :visible="showSettingsModal" :is-sound-enabled="isSoundEnabled"
4242
:coordinate-label-mode="coordinateLabelMode" @close="showSettingsModal = false"
43-
@toggle-flip="isFlipped = !isFlipped"
4443
@update:is-sound-enabled="(val: boolean) => isSoundEnabled = val"
4544
@update:coordinate-label-mode="(val: 'off' | 'inside' | 'outside') => coordinateLabelMode = val" />
4645
</section>
@@ -117,6 +116,12 @@ const {
117116
stopClock,
118117
} = game
119118
119+
// ---- 远程对战 ----
120+
const handleRemoteGame = () => {
121+
// TODO: 后续实现远程对战功能
122+
showSetup.value = true
123+
}
124+
120125
// ---- 生命周期 ----
121126
onUnmounted(() => {
122127
stopClock()

src/assets/styles/global.css

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
body, html {
2+
-webkit-user-select: none;
3+
user-select: none;
4+
}
5+
6+
img {
7+
-webkit-user-drag: none;
8+
user-drag: none;
9+
image-rendering: crisp-edges;
10+
image-rendering: pixelated;
11+
image-rendering: -webkit-optimize-contrast;
12+
image-rendering: -moz-crisp-edges;
13+
-ms-interpolation-mode: nearest-neighbor;
14+
}
15+
16+
input,
17+
textarea,
18+
[contenteditable="true"],
19+
.can-select {
20+
-webkit-user-select: text;
21+
user-select: text;
22+
}
23+
124
.card {
225
border: 2px solid #212529;
326
background-color: #fff;
@@ -54,8 +77,3 @@
5477
.btn:focus {
5578
outline: none;
5679
}
57-
58-
.no-select {
59-
-webkit-user-select: none;
60-
user-select: none;
61-
}

src/components/BoardPanel.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</div>
5858
</div>
5959

60-
<img v-if="isDragging && dragStartSquare" class="floating-piece no-select" draggable="false"
60+
<img v-if="isDragging && dragStartSquare" class="floating-piece " draggable="false"
6161
:src="getPieceImage(board[dragStartSquare.row]?.[dragStartSquare.col]!, board, isDraw, hasResigned, timeoutWinner)"
6262
:style="{ left: mousePos.x + 'px', top: mousePos.y + 'px' }" alt="" />
6363
</div>
@@ -229,8 +229,6 @@ watch(pieceScale, (val) => {
229229
.square-background,
230230
.piece {
231231
display: block;
232-
image-rendering: crisp-edges;
233-
image-rendering: pixelated;
234232
}
235233
236234
.square-background.base {
@@ -270,8 +268,6 @@ watch(pieceScale, (val) => {
270268
pointer-events: none;
271269
z-index: 9999;
272270
transform: translate(-50%, -50%) scale(var(--piece-scale));
273-
image-rendering: crisp-edges;
274-
image-rendering: pixelated;
275271
}
276272
277273
.coordinate-label {
@@ -282,7 +278,6 @@ watch(pieceScale, (val) => {
282278
font-weight: bold;
283279
pointer-events: none;
284280
z-index: 5;
285-
user-select: none;
286281
}
287282
288283
.coordinates-outside-layer {

src/components/ChessClock.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div v-if="isClockEnabled" class="clock-grid no-select" :data-testid="testId">
2+
<div v-if="isClockEnabled" class="clock-grid " :data-testid="testId">
33
<div class="clock-side side-white" :class="{ 'is-active': activeColor === 'white' }">
44
<span class="clock-time">{{ formattedWhiteTime }}</span>
55
</div>

src/components/GameSetup.vue

Lines changed: 145 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
<template>
22
<div class="setup-overlay">
3-
<section class="setup-panel nes-container with-title">
3+
<!-- 首页:上方 Logo,下方三个按钮 -->
4+
<section v-if="screen === 'home'" class="home-panel">
5+
<div class="logo-section">
6+
<!-- 修改处:将文字标题替换为图片 Logo -->
7+
<img src="/texture/logo.png" alt="Chess Dragon" class="logo-img" />
8+
</div>
9+
<div class="home-buttons">
10+
<button class="btn btn-home" @click="startSetup('ai')">人机对战</button>
11+
<button class="btn btn-home" @click="startSetup('human')">双人对战</button>
12+
<button class="btn btn-home btn-home--secondary" @click="handleRemote">远程对战</button>
13+
</div>
14+
</section>
15+
16+
<!-- 对局设置面板 -->
17+
<section v-else class="setup-panel with-title">
418
<div class="setup-section">
519
<h3>棋盘</h3>
620
<div class="option-group">
@@ -33,6 +47,18 @@
3347
</label>
3448
</div>
3549

50+
<!-- 强度设置(仅人机对战) -->
51+
<div v-if="gameMode === 'ai'" class="setup-section">
52+
<h3>强度</h3>
53+
<div class="option-group">
54+
<label v-for="level in 5" :key="level" class="option-card difficulty-card"
55+
:class="{ active: difficulty === level }">
56+
<input v-model="difficulty" type="radio" :value="level" />
57+
<span>{{ level }}</span>
58+
</label>
59+
</div>
60+
</div>
61+
3662
<div class="setup-section">
3763
<h3>执棋方</h3>
3864
<div class="option-group">
@@ -53,9 +79,14 @@
5379

5480
<p v-if="errorMessage" class="error-message">{{ errorMessage }}</p>
5581

56-
<button type="button" class="nes-btn is-primary start-btn" @click="handleStart">
57-
开始对局
58-
</button>
82+
<div class="setup-actions">
83+
<button type="button" class="btn btn-secondary" @click="screen = 'home'">
84+
返回
85+
</button>
86+
<button type="button" class="btn btn-primary start-btn" @click="handleStart">
87+
开始对局
88+
</button>
89+
</div>
5990
</section>
6091
</div>
6192
</template>
@@ -69,19 +100,35 @@ export interface GameSetupConfig {
69100
timeMinutes: number
70101
incrementSeconds: number
71102
starter: 'black' | 'random' | 'white'
103+
gameMode: 'ai' | 'human' | 'remote'
104+
difficulty: number
72105
}
73106
74107
const emit = defineEmits<{
75108
start: [config: GameSetupConfig]
109+
remote: []
76110
}>()
77111
112+
const screen = ref<'home' | 'setup'>('home')
113+
const gameMode = ref<'ai' | 'human' | 'remote'>('ai')
114+
const difficulty = ref(3)
115+
78116
const boardMode = ref<'standard' | 'custom'>('standard')
79117
const fenInput = ref('')
80118
const timeMinutes = ref(10)
81119
const incrementSeconds = ref(0)
82120
const starter = ref<'black' | 'random' | 'white'>('white')
83121
const errorMessage = ref('')
84122
123+
const startSetup = (mode: 'ai' | 'human') => {
124+
gameMode.value = mode
125+
screen.value = 'setup'
126+
}
127+
128+
const handleRemote = () => {
129+
emit('remote')
130+
}
131+
85132
const handleStart = () => {
86133
errorMessage.value = ''
87134
@@ -105,6 +152,8 @@ const handleStart = () => {
105152
timeMinutes: timeMinutes.value,
106153
incrementSeconds: timeMinutes.value === 0 ? 0 : incrementSeconds.value,
107154
starter: starter.value,
155+
gameMode: gameMode.value,
156+
difficulty: difficulty.value,
108157
})
109158
}
110159
</script>
@@ -121,6 +170,62 @@ const handleStart = () => {
121170
background-color: #f0f0f0;
122171
}
123172
173+
.home-panel {
174+
display: flex;
175+
flex-direction: column;
176+
align-items: center;
177+
gap: 40px;
178+
text-align: center;
179+
}
180+
181+
.logo-section {
182+
display: flex;
183+
flex-direction: column;
184+
align-items: center;
185+
gap: 8px;
186+
}
187+
188+
.logo-img {
189+
max-width: 60vh;
190+
height: auto;
191+
object-fit: contain;
192+
}
193+
194+
195+
.home-buttons {
196+
display: flex;
197+
flex-direction: column;
198+
gap: 16px;
199+
width: 260px;
200+
}
201+
202+
.btn-home {
203+
width: 100%;
204+
padding: 14px 0;
205+
font-size: 1.15rem;
206+
font-weight: 600;
207+
border: 2px solid #212529;
208+
background: #fff;
209+
color: #212529;
210+
cursor: pointer;
211+
transition: background-color 0.15s, color 0.15s;
212+
}
213+
214+
.btn-home:hover {
215+
background: #212529;
216+
color: #fff;
217+
}
218+
219+
.btn-home--secondary {
220+
border-color: #888;
221+
color: #666;
222+
}
223+
224+
.btn-home--secondary:hover {
225+
background: #888;
226+
color: #fff;
227+
}
228+
124229
.setup-panel {
125230
width: min(560px, 100%);
126231
max-height: 90vh;
@@ -161,6 +266,21 @@ const handleStart = () => {
161266
cursor: pointer;
162267
}
163268
269+
.difficulty-card {
270+
width: 40px;
271+
height: 40px;
272+
justify-content: center;
273+
padding: 0;
274+
font-size: 1.1rem;
275+
font-weight: 600;
276+
}
277+
278+
.difficulty-card.active {
279+
border-color: #212529;
280+
background: #212529;
281+
color: #fff;
282+
}
283+
164284
.fen-input {
165285
width: 100%;
166286
box-sizing: border-box;
@@ -183,8 +303,27 @@ const handleStart = () => {
183303
font-size: 0.95rem;
184304
}
185305
306+
.setup-actions {
307+
display: flex;
308+
gap: 12px;
309+
}
310+
311+
.btn-secondary {
312+
flex: 0 0 auto;
313+
padding: 10px 20px;
314+
border: 1px solid #888;
315+
background: #fff;
316+
color: #555;
317+
font-size: 0.95rem;
318+
cursor: pointer;
319+
transition: background-color 0.15s;
320+
}
321+
322+
.btn-secondary:hover {
323+
background: #f0f0f0;
324+
}
325+
186326
.start-btn {
187-
width: 100%;
188-
margin-top: 8px;
327+
flex: 1;
189328
}
190329
</style>

src/components/Promotion.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ const computedStyle = computed(() => ({
4646
background: #ffffff;
4747
z-index: 60;
4848
overflow: hidden;
49-
50-
/* 保证像素风格纹理渲染清晰 */
51-
image-rendering: pixelated;
52-
image-rendering: crisp-edges;
53-
54-
-webkit-user-select: none;
55-
-moz-user-select: none;
56-
user-select: none;
5749
}
5850
5951
.promote-btn {
@@ -78,8 +70,5 @@ const computedStyle = computed(() => ({
7870
height: 100%;
7971
object-fit: contain;
8072
box-sizing: border-box;
81-
82-
image-rendering: pixelated;
83-
image-rendering: crisp-edges;
8473
}
8574
</style>

src/components/SettingsModal.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
<p class="dialog-title">游戏设置</p>
55

66
<div class="settings-list">
7-
<!-- 翻转棋盘(按钮形式) -->
8-
<div class="setting-item">
9-
<span class="setting-label">棋盘方向</span>
10-
<button type="button" class="btn flip-btn" @click="$emit('toggle-flip')">
11-
翻转棋盘
12-
</button>
13-
</div>
14-
157
<!-- 音效开关 -->
168
<div class="setting-item">
179
<span class="setting-label">音效</span>

0 commit comments

Comments
 (0)