feat(share): 容器接线 ShareGuideDialog(订阅 SHOW_GUIDE/渲染/返回键/一次性回投,分享重构 §7)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fffb353345
commit
b1055c79f6
@@ -6,10 +6,11 @@ import { ConfigManager, ResourceManager, AppDataInjector, AppDataValues, RemoteC
|
|||||||
import { KvStore, LocalUploadServer } from 'platform';
|
import { KvStore, LocalUploadServer } from 'platform';
|
||||||
import { OutboundHandlers } from 'contracts';
|
import { OutboundHandlers } from 'contracts';
|
||||||
import { AppEnv, EventBus, EventPayload, NavEvents, OpenGenericWebPayload, SwitchGamePayload,
|
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 { BridgeGameParams, GenericWebParams, GenericWebResult, RouteName, AppEvents } from '../routes/AppRoutes';
|
||||||
import { WebSlot } from '../web/WebSlot';
|
import { WebSlot } from '../web/WebSlot';
|
||||||
import { SharePanel } from '../components/SharePanel';
|
import { SharePanel } from '../components/SharePanel';
|
||||||
|
import { ShareGuideDialog } from '../components/ShareGuideDialog';
|
||||||
import { KEY_SPLASH_VISIBLE } from './Index';
|
import { KEY_SPLASH_VISIBLE } from './Index';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +53,12 @@ export struct BridgeGameContainer {
|
|||||||
@State private sharePanelVisible: boolean = false;
|
@State private sharePanelVisible: boolean = false;
|
||||||
/** 当前分享面板的一次性回投事件名(用户选定平台后 emit 回 ShareProvider)。 */
|
/** 当前分享面板的一次性回投事件名(用户选定平台后 emit 回 ShareProvider)。 */
|
||||||
private shareResultEvent: string = '';
|
private shareResultEvent: string = '';
|
||||||
|
/** 分享指引窗显隐(渠道选定后叠在 Stack 顶层)。 */
|
||||||
|
@State private shareGuideVisible: boolean = false;
|
||||||
|
private shareGuidePlatform: string = '';
|
||||||
|
private shareGuideKind: string = '';
|
||||||
|
/** 当前指引窗的一次性回投事件名(用户选动作后 emit 回 ShareProvider)。 */
|
||||||
|
private shareGuideResultEvent: string = '';
|
||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
if (AppEnv.isDebug()) {
|
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.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(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_PANEL, (p?: EventPayload) => this.showSharePanel(p)));
|
||||||
|
this.cancels.push(EventBus.on(ShareEvents.SHOW_GUIDE, (p?: EventPayload) => this.showShareGuide(p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 收到 ShareProvider 的 SHOW_PANEL:记下一次性回投事件名并弹出面板。 */
|
/** 收到 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')。 */
|
/** 路径 B:打开通用网页容器;关闭回传 → 当前激活槽 callHandler('getWebdata')。 */
|
||||||
private openGenericWeb(p?: EventPayload): void {
|
private openGenericWeb(p?: EventPayload): void {
|
||||||
if (p === undefined) {
|
if (p === undefined) {
|
||||||
@@ -390,6 +425,14 @@ export struct BridgeGameContainer {
|
|||||||
if (this.sharePanelVisible) {
|
if (this.sharePanelVisible) {
|
||||||
SharePanel({ onPick: (platform: string) => this.emitShareResult(platform) })
|
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%')
|
.width('100%').height('100%')
|
||||||
// 垫白底:Web 首帧前/页面切换间隙显白色(与启动页白底无缝),避免黑屏闪烁
|
// 垫白底:Web 首帧前/页面切换间隙显白色(与启动页白底无缝),避免黑屏闪烁
|
||||||
@@ -397,6 +440,11 @@ export struct BridgeGameContainer {
|
|||||||
}
|
}
|
||||||
.hideTitleBar(true)
|
.hideTitleBar(true)
|
||||||
.onBackPressed(() => {
|
.onBackPressed(() => {
|
||||||
|
// 指引窗打开时,返回键关闭并按取消回投
|
||||||
|
if (this.shareGuideVisible) {
|
||||||
|
this.emitShareGuideResult('cancel');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// 分享面板打开时,返回键关闭面板并按取消回投(对齐 Android 点空白关闭)
|
// 分享面板打开时,返回键关闭面板并按取消回投(对齐 Android 点空白关闭)
|
||||||
if (this.sharePanelVisible) {
|
if (this.sharePanelVisible) {
|
||||||
this.emitShareResult('cancel');
|
this.emitShareResult('cancel');
|
||||||
|
|||||||
Reference in New Issue
Block a user