@tbox.cn/app-module-mall-core 1.0.0-alpha.1 → 1.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/AGENTS.md +3 -3
  2. package/README.md +4 -4
  3. package/dist/{chunk-QPBYZO27.js → chunk-ZBHJWURF.js} +1399 -1611
  4. package/dist/{chunk-FIHBQMON.js → chunk-ZVXAPBVE.js} +1 -1
  5. package/dist/client/index.d.ts +0 -11
  6. package/dist/client/index.js +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/server/index.d.ts +16 -16
  9. package/dist/server/index.js +1 -1
  10. package/package.json +7 -7
  11. package/src/client/HomeActivityDetailDialog.tsx +21 -81
  12. package/src/client/MallHome.tsx +109 -54
  13. package/src/client/cards/overrides/BumpInActivityChatCard.tsx +1 -1
  14. package/src/client/components/ActivityDetailPresentation/index.tsx +102 -9
  15. package/src/client/components/MemberGateSheet/index.tsx +38 -92
  16. package/src/client/home-slot.tsx +8 -64
  17. package/src/client/index.ts +4 -3
  18. package/src/client/member-gate-overlay.tsx +89 -0
  19. package/src/server/module-ports.ts +1 -1
  20. package/tbox.module.json +1 -2
  21. package/tests/MemberGateSheet.test.tsx +9 -0
  22. package/tests/home-slot.test.tsx +110 -30
  23. package/tsup.config.ts +0 -1
  24. package/dist/HomeActivityDetailDialog-2GJFYSMZ.less +0 -178
  25. package/dist/MallHome-PABCNS6D.less +0 -623
  26. package/dist/home-slot-WBZ6ONDP.less +0 -4
  27. package/dist/index-ELJ55M66.less +0 -256
  28. package/dist/index-U5YRUY7P.less +0 -352
  29. package/src/client/HomeActivityDetailDialog.less +0 -178
  30. package/src/client/MallHome.less +0 -623
  31. package/src/client/components/ActivityDetailPresentation/index.less +0 -352
  32. package/src/client/components/MemberGateSheet/index.less +0 -256
  33. package/src/client/home-slot.less +0 -4
@@ -1,18 +1,7 @@
1
- import { useEffect, useRef } from 'react';
2
- import { createPortal } from 'react-dom';
1
+ import { useEffect, useRef, useState } from 'react';
3
2
  import { X } from '@phosphor-icons/react';
3
+ import { Overlay } from '@tbox.cn/app-agent-ui-kit/overlay';
4
4
  import type { GateCardContext, GatePhase } from '../../member-gate';
