refactor: 提取 refreshBoard status 计算逻辑提高可读性

This commit is contained in:
2026-05-31 13:52:10 +08:00
parent 4ed66377d2
commit 3331d567c0
2 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
# MinGW-Builds MCF 线程模型运行时需要显式链接 libmcfgthread。
# 如果使用 MSVC 工具链或 POSIX 线程模型的 MinGW,可移除此配置。
[target.x86_64-pc-windows-gnu] [target.x86_64-pc-windows-gnu]
# MinGW-Builds MCF 运行时需要链接 libmcfgthread
rustflags = ["-C", "link-args=-lmcfgthread"] rustflags = ["-C", "link-args=-lmcfgthread"]
+6 -1
View File
@@ -100,10 +100,15 @@ export const useGameStore = create<GameState>((set, get) => ({
refreshBoard: async () => { refreshBoard: async () => {
const state: { board: CellState[][]; current_color: string; game_over: boolean } = const state: { board: CellState[][]; current_color: string; game_over: boolean } =
await invoke('get_game_state'); await invoke('get_game_state');
const newStatus: GameStatus = state.game_over
? 'game_over'
: get().status === 'ai_thinking'
? 'ai_thinking'
: 'playing';
set({ set({
board: state.board, board: state.board,
currentColor: state.current_color as Color, currentColor: state.current_color as Color,
status: state.game_over ? 'game_over' : get().status === 'ai_thinking' ? 'ai_thinking' : 'playing', status: newStatus,
}); });
}, },