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" >
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" >
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
74107const 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+
78116const boardMode = ref <' standard' | ' custom' >(' standard' )
79117const fenInput = ref (' ' )
80118const timeMinutes = ref (10 )
81119const incrementSeconds = ref (0 )
82120const starter = ref <' black' | ' random' | ' white' >(' white' )
83121const 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+
85132const 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 >
0 commit comments