From 783b7beacdca3f6abac258329e68f06a63f68b14 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 25 Jun 2025 12:29:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E5=88=B0=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages-user/client-modules/src/render/index.tsx | 7 ++++++- .../client-modules/src/render/ui/settings.tsx | 14 +++++++++++--- packages/system-ui/src/controller.ts | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages-user/client-modules/src/render/index.tsx b/packages-user/client-modules/src/render/index.tsx index be9bb9d..6e0dafb 100644 --- a/packages-user/client-modules/src/render/index.tsx +++ b/packages-user/client-modules/src/render/index.tsx @@ -1,7 +1,7 @@ import { createApp, Font } from '@motajs/render'; import { defineComponent } from 'vue'; import { MAIN_HEIGHT, MAIN_WIDTH } from './shared'; -import { loading } from '@user/data-base'; +import { hook, loading } from '@user/data-base'; import { createLoopMap } from './loopMap'; import { createElements } from './elements'; import { mainRenderer } from './renderer'; @@ -38,6 +38,11 @@ export function createRender() { mainRenderer.show(); }); + hook.on('restart', () => { + sceneController.closeAll(); + sceneController.open(GameTitleUI, {}); + }); + Font.setDefaults(new Font('normal', 18)); } diff --git a/packages-user/client-modules/src/render/ui/settings.tsx b/packages-user/client-modules/src/render/ui/settings.tsx index f9bfa12..0ac172f 100644 --- a/packages-user/client-modules/src/render/ui/settings.tsx +++ b/packages-user/client-modules/src/render/ui/settings.tsx @@ -58,7 +58,7 @@ export const MainSettings = defineComponent(props => { [MainChoice.Back, '返回游戏'] ]; - const choose = (key: ChoiceKey) => { + const choose = async (key: ChoiceKey) => { switch (key) { case MainChoice.SystemSetting: { mainUi.open('settings'); @@ -92,8 +92,16 @@ export const MainSettings = defineComponent(props => { break; } case MainChoice.Restart: { - props.controller.closeAll(); - core.restart(); + const confirm = await getConfirm( + props.controller, + '确认要返回标题吗?', + [420, 240, void 0, void 0, 0.5, 0.5], + 240 + ); + if (confirm) { + props.controller.closeAll(); + core.restart(); + } break; } case MainChoice.Back: { diff --git a/packages/system-ui/src/controller.ts b/packages/system-ui/src/controller.ts index b45a632..8f7c8ab 100644 --- a/packages/system-ui/src/controller.ts +++ b/packages/system-ui/src/controller.ts @@ -237,7 +237,8 @@ export class UIController closeAll(ui?: IGameUI): void { if (!ui) { - this.stack.splice(0); + const list = this.stack.slice(); + list.forEach(v => this.close(v)); } else { const list = this.stack.filter(v => v.ui === ui); list.forEach(v => this.close(v));