5
- import './index.less';
6
-
7
- const FOCUSABLE_SELECTOR = [
8
- 'button:not([disabled])',
9
- '[href]',
10
- 'input:not([disabled])',
11
- 'select:not([disabled])',
12
- 'textarea:not([disabled])',
13
- '[tabindex]:not([tabindex="-1"])',
14
- ].join(',');
15
-
16
5
  const DEFAULT_TITLE: Record<GateCardContext['kind'], string> = {
17
6
  login: '登录后继续',
18
7
  enroll: '入会后继续',
@@ -51,10 +40,12 @@ export function MemberGateSheet({
51
40
  onRetry,
52
41
  onDismiss,
53
42
  }: MemberGateSheetProps) {
54
- const sheetRef = useRef<HTMLElement>(null);
55
43
  const closeRef = useRef<HTMLButtonElement>(null);
56
44
  const confirmButtonRef = useRef<HTMLButtonElement>(null);
57
45
  const openingRef = useRef(false);
46
+ // 两段式关闭:先播退场动画(onExited)再交还门禁状态机;换卡(context 变)时复位。
47
+ const [closing, setClosing] = useState(false);
48
+ const requestDismiss = () => setClosing(true);
58
49
 
59
50
  const contextId = context.id;
60
51
  const titleId = `member-login-sheet-title-${contextId}`;
@@ -73,59 +64,6 @@ export function MemberGateSheet({
73
64
  : message ?? '请稍后重试'
74
65
  : context.subtitle ?? DEFAULT_DESCRIPTION[context.kind];
75
66
 
76
- useEffect(() => {
77
- const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
78
- const previousOverflow = document.body.style.overflow;
79
- const appRoot = document.getElementById('root');
80
- const previousAriaHidden = appRoot?.getAttribute('aria-hidden') ?? null;
81
- const previousInert = appRoot?.inert ?? false;
82
-
83
- document.body.style.overflow = 'hidden';
84
- if (appRoot) {
85
- appRoot.setAttribute('aria-hidden', 'true');
86
- appRoot.inert = true;
87
- }
88
- closeRef.current?.focus();
89
-
90
- const handleKeyDown = (event: KeyboardEvent) => {
91
- if (event.key === 'Escape') {
92
- event.preventDefault();
93
- onDismiss();
94
- return;
95
- }
96
- if (event.key !== 'Tab') return;
97
-
98
- const focusable = Array.from(
99
- sheetRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR) ?? [],
100
- );
101
- if (focusable.length === 0) {
102
- event.preventDefault();
103
- return;
104
- }
105
- const first = focusable[0];
106
- const last = focusable[focusable.length - 1];
107
- if (event.shiftKey && document.activeElement === first) {
108
- event.preventDefault();
109
- last.focus();
110
- } else if (!event.shiftKey && document.activeElement === last) {
111
- event.preventDefault();
112
- first.focus();
113
- }
114
- };
115
-
116
- document.addEventListener('keydown', handleKeyDown);
117
- return () => {
118
- document.removeEventListener('keydown', handleKeyDown);
119
- document.body.style.overflow = previousOverflow;
120
- if (appRoot) {
121
- appRoot.inert = previousInert;
122
- if (previousAriaHidden === null) appRoot.removeAttribute('aria-hidden');
123
- else appRoot.setAttribute('aria-hidden', previousAriaHidden);
124
- }
125
- previousFocus?.focus();
126
- };
127
- }, [contextId, onDismiss]);
128
-
129
67
  // 阶段回退(cancel 收场/终态重试重开/同浮层新卡重新武装)时复位一次性标志,confirm 按钮重新可用
130
68
  useEffect(() => {
131
69
  if (phase === 'idle') {
@@ -133,6 +71,13 @@ export function MemberGateSheet({
133
71
  }
134
72
  }, [phase, contextId]);
135
73
 
74
+ // 同浮层换卡(门禁卡被新消息替换)时重新武装并回到关闭按钮(旧实现的 effect 依赖 contextId,
75
+ // 换卡即重聚焦;内核只管首次打开,这里补回同一语义)。
76
+ useEffect(() => {
77
+ setClosing(false);
78
+ closeRef.current?.focus({ preventScroll: true });
79
+ }, [contextId]);
80
+
136
81
  const performConfirm = () => {
137
82
  if (openingRef.current) return;
138
83
  openingRef.current = true;
@@ -146,42 +91,45 @@ export function MemberGateSheet({
146
91
  : CONFIRM_LABEL[context.kind];
147
92
  const confirmDisabled = busy || phase !== 'idle';
148
93
 
149
- return createPortal(
150
- <div className="member-login-sheet" role="presentation">
151
- <div className="member-login-sheet__mask" aria-hidden="true" onClick={() => onDismiss()} />
152
- <section
153
- ref={sheetRef}
154
- className="member-login-sheet__panel"
155
- role="dialog"
156
- aria-modal="true"
157
- aria-labelledby={titleId}
158
- aria-describedby={descriptionId}
159
- >
160
- <div className="member-login-sheet__handle" aria-hidden="true" />
94
+ return (
95
+ <Overlay
96
+ open={!closing}
97
+ onDismiss={requestDismiss}
98
+ onExited={onDismiss}
99
+ exitMs={220}
100
+ placement="bottom"
101
+ labelledBy={titleId}
102
+ describedBy={descriptionId}
103
+ initialFocus={closeRef}
104
+ rootClassName="member-login-sheet group"
105
+ maskClassName="bg-scrim animate-[member-login-mask-in_180ms_ease-out_both] group-data-[state=closed]:animate-[member-login-mask-out_160ms_ease-in_both] motion-reduce:animate-none"
106
+ panelClassName="member-login-sheet__panel flex h-[58vh] min-h-0 w-full max-w-[560px] flex-col overflow-hidden rounded-t-[28px] bg-card shadow-[0_-14px_44px_rgba(35,47,28,0.16)] animate-[member-login-sheet-in_260ms_cubic-bezier(0.22,0.72,0.24,1)_both] [@media(max-height:620px)]:h-[64vh] [@media(max-height:620px)]:supports-[height:100dvh]:h-[64dvh] landscape:[@media(max-height:500px)]:h-[88vh] landscape:[@media(max-height:500px)]:supports-[height:100dvh]:h-[88dvh] max-h-[calc(100vh-env(safe-area-inset-top)-12px)] supports-[height:100dvh]:max-h-[calc(100dvh-env(safe-area-inset-top)-12px)] group-data-[state=closed]:animate-[member-login-sheet-out_200ms_ease-in_both] motion-reduce:animate-none"
107
+ >
108
+ <div className="member-login-sheet__handle absolute left-1/2 top-2.25 z-10 h-1 w-9.5 -translate-x-1/2 rounded-full bg-neutral-soft" aria-hidden="true" />
161
109
  <button
162
110
  ref={closeRef}
163
111
  type="button"
164
- className="member-login-sheet__close"
112
+ className="member-login-sheet__close absolute right-4.5 top-4.5 z-20 grid size-9 place-items-center rounded-full border border-border bg-card p-0 text-foreground shadow-md outline-none focus-visible:ring-3 focus-visible:ring-focus-ring"
165
113
  aria-label="关闭登录提示"
166
- onClick={() => onDismiss()}
114
+ onClick={requestDismiss}
167
115
  >
168
116
  <X size={18} weight="bold" aria-hidden="true" />
169
117
  </button>
170
118
 
171
- <div className="member-login-sheet__scroll">
119
+ <div className="member-login-sheet__scroll flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
172
120
  {/* 素材变量链(主题轨 T-2.3):主视觉经 CSS background(--tbox-asset-member-login-hero) */}
173
- <div className="member-login-sheet__hero" aria-hidden="true" />
174
- <div className="member-login-sheet__tear" aria-hidden="true" />
121
+ <div className="member-login-sheet__hero relative min-h-40 w-full flex-[1_1_190px] overflow-hidden member-hero [@media(max-height:620px)]:min-h-29 [@media(max-height:620px)]:flex-[0_0_116px]" aria-hidden="true" />
122
+ <div className="member-login-sheet__tear relative z-10 -mt-3.75 h-4 w-full shrink-0 bg-card [clip-path:polygon(0_70%,8%_28%,15%_72%,24%_22%,33%_66%,43%_18%,53%_72%,63%_25%,72%_68%,82%_20%,91%_64%,100%_32%,100%_100%,0_100%)]" aria-hidden="true" />
175
123
 
176
- <div className="member-login-sheet__content">
124
+ <div className="member-login-sheet__content shrink-0 px-3 pb-[calc(14px+env(safe-area-inset-bottom))] pt-3 text-center [@media(max-height:620px)]:pt-2 [&_h2]:m-0 [&_h2]:text-xl [&_h2]:font-bold [&_h2]:leading-tight [&_h2]:text-foreground">
177
125
  <h2 id={titleId}>{heroTitle}</h2>
178
- <p id={descriptionId} className="member-login-sheet__description">
126
+ <p id={descriptionId} className="member-login-sheet__description mt-1.5 text-sm leading-normal text-muted-foreground">
179
127
  {description}
180
128
  </p>
181
129
 
182
130
  {isTerminal ? (
183
- <div className="member-login-sheet__status-actions">
184
- <button type="button" onClick={() => onDismiss()}>暂不</button>
131
+ <div className="member-login-sheet__status-actions mx-auto mt-2 grid w-[min(100%,292px)] grid-cols-2 gap-2.5 [&_button]:min-h-11 [&_button]:rounded-xl [&_button]:border-0 [&_button]:bg-muted [&_button]:px-2.5 [&_button]:text-sm [&_button]:font-semibold [&_button]:text-secondary-foreground [&_button:last-child]:bg-member-accent [&_button:last-child]:text-white [&_button:disabled]:cursor-not-allowed [&_button:disabled]:opacity-68 [&_button:focus-visible]:ring-3 [&_button:focus-visible]:ring-focus-ring [&_button:active:not(:disabled)]:scale-98">
132
+ <button type="button" onClick={requestDismiss}>暂不</button>
185
133
  <button
186
134
  ref={confirmButtonRef}
187
135
  type="button"
@@ -195,7 +143,7 @@ export function MemberGateSheet({
195
143
  <button
196
144
  ref={confirmButtonRef}
197
145
  type="button"
198
- className="member-login-sheet__login"
146
+ className="member-login-sheet__login mx-auto mt-2 flex min-h-11 w-[min(100%,292px)] items-center justify-center rounded-xl border-0 bg-member-accent px-4 text-sm font-semibold leading-none text-white shadow-md transition active:scale-98 disabled:cursor-not-allowed disabled:opacity-68"
199
147
  disabled={confirmDisabled}
200
148
  onClick={performConfirm}
201
149
  >
@@ -204,8 +152,6 @@ export function MemberGateSheet({
204
152
  )}
205
153
  </div>
206
154
  </div>
207
- </section>
208
- </div>,
209
- document.body,
155
+ </Overlay>
210
156
  );
211
157
  }
@@ -5,17 +5,15 @@
5
5
  *
6
6
  * slot 值 = 自持渲染函数(kit ChatPage 恒挂载;域自持数据加载/门禁状态机/浮层显隐)。
7
7
  */
8
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
8
+ import { useCallback, useEffect, useRef, useState } from 'react';
9
9
  import type { HomeSlotRenderProps, HomeSlotValue, TboxCardPayload } from '@tbox.cn/app-contracts';
10
- import { createLogger, getAuthClient, getLoginState, isInAlipayShell, waitForSocketOpen } from '@tbox.cn/app-agent-sdk-client';
11
- import { RawCardRenderer, toast, useChatStore, useChatStoreApi } from '@tbox.cn/app-agent-ui-kit';
10
+ import { getAuthClient } from '@tbox.cn/app-agent-sdk-client';
11
+ import { RawCardRenderer, useChatStore } from '@tbox.cn/app-agent-ui-kit';
12
12
  import { readMallIdFromUrl } from '@tbox.cn/app-contracts-mall';
13
13
 
14
14
  import { MallHome } from './MallHome';
15
+ import { useMemberGateController } from './member-gate-overlay';
15
16
  import { MemberGateSheet } from './components/MemberGateSheet';
16
- import { selectLatestMemberGateCard } from './components/MemberGateSheet/model';
17
- import { createMemberGate, useMemberGate } from './member-gate';
18
- import { directLoginGate } from './mock-direct-gate';
19
17
  import {
20
18
  loadHomeConfig,
21
19
  loadLinkedPanelState,
@@ -23,8 +21,6 @@ import {
23
21
  pickMallId,
24
22
  } from './home-runtime';
25
23
  import type { HomeConfig, LinkedOrderLoadState, MemberLoadState, ParkingLoadState } from './home-runtime';
26
- import './home-slot.less';
27
-
28
24
  const PARKING_FEE_QUERY = '查询停车费';
29
25
  const PARKING_VEHICLE_QUERY = '我的车辆';
30
26
  const PARKING_SERVICE_QUERY = '停车服务';
@@ -34,16 +30,12 @@ function renderHomeActivityDetail(card: TboxCardPayload) {
34
30
  return <RawCardRenderer card={card} />;
35
31
  }
36
32
 
37
- /** 门禁排障五锚(open/receipt/relogin/judge/replay)——对齐 SESSION-UPGRADE 域日志先例 */
38
- const gateLogger = createLogger('MEMBER-GATE');
39
33
 
40
34
  function HomeSlotContent({ onSend, mallName }: HomeSlotRenderProps) {
41
- const store = useChatStoreApi();
42
35
  const messages = useChatStore((s) => s.messages);
43
36
  const orphanCards = useChatStore((s) => s.orphanCards);
44
37
  const cardsByMessageId = useChatStore((s) => s.cardsByMessageId);
45
38
  const retryBootstrap = useChatStore((s) => s.retryBootstrap);
46
- const isGenerating = useChatStore((s) => s.isGenerating);
47
39
  // 面板 mallId 读源:URL 优先(?mallId= / 小程序壳 ?plazaId=)——挂载即可发 /api/m/mall-core/linked-panel,免等
48
40
  // createConversation + WS HELLO 握手;URL 缺席回退 HELLO_ACK(原逻辑不变)。HELLO 后到且值不同时,
49
41
  // 面板 effect 依赖 mallId 自动重载(以 HELLO 为准,旧请求经 AbortController 中止)。
@@ -63,58 +55,10 @@ function HomeSlotContent({ onSend, mallName }: HomeSlotRenderProps) {
63
55
  // parking-vehicle-management 各卡 bound 数快照(按卡 id 跟踪;已有卡 bound 变化=绑定/解绑发生)
64
56
  const prevParkingBoundByCardRef = useRef<Map<string, number>>(new Map());
65
57
 
66
- const gateCard = useMemo(
67
- () => selectLatestMemberGateCard(messages.map((message) => message.id), cardsByMessageId, orphanCards),
68
- [messages, cardsByMessageId, orphanCards],
69
- );
70
-
71
- // 会员门禁状态机(deps 全注入 store/平台面;实例单建——store 方法经 getState 现取)
72
- const gate = useMemo(
73
- () =>
74
- createMemberGate({
75
- // 壳内走桥(容器 mock-enrollment/真实厂商 gate 页);非壳(扫码直开/浏览器)走 H5 直连 mock 入会
76
- getLoginState: (params) => (isInAlipayShell() ? getLoginState(params) : directLoginGate()),
77
- retryBootstrap: (refreshAuth) => store.getState().retryBootstrap(refreshAuth),
78
- loadPanel: async (panelMallId) => {
79
- const panel = await loadLinkedPanelState(getAuthClient(), panelMallId, fetch);
80
- return { member: { status: panel.member.status } };
81
- },
82
- waitForSocketOpen,
83
- getAuthState: () => getAuthClient().getAuthState(),
84
- sendMessage: (input) => store.getState().sendMessage(input),
85
- sendUiAction: (surfaceId, action) => store.getState().sendUiAction(surfaceId, action),
86
- hideCard: (cardId) => store.getState().hideCard(cardId),
87
- toast: (content) => {
88
- void toast(content);
89
- },
90
- isGenerating: () => store.getState().isGenerating,
91
- lastUserMessage: () => {
92
- const live = store.getState().messages;
93
- for (let i = live.length - 1; i >= 0; i -= 1) {
94
- if (live[i]?.role === 'user') return { id: live[i].id, content: live[i].content };
95
- }
96
- return null;
97
- },
98
- readMallId: () =>
99
- pickMallId(store.getState().helloAck?.mallScope?.mallId, readMallIdFromUrl()),
100
- refreshPanel: () => setLinkedPanelReloadEpoch((epoch) => epoch + 1),
101
- log: (message) => {
102
- gateLogger.info(message);
103
- },
104
- }),
105
- // eslint-disable-next-line react-hooks/exhaustive-deps
106
- [],
107
- );
108
- const gateState = useMemberGate(gate);
109
-
110
- // 门禁卡到达 → 武装浮层(飞轮中忽略;同卡不重复;replayQuery 缺省取触发原话)
111
- useEffect(() => {
112
- if (!gateCard) return;
113
- const { phase, card } = gate.getState();
114
- if (phase === 'opening' || phase === 'syncing') return;
115
- if (card?.id === gateCard.id) return;
116
- gate.trigger(gateCard, undefined);
117
- }, [gateCard, gate, gateState.phase]);
58
+ const refreshPanel = useCallback(() => {
59
+ setLinkedPanelReloadEpoch((epoch) => epoch + 1);
60
+ }, []);
61
+ const { gate, gateState, isGenerating } = useMemberGateController(refreshPanel);
118
62
 
119
63
  // 首页配置单次加载(app 级旗标,无 mall/会话维度,无 reload epoch);任何失败保持隐藏。
120
64
  useEffect(() => {
@@ -2,15 +2,16 @@
2
2
  * module-mall-core 客户端入口(与服务端 serverModule 对称;2026-09-20 随 module-mall-home 并入)。
3
3
  *
4
4
  * 注册面(应用组装端 registerAll(ctx) 内生效):
5
- * - ctx.slots.register('home', homeSlotValue):商圈主屏槽(空态首屏 + 会话态恒挂载,域自持显隐);
5
+ * - ctx.slots.register('conversationOverlay', ...):会员授权/入会浮层;
6
6
  * - ctx.cards.registerOverride('promotion-bumpin-activity', ...):聊天视图组合层覆盖
7
7
  * (原始形态仍由 provider 模块注册——RawCardRenderer 详情弹层防嵌套);
8
8
  * - ctx.cards.registerInlineFilter(filterInlineCards):会员门禁卡系剥离(浮层自持,不进内联流);
9
9
  * - cards map 'mall-home':首页预览卡(dev 预览专用——/_tbox/card-preview 目录收录,chat 零出场)。
10
10
  */
11
+ import { createElement } from 'react';
11
12
  import type { CardComponent } from '@tbox.cn/app-contracts';
12
13
  import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
13
- import { homeSlotValue } from './home-slot.js';
14
+ import { MemberGateOverlay } from './member-gate-overlay.js';
14
15
  import { BumpInActivityChatCard } from './cards/overrides/BumpInActivityChatCard.js';
15
16
  import { MallHomePreviewCard } from './cards/mall-home/index.js';
16
17
  import { filterInlineCards } from './components/MemberGateSheet/model.js';
@@ -22,7 +23,7 @@ const cards = {
22
23
  export const clientModule = {
23
24
  cards,
24
25
  register(ctx: ClientContext): void {
25
- ctx.slots.register('home', homeSlotValue);
26
+ ctx.slots.register('conversationOverlay', () => createElement(MemberGateOverlay));
26
27
  ctx.cards.registerMap(cards);
27
28
  ctx.cards.registerOverride('promotion-bumpin-activity', BumpInActivityChatCard);
28
29
  ctx.cards.registerInlineFilter(filterInlineCards);
@@ -0,0 +1,89 @@
1
+ import { useEffect, useMemo } from 'react';
2
+ import { createLogger, getAuthClient, getLoginState, isInAlipayShell, waitForSocketOpen } from '@tbox.cn/app-agent-sdk-client';
3
+ import { toast, useChatStore, useChatStoreApi } from '@tbox.cn/app-agent-ui-kit';
4
+ import { readMallIdFromUrl } from '@tbox.cn/app-contracts-mall';
5
+ import { MemberGateSheet } from './components/MemberGateSheet';
6
+ import { selectLatestMemberGateCard } from './components/MemberGateSheet/model';
7
+ import { createMemberGate, useMemberGate } from './member-gate';
8
+ import { directLoginGate } from './mock-direct-gate';
9
+ import { loadLinkedPanelState, pickMallId } from './home-runtime';
10
+
11
+ const gateLogger = createLogger('MEMBER-GATE');
12
+ const ignorePanelRefresh = () => {};
13
+
14
+ export function useMemberGateController(refreshPanel = ignorePanelRefresh) {
15
+ const store = useChatStoreApi();
16
+ const messages = useChatStore((s) => s.messages);
17
+ const orphanCards = useChatStore((s) => s.orphanCards);
18
+ const cardsByMessageId = useChatStore((s) => s.cardsByMessageId);
19
+ const isGenerating = useChatStore((s) => s.isGenerating);
20
+ const gateCard = useMemo(
21
+ () => selectLatestMemberGateCard(messages.map((message) => message.id), cardsByMessageId, orphanCards),
22
+ [messages, cardsByMessageId, orphanCards],
23
+ );
24
+
25
+ // 会员门禁状态机(deps 全注入 store/平台面;实例单建——store 方法经 getState 现取)
26
+ const gate = useMemo(
27
+ () =>
28
+ createMemberGate({
29
+ // 壳内走桥(容器 mock-enrollment/真实厂商 gate 页);非壳(扫码直开/浏览器)走 H5 直连 mock 入会
30
+ getLoginState: (params) => (isInAlipayShell() ? getLoginState(params) : directLoginGate()),
31
+ retryBootstrap: (refreshAuth) => store.getState().retryBootstrap(refreshAuth),
32
+ loadPanel: async (panelMallId) => {
33
+ const panel = await loadLinkedPanelState(getAuthClient(), panelMallId, fetch);
34
+ return { member: { status: panel.member.status } };
35
+ },
36
+ waitForSocketOpen,
37
+ getAuthState: () => getAuthClient().getAuthState(),
38
+ sendMessage: (input) => store.getState().sendMessage(input),
39
+ sendUiAction: (surfaceId, action) => store.getState().sendUiAction(surfaceId, action),
40
+ hideCard: (cardId) => store.getState().hideCard(cardId),
41
+ toast: (content) => {
42
+ void toast(content);
43
+ },
44
+ isGenerating: () => store.getState().isGenerating,
45
+ lastUserMessage: () => {
46
+ const live = store.getState().messages;
47
+ for (let i = live.length - 1; i >= 0; i -= 1) {
48
+ if (live[i]?.role === 'user') return { id: live[i].id, content: live[i].content };
49
+ }
50
+ return null;
51
+ },
52
+ readMallId: () =>
53
+ pickMallId(store.getState().helloAck?.mallScope?.mallId, readMallIdFromUrl()),
54
+ refreshPanel,
55
+ log: (message) => {
56
+ gateLogger.info(message);
57
+ },
58
+ }),
59
+ [store, refreshPanel],
60
+ );
61
+ const gateState = useMemberGate(gate);
62
+
63
+ // 门禁卡到达 → 武装浮层(飞轮中忽略;同卡不重复;replayQuery 缺省取触发原话)
64
+ useEffect(() => {
65
+ if (!gateCard) return;
66
+ const { phase, card } = gate.getState();
67
+ if (phase === 'opening' || phase === 'syncing') return;
68
+ if (card?.id === gateCard.id) return;
69
+ gate.trigger(gateCard, undefined);
70
+ }, [gateCard, gate, gateState.phase]);
71
+
72
+ return { gate, gateState, isGenerating };
73
+ }
74
+
75
+ export function MemberGateOverlay() {
76
+ const { gate, gateState, isGenerating } = useMemberGateController();
77
+ if (!gateState.sheetVisible || !gateState.card) return null;
78
+ return (
79
+ <MemberGateSheet
80
+ context={gateState.card}
81
+ phase={gateState.phase}
82
+ message={gateState.message}
83
+ busy={isGenerating}
84
+ onConfirm={() => gate.confirm()}
85
+ onRetry={() => gate.retry()}
86
+ onDismiss={() => gate.dismiss()}
87
+ />
88
+ );
89
+ }
@@ -48,7 +48,7 @@ type BumpinPorts = {
48
48
 
49
49
  function warnUnassembled(specifier: string, e: unknown): void {
50
50
  portsLogger.warn(
51
- 'module ports 未装配(npx --yes @tbox.cn/app-cli module add 后生效)',
51
+ 'module ports 未装配(pnpm exec tbox-app module add 后生效)',
52
52
  specifier,
53
53
  String((e as Error)?.message ?? e).slice(0, 120),
54
54
  );
package/tbox.module.json CHANGED
@@ -2,8 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "module-mall-core",
4
4
  "name": "商圈基础",
5
- "description": "提供商场首页、基础信息和支付宝登录,并汇总会员及停车服务状态",
6
- "version": "0.3.0",
5
+ "description": "提供商场基础信息、支付宝登录和会员会话浮层,以及会员及停车状态查询接口",
7
6
  "kind": "business",
8
7
  "risk": {
9
8
  "level": "medium",
@@ -132,6 +132,9 @@ describe('MemberGateSheet', () => {
132
132
  act(() => (actions[1] as HTMLButtonElement).click());
133
133
  expect(onRetry).toHaveBeenCalledTimes(1);
134
134
  act(() => (actions[0] as HTMLButtonElement).click());
135
+ const closingSheet = document.body.querySelector('.member-login-sheet') as HTMLElement;
136
+ expect(closingSheet.getAttribute('data-state')).toBe('closed');
137
+ act(() => closingSheet.dispatchEvent(new Event('animationend', { bubbles: true })));
135
138
  expect(onDismiss).toHaveBeenCalledTimes(1);
136
139
 
137
140
  // login 卡型的终态标题区分
@@ -154,6 +157,9 @@ describe('MemberGateSheet', () => {
154
157
 
155
158
  const close = document.body.querySelector('[aria-label="关闭登录提示"]') as HTMLButtonElement;
156
159
  act(() => close.click());
160
+ const sheet = document.body.querySelector('.member-login-sheet') as HTMLElement;
161
+ expect(sheet.getAttribute('data-state')).toBe('closed');
162
+ act(() => sheet.dispatchEvent(new Event('animationend', { bubbles: true })));
157
163
  expect(onDismiss).toHaveBeenCalledTimes(1);
158
164
  });
159
165
 
@@ -163,6 +169,9 @@ describe('MemberGateSheet', () => {
163
169
 
164
170
  act(() => document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })));
165
171
  expect(document.body.querySelector('[role="alertdialog"]')).toBeNull();
172
+ const sheet = document.body.querySelector('.member-login-sheet') as HTMLElement;
173
+ expect(sheet.getAttribute('data-state')).toBe('closed');
174
+ act(() => sheet.dispatchEvent(new Event('animationend', { bubbles: true })));
166
175
  expect(onDismiss).toHaveBeenCalledTimes(1);
167
176
 
168
177
  act(() => root.unmount());