From b1055c79f60d10859ca5a0b86884dff823eca02c Mon Sep 17 00:00:00 2001 From: lanterngamescn Date: Sat, 27 Jun 2026 14:15:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(share):=20=E5=AE=B9=E5=99=A8=E6=8E=A5?= =?UTF-8?q?=E7=BA=BF=20ShareGuideDialog=EF=BC=88=E8=AE=A2=E9=98=85=20SHOW?= =?UTF-8?q?=5FGUIDE/=E6=B8=B2=E6=9F=93/=E8=BF=94=E5=9B=9E=E9=94=AE/?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=80=A7=E5=9B=9E=E6=8A=95=EF=BC=8C=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E9=87=8D=E6=9E=84=20=C2=A77=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../main/ets/pages/BridgeGameContainer.ets | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/BridgeGameContainer.ets b/entry/src/main/ets/pages/BridgeGameContainer.ets index 9fa8c4a..53d4049 100644 --- a/entry/src/main/ets/pages/BridgeGameContainer.ets +++ b/entry/src/main/ets/pages/BridgeGameContainer.ets @@ -6,10 +6,11 @@ import { ConfigManager, ResourceManager, AppDataInjector, AppDataValues, RemoteC import { KvStore, LocalUploadServer } from 'platform'; import { OutboundHandlers } from 'contracts'; import { AppEnv, EventBus, EventPayload, NavEvents, OpenGenericWebPayload, SwitchGamePayload, - BackGamePayload, ShareEvents, SharePanelRequest, SharePanelResult, Logger } from 'common'; + BackGamePayload, ShareEvents, SharePanelRequest, SharePanelResult, ShareGuideRequest, ShareGuideResult, Logger } from 'common'; import { BridgeGameParams, GenericWebParams, GenericWebResult, RouteName, AppEvents } from '../routes/AppRoutes'; import { WebSlot } from '../web/WebSlot'; import { SharePanel } from '../components/SharePanel'; +import { ShareGuideDialog } from '../components/ShareGuideDialog'; import { KEY_SPLASH_VISIBLE } from './Index'; /** @@ -52,6 +53,12 @@ export struct BridgeGameContainer { @State private sharePanelVisible: boolean = false; /** 当前分享面板的一次性回投事件名(用户选定平台后 emit 回 ShareProvider)。 */ private shareResultEvent: string = ''; + /** 分享指引窗显隐(渠道选定后叠在 Stack 顶层)。 */ + @State private shareGuideVisible: boolean = false; + private shareGuidePlatform: string = ''; + private shareGuideKind: string = ''; + /** 当前指引窗的一次性回投事件名(用户选动作后 emit 回 ShareProvider)。 */ + private shareGuideResultEvent: string = ''; aboutToAppear(): void { if (AppEnv.isDebug()) { @@ -120,6 +127,7 @@ export struct BridgeGameContainer { this.cancels.push(EventBus.on(NavEvents.SWITCH_GAME, (p?: EventPayload) => this.switchGame(p))); this.cancels.push(EventBus.on(NavEvents.BACK_GAME, (p?: EventPayload) => this.backToLobby(p))); this.cancels.push(EventBus.on(ShareEvents.SHOW_PANEL, (p?: EventPayload) => this.showSharePanel(p))); + this.cancels.push(EventBus.on(ShareEvents.SHOW_GUIDE, (p?: EventPayload) => this.showShareGuide(p))); } /** 收到 ShareProvider 的 SHOW_PANEL:记下一次性回投事件名并弹出面板。 */ @@ -147,6 +155,33 @@ export struct BridgeGameContainer { } } + /** 收到 ShareProvider 的 SHOW_GUIDE:记下渠道/类型/一次性回投事件名并弹出指引窗。 */ + private showShareGuide(p?: EventPayload): void { + if (p === undefined) { + return; + } + // 已有指引窗未关闭:先按取消回投旧请求,避免上一个 once 永不触发致 ShareProvider 悬挂。 + if (this.shareGuideVisible && this.shareGuideResultEvent !== '') { + this.emitShareGuideResult('cancel'); + } + const req = p as ShareGuideRequest; + this.shareGuidePlatform = req.platform; + this.shareGuideKind = req.contentKind; + this.shareGuideResultEvent = req.resultEvent; + this.shareGuideVisible = true; + } + + /** 用户选定动作/取消:回投并关闭指引窗。 */ + private emitShareGuideResult(action: string): void { + const ev: string = this.shareGuideResultEvent; + this.shareGuideResultEvent = ''; + this.shareGuideVisible = false; + if (ev !== '') { + const result: ShareGuideResult = { action }; + EventBus.emit(ev, result); + } + } + /** 路径 B:打开通用网页容器;关闭回传 → 当前激活槽 callHandler('getWebdata')。 */ private openGenericWeb(p?: EventPayload): void { if (p === undefined) { @@ -390,6 +425,14 @@ export struct BridgeGameContainer { if (this.sharePanelVisible) { SharePanel({ onPick: (platform: string) => this.emitShareResult(platform) }) } + // 分享指引窗(顶层叠加;渠道选定后弹,选动作/取消 → 一次性回投 ShareProvider) + if (this.shareGuideVisible) { + ShareGuideDialog({ + platform: this.shareGuidePlatform, + contentKind: this.shareGuideKind, + onPick: (action: string) => this.emitShareGuideResult(action), + }) + } } .width('100%').height('100%') // 垫白底:Web 首帧前/页面切换间隙显白色(与启动页白底无缝),避免黑屏闪烁 @@ -397,6 +440,11 @@ export struct BridgeGameContainer { } .hideTitleBar(true) .onBackPressed(() => { + // 指引窗打开时,返回键关闭并按取消回投 + if (this.shareGuideVisible) { + this.emitShareGuideResult('cancel'); + return true; + } // 分享面板打开时,返回键关闭面板并按取消回投(对齐 Android 点空白关闭) if (this.sharePanelVisible) { this.emitShareResult('cancel');