fix: fix bugs
This commit is contained in:
@@ -83,24 +83,14 @@ export class GameScene extends ReactiveScene<TicTacToeState> {
|
||||
}
|
||||
|
||||
private setupInput(): void {
|
||||
const scene = this;
|
||||
const activePromptRef = {
|
||||
get current() { return scene.activePrompt; }
|
||||
};
|
||||
|
||||
this.inputMapper = createInputMapper(
|
||||
this,
|
||||
this.commands,
|
||||
activePromptRef,
|
||||
{ current: null }, // 不再需要,保留以兼容接口
|
||||
(cmd: string) => {
|
||||
const activePrompt = this.activePrompt;
|
||||
if (!activePrompt) return 'No active prompt';
|
||||
const error = activePrompt.tryCommit(cmd);
|
||||
if (error === null) {
|
||||
this.activePrompt = null;
|
||||
this.promptHandler.start();
|
||||
}
|
||||
return error;
|
||||
// 使用 PromptHandler.submit() 而不是直接 tryCommit
|
||||
// 这样会自动处理没有活跃 prompt 时的排队逻辑
|
||||
return this.promptHandler.submit(cmd);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user