@tbox.cn/app-agent-ui-kit 1.0.0-alpha.19 → 1.0.0-alpha.21

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-agent-ui-kit",
3
- "version": "1.0.0-alpha.19",
3
+ "version": "1.0.0-alpha.21",
4
4
  "type": "module",
5
5
  "description": "Agent 对话壳 UI 组件包(源码发布,单一模板统一化 W2-1):ChatPage/壳组件族/主题 tokens。",
6
6
  "exports": {
@@ -44,8 +44,8 @@
44
44
  "remark-gfm": "4.0.1",
45
45
  "yet-another-react-lightbox": "3.33.1",
46
46
  "zustand": "4.5.7",
47
- "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.19",
48
- "@tbox.cn/app-contracts": "1.0.0-alpha.19"
47
+ "@tbox.cn/app-contracts": "1.0.0-alpha.21",
48
+ "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.21"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "18.3.1",
package/src/ChatPage.tsx CHANGED
@@ -18,6 +18,7 @@ import HistoryEntry from './components/HistoryEntry';
18
18
  import { HistoryList } from './components/HistoryList';
19
19
  import { MessageBubble } from './components/MessageBubble';
20
20
  import { QuickCommands } from './components/QuickCommands';
21
+ import { StarterQuestions } from './components/StarterQuestions';
21
22
  import ScrollToBottomButton from './components/ScrollToBottomButton';
22
23
  import { useChatConfigStore } from './chat-config';
23
24
  import { useStickToBottom } from './hooks/use-stick-to-bottom';
@@ -53,6 +54,12 @@ export interface ChatPageProps {
53
54
  *
54
55
  * 为什么颜色必须在这里给:`@layer base` 的选择器压不过 `utilities` 层
55
56
  * (层序优先于特异性),把 `color` 写在 base.css 里会被 `text-foreground` 无条件覆盖。
57
+ *
58
+ * 几何栅格(2026-11):brand/subtle 是实体圆角卡,必须与快捷入口/消息行共一条 16px
59
+ * 水平基准线(缺 `mx-page` 会 0px 贴屏边——真实构建 case 实测);`py-5` 保住最小垂直
60
+ * 内距,防应用层把副标题压到贴底。default 是透明文字态,保留出厂全宽 + 原垂直距。
61
+ * 垂直内距收进本函数而非 JSX 固定段:brand/subtle 的 `py-5` 若与固定 `pb-4 pt-6`
62
+ * 同串冲突,Tailwind 同特异性按生成序裁决、行为不可预期。
56
63
  */
57
64
  export function welcomeSurfaceClasses(surface: 'default' | 'brand' | 'subtle' = 'default'): {
58
65
  container: string;
@@ -62,10 +69,10 @@ export function welcomeSurfaceClasses(surface: 'default' | 'brand' | 'subtle' =
62
69
  return {
63
70
  container:
64
71
  surface === 'brand'
65
- ? 'chat-page__welcome--brand'
72
+ ? 'chat-page__welcome--brand mx-page mt-3 py-5'
66
73
  : surface === 'subtle'
67
- ? 'chat-page__welcome--subtle bg-card border border-border shadow-sm'
68
- : '',
74
+ ? 'chat-page__welcome--subtle mx-page mt-3 py-5 bg-card border border-border shadow-sm'
75
+ : 'pb-4 pt-6',
69
76
  title: surface === 'brand' ? 'text-primary-foreground' : 'text-foreground',
70
77
  subtitle: surface === 'brand' ? 'text-primary-foreground' : 'text-muted-foreground',
71
78
  };
@@ -121,6 +128,14 @@ function ChatPageInner() {
121
128
 
122
129
  const slots = useClientSlots();
123
130
  const homeSlot = slots?.resolve('home');
131
+ // home 槽元信息(2026-11):裸函数注册缺省 persistent + bleed 完全兼容存量域模块(MallHome);
132
+ // home add 复制件推荐 home-only + inset:对话后自动收起 + 壳统一 16px 屏边距。
133
+ const homeMeta = slots?.resolveMeta?.('home') ?? undefined;
134
+ const homeLifecycle = homeMeta?.lifecycle ?? 'persistent';
135
+ const homeGutter = homeMeta?.gutter ?? 'bleed';
136
+ const homeHideBottomQuickCommands = homeMeta?.hideBottomQuickCommands ?? (homeLifecycle === 'home-only');
137
+ const starterQuestions = useChatConfigStore((s) => s.starterQuestions);
138
+ const sendUiAction = useChatStore((s) => s.sendUiAction);
124
139
  // 主题在应用挂载前就位,布局从首帧起固定。
125
140
  const [compactLayout] = useState(() => typeof window !== 'undefined'
126
141
  && window.getComputedStyle(document.documentElement).getPropertyValue('--tbox-compact-chat').trim() === '1');
@@ -326,9 +341,16 @@ function ChatPageInner() {
326
341
  }, [lastTimelineId]);
327
342
 
328
343
  const showHistoryEntry = historyHasMore && historyMessages.length === 0;
344
+ // home-only 首页与欢迎区同门控(空会话挂载、进对话卸载);persistent 由域自持显隐(MallHome 形态)。
345
+ const mountHome = Boolean(homeSlot) && (homeLifecycle === 'persistent' || showHome);
346
+ // 首页外链桥(探针/SSR/运行态同构的关键):Home 复制件经 shared/actions 直连,不再耦合 @/store/chat。
347
+ const handleHomeOpenLink = useCallback((url: string) => {
348
+ void sendUiAction('home', { type: 'openLink', url });
349
+ }, [sendUiAction]);
329
350
  // 欢迎区是身份的唯一位:身份写进 welcome.title / subtitle,壳不再有页头
330
351
  const welcomeTitle = welcome?.title ?? '开始对话';
331
352
  const welcomeSubtitle = welcome?.subtitle ?? '可以直接提问,也可以从下面的问题开始';
353
+ const welcomeBadge = welcome?.badge;
332
354
  // 欢迎区表面:brand = 品牌深色渐变(迎宾感),subtle = 弱化描边;都只消费既有主题变量。
333
355
  const welcomeSurfaceClass = welcomeSurfaceClasses(welcome?.surface ?? 'default');
334
356
  // 仅无 home 槽的纯对话欢迎态在正文内用两列网格;
@@ -396,18 +418,25 @@ function ChatPageInner() {
396
418
 
397
419
  <HistoryList messages={historyMessages} scrollRef={bodyRef} />
398
420
 
399
- {/* 空会话欢迎区:没有 home 槽时的首屏落点(文案来自 chat.json welcome) */}
421
+ {/* 空会话欢迎区:没有 home 槽时的首屏落点(文案来自 chat.json welcome)。
422
+ 垂直内距由 surface 类给(default=pb-4 pt-6 / brand|subtle=py-5):避免同串冲突。 */}
400
423
  {showWelcome ? (
401
- <div className={`chat-page__welcome flex flex-col items-center justify-center gap-2 px-page pb-4 pt-6 text-center ${welcomeSurfaceClass.container}`}>
424
+ <div className={`chat-page__welcome flex flex-col items-center justify-center gap-2 px-page text-center ${welcomeSurfaceClass.container}`}>
425
+ {welcomeBadge ? <span className={`chat-page__welcome-badge m-0 self-center rounded-full border px-2.5 py-0.5 text-xs font-medium tracking-wide ${welcomeSurfaceClass.subtitle}`}>{welcomeBadge}</span> : null}
402
426
  <h2 className={`chat-page__welcome-title m-0 text-xl font-bold ${welcomeSurfaceClass.title}`}>{welcomeTitle}</h2>
403
427
  {welcomeSubtitle ? <p className={`chat-page__welcome-subtitle m-0 text-sm leading-normal ${welcomeSurfaceClass.subtitle}`}>{welcomeSubtitle}</p> : null}
404
428
  </div>
405
429
  ) : null}
406
430
 
407
- {/* home 槽渲染位(域自持显隐;缺席则不渲染)。flow-root 让首页子元素
408
- 的外边距留在槽内,不折叠到历史入口与首页之间。 */}
409
- <div className="chat-page__home-slot flow-root">
410
- {homeSlot?.({ onSend: send, ...(mallName ? { mallName } : {}) })}
431
+ {/* home 槽渲染位。显隐按 HomeSlotMeta:home-only 随空会话挂载/卸载,
432
+ persistent(MallHome 形态)恒挂载由域自持;gutter=inset 时壳统一补 px-page。 */}
433
+ <div className={`chat-page__home-slot flow-root${homeGutter === 'inset' ? ' px-page' : ''}`}>
434
+ {mountHome ? homeSlot?.({
435
+ onSend: send,
436
+ onOpenLink: handleHomeOpenLink,
437
+ visible: showHome,
438
+ ...(mallName ? { mallName } : {}),
439
+ }) : null}
411
440
  </div>
412
441
 
413
442
  {!blocked && showGridCommands ? (
@@ -416,6 +445,12 @@ function ChatPageInner() {
416
445
  </div>
417
446
  ) : null}
418
447
 
448
+ {/* L0「猜你想问」:空态渲染在快捷入口下方、对话开始自动随欢迎态收起
449
+ (chat.json starterQuestions;组件自带换一换分页,无配置项即不渲染)。 */}
450
+ {showWelcome && (starterQuestions?.items?.length ?? 0) > 0 ? (
451
+ <StarterQuestions onCommand={send} />
452
+ ) : null}
453
+
419
454
  {/* 业务旁路 emit 的卡片(如欢迎卡):placement 缺省/top */}
420
455
  {topCards.map((card) => (
421
456
  <div key={card.id} className="chat-page__orphan-card mx-page">
@@ -469,9 +504,11 @@ function ChatPageInner() {
469
504
  <ScrollToBottomButton visible={stick.showJump} onClick={scrollToBottom} />
470
505
  </div>
471
506
 
472
- {/* 有 home 槽的首页和对话态共用输入框上方的快捷胶囊,随输入区一起测量。 */}
507
+ {/* 有 home 槽的首页和对话态共用输入框上方的快捷胶囊,随输入区一起测量。
508
+ 首页声明 hideBottomQuickCommands(home-only 缺省 true)时空态不双显——
509
+ 首页服务卡与底部胶囊内容高度重叠是真实构建实测的体验缺陷。 */}
473
510
  <div ref={chatBottomRef}>
474
- {!blocked && !showGridCommands && <QuickCommands variant={compactLayout ? 'compact' : 'row'} hidden={voiceActive} onCommand={send} />}
511
+ {!blocked && !showGridCommands && !(showHome && homeHideBottomQuickCommands) && <QuickCommands variant={compactLayout ? 'compact' : 'row'} hidden={voiceActive} onCommand={send} />}
475
512
  <ChatInput
476
513
  compact={compactLayout}
477
514
  generating={isGenerating}
@@ -203,10 +203,11 @@ const BUTTON_VARIANT = {
203
203
  link: 'w-auto border-0 bg-transparent font-medium text-primary',
204
204
  } as const;
205
205
 
206
- /** 尺寸档:`sm` 只压视觉,命中区仍由 `min-h-11` 保证 ≥44px。 */
206
+ /** 尺寸档:`sm` 只压视觉,命中区仍由 `min-h-11 min-w-11` 保证 ≥44×44px;
207
+ * `w-full` 变体宽度天然覆盖;收缩槽(Ticket 右侧等)里 2 字中文按钮也因此不再缩到 40px。 */
207
208
  const BUTTON_SIZE = {
208
- md: 'min-h-11 px-4 py-2.5 text-sm',
209
- sm: 'min-h-11 px-3 py-1.5 text-xs',
209
+ md: 'min-h-11 min-w-11 px-4 py-2.5 text-sm',
210
+ sm: 'min-h-11 min-w-11 px-3 py-1.5 text-xs',
210
211
  } as const;
211
212
 
212
213
  /** `link` 变体的内距单独给:它不是胶囊,用胶囊内距会撑出一大块空白。 */
@@ -353,20 +354,34 @@ export interface TicketProps {
353
354
  tone?: 'primary' | 'muted';
354
355
  }
355
356
 
356
- /** 票券形:券、凭证、卡包条目。 */
357
+ /**
358
+ * 票券形:券、凭证、卡包条目。
359
+ *
360
+ * 两层布局(2026-11):左面额竖列(票根虚线分隔)+ 右侧上下两层——顶层「券名(两行截断)+
361
+ * 状态胶囊」、底层「说明 + 动作」。原四栏同排在 320px 宽度下券名仅剩 ~76px(窄屏 9 字
362
+ * 券名必截断、2 字按钮触区缩水);双层把券名行宽让到 status 左侧全量,动作行独立保障命中区。
363
+ */
357
364
  export function Ticket({ amount, title, condition, meta, status, action, tone = 'primary' }: TicketProps) {
358
365
  return (
359
- <div className={`tbox-ticket tbox-ticket--${tone} flex items-center gap-2.5 rounded-lg border border-dashed p-3 ${TICKET_TONE[tone]}`}>
360
- <div className="tbox-ticket__main flex shrink-0 flex-col gap-1">
361
- <span className={`tbox-ticket__amount text-2xl font-bold ${tone === 'muted' ? 'text-muted-foreground' : 'text-primary'}`}>{amount}</span>
362
- {condition ? <span className="tbox-ticket__condition text-xs text-secondary-foreground">{condition}</span> : null}
366
+ <div className={`tbox-ticket tbox-ticket--${tone} flex items-stretch gap-3 rounded-lg border border-dashed p-3 ${TICKET_TONE[tone]}`}>
367
+ <div className="tbox-ticket__main flex shrink-0 flex-col justify-center gap-0.5 border-r border-dashed border-border pr-2.5 text-center">
368
+ <span className={`tbox-ticket__amount whitespace-nowrap text-xl font-bold tabular-nums leading-tight ${tone === 'muted' ? 'text-muted-foreground' : 'text-primary'}`}>{amount}</span>
369
+ {condition ? <span className="tbox-ticket__condition text-xs leading-snug text-secondary-foreground">{condition}</span> : null}
363
370
  </div>
364
- <div className="tbox-ticket__body min-w-0 flex-1">
365
- {title ? <div className="tbox-ticket__title text-sm font-semibold text-foreground">{title}</div> : null}
366
- {meta ? <div className="tbox-ticket__meta min-w-0 text-xs text-muted-foreground">{meta}</div> : null}
371
+ <div className="tbox-ticket__body flex min-w-0 flex-1 flex-col justify-center gap-1.5">
372
+ {title || status ? (
373
+ <div className="flex items-start justify-between gap-2">
374
+ {title ? <div className="tbox-ticket__title min-w-0 flex-1 line-clamp-2 text-sm font-semibold leading-snug text-foreground">{title}</div> : null}
375
+ {status ? <div className="tbox-ticket__status shrink-0">{status}</div> : null}
376
+ </div>
377
+ ) : null}
378
+ {meta || action ? (
379
+ <div className="flex items-center justify-between gap-2">
380
+ {meta ? <div className="tbox-ticket__meta min-w-0 flex-1 text-xs leading-snug text-muted-foreground">{meta}</div> : null}
381
+ {action ? <div className="tbox-ticket__action shrink-0">{action}</div> : null}
382
+ </div>
383
+ ) : null}
367
384
  </div>
368
- {status ? <div className="tbox-ticket__status shrink-0">{status}</div> : null}
369
- {action ? <div className="tbox-ticket__action shrink-0">{action}</div> : null}
370
385
  </div>
371
386
  );
372
387
  }
@@ -473,13 +488,19 @@ export interface StatItem {
473
488
  hint?: ReactNode;
474
489
  }
475
490
 
476
- /** 并列数值格(两到三格):积分/余额、车位/时长。 */
491
+ /**
492
+ * 并列数值格(两到四格):积分/余额、车位/时长、行程 KPI。
493
+ *
494
+ * 四格在窄视口(<sm)折 2×2:flex 等分下每格内宽仅 ~57px,「¥238/人」这类带单位
495
+ * 数值必折行(真实构建实测);sm 视口起飞回 4 列。数值一律 tabular-nums + 不折行。
496
+ */
477
497
  export function StatGrid({ items }: { items: StatItem[] }) {
498
+ const grid = items.length >= 4 ? 'grid grid-cols-2 gap-1.5 sm:grid-cols-4' : 'flex gap-1.5';
478
499
  return (
479
- <div className="tbox-stats flex gap-1.5">
500
+ <div className={`tbox-stats ${grid}`}>
480
501
  {items.map((item, index) => (
481
- <div className="tbox-stats__item flex flex-1 flex-col gap-1 rounded-md bg-muted p-2.5 text-center" key={index}>
482
- <span className="tbox-stats__value text-lg font-bold text-foreground">{item.value}</span>
502
+ <div className="tbox-stats__item flex min-w-0 flex-1 flex-col gap-1 rounded-md bg-muted p-2.5 text-center" key={index}>
503
+ <span className="tbox-stats__value whitespace-nowrap tabular-nums text-lg font-bold text-foreground">{item.value}</span>
483
504
  <span className="tbox-stats__label text-xs text-muted-foreground">{item.label}</span>
484
505
  {item.hint ? <span className="tbox-stats__hint text-xs text-secondary-foreground">{item.hint}</span> : null}
485
506
  </div>
@@ -222,6 +222,9 @@ function renderBlock(
222
222
  case 'list':
223
223
  return (
224
224
  <div className="tbox-view-list flex flex-col gap-2.5">
225
+ {block.title ? (
226
+ <div className="tbox-view-list__title text-xs font-medium tracking-wide text-muted-foreground">{block.title}</div>
227
+ ) : null}
225
228
  {block.items.map((item, index) => (
226
229
  <EntityRow
227
230
  key={item.title + '-' + index}
@@ -296,7 +299,7 @@ export function ViewCard({
296
299
  }) {
297
300
  let safeView: CardView;
298
301
  try {
299
- safeView = normalizeCardView(view);
302
+ safeView = normalizeCardView(view, { emptyMode: 'drop' });
300
303
  } catch {
301
304
  return (
302
305
  <Card>
@@ -11,7 +11,7 @@ const reset = () => {
11
11
  quickCommands: [],
12
12
  retryOnError: true,
13
13
  });
14
- useChatConfigStore.setState({ welcome: undefined });
14
+ useChatConfigStore.setState({ welcome: undefined, starterQuestions: undefined });
15
15
  };
16
16
 
17
17
  describe('chat 设置的构建期快照', () => {
@@ -48,4 +48,22 @@ describe('chat 设置的构建期快照', () => {
48
48
  const state = useChatConfigStore.getState() as unknown as Record<string, unknown>;
49
49
  expect('identity' in state).toBe(false);
50
50
  });
51
+
52
+ it('L0 声明式首页:welcome.badge + starterQuestions 随快照注入且不改缺省(2026-11)', () => {
53
+ reset();
54
+ configureChatConfigDefaults({
55
+ welcome: { title: '小满客服', subtitle: '订单物流都能问我', surface: 'brand', badge: '7×24 智能售后' },
56
+ starterQuestions: { title: '猜你想问', pageSize: 3, items: [{ label: '我的订单到哪了?' }, { label: '申请退款', query: '我想申请退款' }] },
57
+ });
58
+ const state = useChatConfigStore.getState();
59
+ expect(state.welcome?.badge).toBe('7×24 智能售后');
60
+ expect(state.starterQuestions?.items).toHaveLength(2);
61
+ expect(state.starterQuestions?.items[0]?.query).toBeUndefined();
62
+ expect(state.starterQuestions?.items[1]?.query).toBe('我想申请退款');
63
+ });
64
+
65
+ it('starterQuestions 缺省为 undefined(无配置零渲染)', () => {
66
+ reset();
67
+ expect(useChatConfigStore.getState().starterQuestions).toBeUndefined();
68
+ });
51
69
  });
@@ -9,17 +9,35 @@ import { create } from 'zustand';
9
9
  import type { ChatUiSettings } from '@tbox.cn/app-agent-sdk-client';
10
10
 
11
11
  export interface QuickCommand {
12
- /** 纯文案;前导星标/图标由 QuickCommands 组件渲染,不要写进 label */
12
+ /** 纯文案;前导星标/图标由 QuickCommands 组件渲染,不要写进 label(两列网格建议 2–8 字) */
13
13
  label: string;
14
14
  query: string;
15
15
  icon?: string;
16
+ /**
17
+ * 可选短副文案(≤24 字):空态首屏把快捷项升级为两列服务卡(图标托盘 + 标题 + 副文案),
18
+ * 对话态自动收敛回单行胶囊——同一份配置双态复用,零重复维护(2026-11 L0 声明式首页)。
19
+ */
20
+ description?: string;
16
21
  }
17
22
 
23
+ /** 空态「猜你想问」条目(chat.json starterQuestions.items) */
24
+ export interface StarterQuestionItem {
25
+ label: string;
26
+ /** 缺省点击发送 label 原文 */
27
+ query?: string;
28
+ }
18
29
 
30
+ export interface ChatStarterQuestions {
31
+ title?: string;
32
+ pageSize?: number;
33
+ items: StarterQuestionItem[];
34
+ }
19
35
 
20
36
  export interface ChatWelcome {
21
37
  title: string;
22
38
  subtitle?: string;
39
+ /** 顶部短身份角标(≤16 字) */
40
+ badge?: string;
23
41
  /** 欢迎区表面变体(只消费既有主题变量;缺省 default) */
24
42
  surface?: 'default' | 'brand' | 'subtle';
25
43
  }
@@ -37,6 +55,8 @@ interface ChatConfigStore {
37
55
  inputMaxRows: number;
38
56
  /** 欢迎区是构建期展示配置,不经 HELLO_ACK 水合 */
39
57
  welcome?: ChatWelcome;
58
+ /** 空态「猜你想问」是构建期展示配置(L0 首页),不经 HELLO_ACK 水合 */
59
+ starterQuestions?: ChatStarterQuestions;
40
60
  retryOnError: boolean;
41
61
  /** HELLO_ACK settings 水合:服务端单一真源;undefined 键保留构建期快照(五键整组语义,禁部分水合) */
42
62
  applyServerSettings: (settings: ChatUiSettings | undefined) => void;
@@ -55,6 +75,7 @@ export const useChatConfigStore = create<ChatConfigStore>()((set) => ({
55
75
  inputMinRows: 1,
56
76
  inputMaxRows: 4,
57
77
  welcome: ssrSnapshot['welcome'] as ChatWelcome | undefined,
78
+ starterQuestions: ssrSnapshot['starterQuestions'] as ChatStarterQuestions | undefined,
58
79
  retryOnError: true,
59
80
  applyServerSettings: (settings) =>
60
81
  set((cur) => ({
@@ -102,6 +123,7 @@ export function configureChatConfigDefaults(snapshot: Record<string, unknown> |
102
123
  inputMinRows: readRows(snapshot['input'], 'minRows') ?? cur.inputMinRows,
103
124
  inputMaxRows: readRows(snapshot['input'], 'maxRows') ?? cur.inputMaxRows,
104
125
  welcome: (snapshot['welcome'] as ChatWelcome | undefined) ?? cur.welcome,
126
+ starterQuestions: (snapshot['starterQuestions'] as ChatStarterQuestions | undefined) ?? cur.starterQuestions,
105
127
  retryOnError: (snapshot['retryOnError'] as boolean | undefined) ?? cur.retryOnError,
106
128
  }));
107
129
  }
@@ -118,4 +118,59 @@ describe('QuickCommands 快捷胶囊', () => {
118
118
  expect(buttons[1]?.querySelector('img')?.getAttribute('src')).toBe(STATIC_COMMANDS[1].icon);
119
119
  expect(buttons[2]?.querySelector('svg[aria-hidden="true"]')).not.toBeNull();
120
120
  });
121
+
122
+ it('L0 服务卡模式:带 description 时升级为图标托盘 + 标题/副文案,奇数末项跨两列不落单', () => {
123
+ configureChatConfigDefaults({
124
+ quickCommands: [
125
+ { label: '查订单物流', query: '帮我查询最近的订单物流', icon: 'icon:receipt', description: '实时轨迹与签收状态' },
126
+ { label: '申请退换货', query: '我想申请退换货', icon: 'icon:gift', description: '签收后 7 天可退' },
127
+ { label: '商品咨询', query: '咨询商品规格与库存', icon: 'icon:info', description: '尺寸/材质/发货时效' },
128
+ ],
129
+ });
130
+ const onCommand = vi.fn();
131
+ const container = document.createElement('div');
132
+ document.body.appendChild(container);
133
+ renderWithKit(container, <QuickCommands variant="grid" onCommand={onCommand} />);
134
+
135
+ const buttons = [...container.querySelectorAll('button')];
136
+ expect(buttons).toHaveLength(3);
137
+ // 奇数末项(第 3 个)跨两列:col-span-2 不落单。
138
+ expect(buttons[2].className).toContain('col-span-2');
139
+ // 服务卡形态:图标托盘 + 标题 + 副文案同框。
140
+ expect(buttons[0].textContent).toContain('查订单物流');
141
+ expect(buttons[0].textContent).toContain('实时轨迹与签收状态');
142
+ expect(buttons[0].querySelector('svg[aria-hidden="true"]')).not.toBeNull();
143
+ flushSync(() => buttons[0].click());
144
+ expect(onCommand).toHaveBeenCalledWith('帮我查询最近的订单物流');
145
+ });
146
+
147
+ it('单项服务卡不跨列也不报错(oddTail 需要 >=3 条)', () => {
148
+ configureChatConfigDefaults({
149
+ quickCommands: [
150
+ { label: '唯一服务', query: '唯一的完整问句', icon: 'icon:storefront', description: '只有一项' },
151
+ ],
152
+ });
153
+ const container = document.createElement('div');
154
+ document.body.appendChild(container);
155
+ renderWithKit(container, <QuickCommands variant="grid" onCommand={vi.fn()} />);
156
+ const buttons = [...container.querySelectorAll('button')];
157
+ expect(buttons).toHaveLength(1);
158
+ expect(buttons[0].className).not.toContain('col-span-2');
159
+ expect(buttons[0].textContent).toContain('只有一项');
160
+ });
161
+
162
+ it('无 description 的网格保持胶囊形态,不受 L0 服务卡分支影响', () => {
163
+ configureChatConfigDefaults({
164
+ quickCommands: [
165
+ { label: '停车缴费', query: '查询停车费并缴费' },
166
+ { label: '碰一下入会', query: '碰一下入会', icon: 'icon:qr-code' },
167
+ ],
168
+ });
169
+ const container = document.createElement('div');
170
+ document.body.appendChild(container);
171
+ renderWithKit(container, <QuickCommands variant="grid" onCommand={vi.fn()} />);
172
+ const buttons = [...container.querySelectorAll('button')];
173
+ expect(buttons[0].className).not.toContain('col-span-2');
174
+ expect(buttons[1].querySelector('svg[aria-hidden="true"]')).not.toBeNull();
175
+ });
121
176
  });
@@ -1,20 +1,59 @@
1
1
  // 服务端 HelloAck.chatConfig.quickCommands 优先;旧服务端缺省 icon 时按 label 合并本地配置。
2
2
  // label 只写纯文字;前面的星标由本组件渲染(icon 字段或默认 ✦),不要把 ✦/emoji 写进 label。
3
3
  //
4
- // 欢迎区用两列;主题选择紧凑布局时输入区使用紧凑单行。
4
+ // 欢迎区用两列(条目带 description 时自动升级为「图标托盘 + 标题 + 副文案」服务卡,
5
+ // 奇数末项跨两列不落单——2026-11 L0 声明式首页);主题选择紧凑布局时输入区使用紧凑单行。
5
6
  import { useEffect, useRef, useState } from 'react';
6
7
  import { useChatConfigStore } from '../../chat-config';
7
- import { Calendar } from '../../icons';
8
+ import {
9
+ Calendar,
10
+ Clock,
11
+ Coins,
12
+ CreditCard,
13
+ Gift,
14
+ Info,
15
+ MapPin,
16
+ MapTrifold,
17
+ QrCode,
18
+ Receipt,
19
+ Sparkle,
20
+ Star,
21
+ Storefront,
22
+ Ticket,
23
+ User,
24
+ Warning,
25
+ } from '../../icons';
8
26
  import { useChatStore } from '../../store-context';
9
27
  import starIcon from '../../../assets/quick-command-star.svg';
10
28
 
11
- function QuickCommandIcon({ icon }: { icon?: string }) {
12
- if (icon === 'icon:calendar') {
13
- return <Calendar size={16} weight="fill" className="quick-commands__icon shrink-0 text-secondary-foreground" aria-hidden="true" />;
29
+ /** chat.json `icon:*` 内置语义图标白名单(服务端 quickCommands[].icon 与 starter 同源词表)。 */
30
+ const VECTOR_ICONS = {
31
+ 'icon:calendar': Calendar,
32
+ 'icon:clock': Clock,
33
+ 'icon:coins': Coins,
34
+ 'icon:credit-card': CreditCard,
35
+ 'icon:gift': Gift,
36
+ 'icon:info': Info,
37
+ 'icon:map-pin': MapPin,
38
+ 'icon:map': MapTrifold,
39
+ 'icon:qr-code': QrCode,
40
+ 'icon:receipt': Receipt,
41
+ 'icon:sparkle': Sparkle,
42
+ 'icon:star': Star,
43
+ 'icon:storefront': Storefront,
44
+ 'icon:ticket': Ticket,
45
+ 'icon:user': User,
46
+ 'icon:warning': Warning,
47
+ } as const;
48
+
49
+ function QuickCommandIcon({ icon, sizePx = 16, tone }: { icon?: string; sizePx?: 4 | 5 | 16 | 20; tone?: string }) {
50
+ const VectorIcon = icon ? VECTOR_ICONS[icon as keyof typeof VECTOR_ICONS] : undefined;
51
+ if (VectorIcon) {
52
+ return <VectorIcon size={sizePx} weight="fill" className={`quick-commands__icon shrink-0 ${tone ?? 'text-secondary-foreground'}`} aria-hidden="true" />;
14
53
  }
15
54
  return (
16
55
  <img
17
- className="quick-commands__icon size-4 shrink-0 object-contain"
56
+ className={`quick-commands__icon ${sizePx >= 20 ? 'size-5' : 'size-4'} shrink-0 object-contain`}
18
57
  src={icon || starIcon}
19
58
  alt=""
20
59
  onError={({ currentTarget }) => {
@@ -43,11 +82,18 @@ export function QuickCommands({
43
82
  label: command.label,
44
83
  query: command.prompt,
45
84
  icon: command.icon || staticByLabel.get(command.label)?.icon,
85
+ // description 是构建期展示增强(HELLO_ACK 不投影该字段):按 label 从本地快照兜底。
86
+ description: staticByLabel.get(command.label)?.description,
46
87
  }))
47
88
  : staticCommands;
48
89
  // hooks 必须先于任何 early return(否则空态会触发 hook 数量不一致)。
49
90
  const grid = variant === 'grid';
50
91
  const compact = variant === 'compact';
92
+ // 服务卡模式(L0 声明式首页,2026-11):任一条目带 description 整网格即升级为
93
+ //「图标托盘 + 标题 + 副文案」两列服务卡;对话态(row/compact)自动收敛回单行胶囊——
94
+ // 同一份 quickCommands 双态复用。奇数末项跨两列(col-span-2),网格不落单。
95
+ const serviceMode = grid && commands.some((command) => typeof command.description === 'string' && command.description.length > 0);
96
+ const oddTail = serviceMode && commands.length >= 3 && commands.length % 2 === 1;
51
97
  // 行/紧凑档是横向滚动容器:滚出视口的胶囊没有任何提示。用两侧渐变层给出可滑动暗示
52
98
  //(不用 mask-image —— 无前缀写法在 safari 16.4 基线外,会踩兼容门禁)。
53
99
  const rowRef = useRef<HTMLDivElement>(null);
@@ -74,24 +120,39 @@ export function QuickCommands({
74
120
  if (!commands.length) return null;
75
121
  const buttonStyle = {
76
122
  grid: 'w-full justify-start gap-1.5 rounded-[22px] border border-border bg-card px-3 py-2 text-left shadow-sm active:border-primary',
123
+ gridService: 'flex flex-col items-start gap-2 rounded-2xl border border-border bg-card px-4 py-3.5 text-left shadow-sm active:border-primary',
77
124
  row: 'flex-[1_0_auto] justify-center gap-1.5 rounded-[22px] border border-border bg-card px-3 py-2 shadow-sm active:border-primary',
78
125
  compact: 'relative isolate flex-[1_0_auto] justify-center gap-[5px] rounded-full border-0 bg-transparent px-3 before:pointer-events-none before:absolute before:inset-x-0 before:inset-y-[5px] before:-z-10 before:rounded-full before:border before:border-border before:bg-card before:shadow-[0_4px_16px_rgba(38,59,92,0.05)] before:transition-colors active:before:border-primary',
79
- }[variant];
126
+ }[serviceMode ? 'gridService' : variant];
80
127
  // 外层保存 `.quick-commands`(壳契约与紧凑布局的相邻兄弟断言都按它取),
81
128
  // 内层 `.quick-commands__scroll` 只负责横向滚动。
82
129
  // row 变体的 shadow-sm(0 4px 13px)直接画在 44px 按钮外框上,overflow-x-auto 会隐式裁切垂直溢出:
83
130
  // 顶部留 pt-2(8px)防上沿贴边,底部保留 pb-[9px] 容纳下偏移阴影并维持与输入框的原间距;
84
131
  // compact 变体靠 before:inset-y-[5px] 已内置 5px 上下缓冲,pb-1 即等价 9px。
85
132
  const scrollClass = `quick-commands__scroll flex w-full items-center gap-2 overflow-x-auto px-page [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden ${compact ? 'pb-1' : 'pt-2 pb-[9px]'}`;
86
- const buttons = commands.map((cmd) => (
133
+ const buttons = commands.map((cmd, index) => (
87
134
  <button
88
135
  key={cmd.label}
89
- className={`quick-commands__item inline-flex min-h-11 appearance-none items-center text-foreground transition-colors duration-[var(--tbox-motion-duration-fast)] ease-[var(--tbox-motion-easing-standard)] ${buttonStyle}`}
136
+ className={`quick-commands__item inline-flex min-h-11 appearance-none items-center text-foreground transition-colors duration-[var(--tbox-motion-duration-fast)] ease-[var(--tbox-motion-easing-standard)] ${buttonStyle}${oddTail && index === commands.length - 1 ? ' col-span-2' : ''}`}
90
137
  disabled={hidden}
91
138
  onClick={() => onCommand(cmd.query)}
92
139
  >
93
- <QuickCommandIcon icon={cmd.icon} />
94
- <span className={`quick-commands__label text-sm font-medium leading-[18px] text-foreground ${grid ? 'line-clamp-2 text-left' : 'whitespace-nowrap'}`}>{cmd.label}</span>
140
+ {serviceMode ? (
141
+ <>
142
+ <span className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary-soft text-primary">
143
+ <QuickCommandIcon icon={cmd.icon} sizePx={20} tone="text-primary" />
144
+ </span>
145
+ <span className="flex min-w-0 flex-col">
146
+ <span className="quick-commands__label truncate text-sm font-medium text-foreground">{cmd.label}</span>
147
+ <span className="mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground">{cmd.description}</span>
148
+ </span>
149
+ </>
150
+ ) : (
151
+ <>
152
+ <QuickCommandIcon icon={cmd.icon} />
153
+ <span className={`quick-commands__label text-sm font-medium leading-[18px] text-foreground ${grid ? 'line-clamp-2 text-left' : 'whitespace-nowrap'}`}>{cmd.label}</span>
154
+ </>
155
+ )}
95
156
  </button>
96
157
  ));
97
158
  return (
@@ -0,0 +1,115 @@
1
+ // @vitest-environment happy-dom
2
+ /**
3
+ * StarterQuestions 测试(L0 猜你想问,2026-11 评审 P1-4 补齐):
4
+ * 覆盖 default title / query→label 回退 / pageSize clamp / rotate 数学 / canRotate=false。
5
+ */
6
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
7
+ import { createRoot } from 'react-dom/client';
8
+ import { flushSync } from 'react-dom';
9
+ import type { ReactNode } from 'react';
10
+ import { create } from 'zustand';
11
+ import type { CoreChatStore } from '@tbox.cn/app-agent-sdk-client';
12
+ import { configureChatConfigDefaults, useChatConfigStore } from '../../chat-config';
13
+ import { KitChatProvider } from '../../store-context';
14
+ import { StarterQuestions } from './index';
15
+
16
+ const testStore = create<{ helloAck: unknown }>(() => ({ helloAck: null })) as unknown as CoreChatStore;
17
+
18
+ function renderWithKit(container: HTMLElement, node: ReactNode): void {
19
+ flushSync(() => {
20
+ createRoot(container).render(
21
+ <KitChatProvider store={testStore} cards={{}} rawCards={{}}>
22
+ {node}
23
+ </KitChatProvider>,
24
+ );
25
+ });
26
+ }
27
+
28
+ const reset = () => {
29
+ useChatConfigStore.setState({ starterQuestions: undefined });
30
+ };
31
+
32
+ beforeEach(reset);
33
+ afterEach(() => {
34
+ reset();
35
+ document.body.innerHTML = '';
36
+ });
37
+
38
+ describe('StarterQuestions 猜你想问(L0)', () => {
39
+ it('渲染自定义 title,条目点击发送 query;无 query 回退 label 原文', () => {
40
+ configureChatConfigDefaults({
41
+ starterQuestions: {
42
+ title: '常见问题',
43
+ items: [{ label: '订单到哪了?', query: '我的订单到哪了?' }, { label: '怎么申请退款' }],
44
+ },
45
+ });
46
+ const onCommand = vi.fn();
47
+ const container = document.createElement('div');
48
+ document.body.appendChild(container);
49
+ renderWithKit(container, <StarterQuestions onCommand={onCommand} />);
50
+
51
+ expect(container.textContent).toContain('常见问题');
52
+ expect(container.textContent).toContain('订单到哪了?');
53
+ // 3 条以内无换一换
54
+ expect(container.textContent).not.toContain('换一换');
55
+ const [first, second] = [...container.querySelectorAll('button')];
56
+ flushSync(() => first?.click());
57
+ expect(onCommand).toHaveBeenCalledWith('我的订单到哪了?');
58
+ flushSync(() => second?.click());
59
+ expect(onCommand).toHaveBeenCalledWith('怎么申请退款');
60
+ });
61
+
62
+ it('title 缺省为「猜你想问」;超过 pageSize 出现换一换,循环分页跨条目', () => {
63
+ configureChatConfigDefaults({
64
+ starterQuestions: {
65
+ pageSize: 3,
66
+ items: [{ label: '1' }, { label: '2' }, { label: '3' }, { label: '4' }],
67
+ },
68
+ });
69
+ const container = document.createElement('div');
70
+ document.body.appendChild(container);
71
+ renderWithKit(container, <StarterQuestions onCommand={vi.fn()} />);
72
+
73
+ expect(container.textContent).toContain('猜你想问');
74
+ expect(container.textContent).toContain('换一换');
75
+ // 首页 1,2,3;换一换后跨条目(cyclic:4,1,2——原组件族的同语义)。
76
+ expect(container.textContent).toContain('1');
77
+ expect(container.textContent).not.toContain('4');
78
+ const rotate = [...container.querySelectorAll('button')].find((b) => b.textContent?.includes('换一换'));
79
+ flushSync(() => rotate?.click());
80
+ expect(container.textContent).toContain('4');
81
+ });
82
+
83
+ it('pageSize clamp:手工注入的越界值夹到 [2,6](SSR 快照通道不经 zod 校验)', () => {
84
+ configureChatConfigDefaults({
85
+ starterQuestions: { pageSize: 99, items: [{ label: 'a' }, { label: 'b' }, { label: 'c' }, { label: 'd' }, { label: 'e' }, { label: 'f' }, { label: 'g' }] },
86
+ } as never);
87
+ const container = document.createElement('div');
88
+ document.body.appendChild(container);
89
+ renderWithKit(container, <StarterQuestions onCommand={vi.fn()} />);
90
+ // clamp 到 6:首页渲染前 6 条(g 不在首页),且出现换一换。
91
+ expect([...container.querySelectorAll('button')].filter((b) => !b.textContent?.includes('换一换'))).toHaveLength(6);
92
+
93
+ useChatConfigStore.setState({ starterQuestions: { pageSize: 1, items: [{ label: 'x' }, { label: 'y' }, { label: 'z' }] } });
94
+ document.body.innerHTML = '';
95
+ const container2 = document.createElement('div');
96
+ document.body.appendChild(container2);
97
+ renderWithKit(container2, <StarterQuestions onCommand={vi.fn()} />);
98
+ // clamp 到 2:每页 2 条。
99
+ expect([...container2.querySelectorAll('button')].filter((b) => !b.textContent?.includes('换一换'))).toHaveLength(2);
100
+ });
101
+
102
+ it('无配置零渲染;canRotate=false 时不渲染换一换按钮', () => {
103
+ const empty = document.createElement('div');
104
+ document.body.appendChild(empty);
105
+ renderWithKit(empty, <StarterQuestions onCommand={vi.fn()} />);
106
+ expect(empty.firstElementChild).toBeNull();
107
+
108
+ configureChatConfigDefaults({ starterQuestions: { items: [{ label: '只有一个' }] } });
109
+ const container = document.createElement('div');
110
+ document.body.appendChild(container);
111
+ renderWithKit(container, <StarterQuestions onCommand={vi.fn()} />);
112
+ expect(container.textContent).toContain('只有一个');
113
+ expect(container.textContent).not.toContain('换一换');
114
+ });
115
+ });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * 猜你想问(L0 声明式首页,chat.json starterQuestions;2026-11)。
3
+ *
4
+ * - 仅空会话首屏渲染(ChatPage 按 showWelcome 门控),进入对话随欢迎态自动卸载;
5
+ * - 超过 pageSize 自动出现「换一换」(循环分页,不与快捷指令重复——那是服务入口,这是问题推荐);
6
+ * - 全语义令牌 + 44px 触控行 + 内联 phosphor 图标(icons.ts 白名单),零外链零硬编码色。
7
+ */
8
+ import { useState } from 'react';
9
+ import { ArrowsClockwise, CaretRight, Sparkle } from '../../icons';
10
+ import { useChatConfigStore } from '../../chat-config';
11
+
12
+ export function StarterQuestions({ onCommand }: { onCommand: (query: string) => void }) {
13
+ const starterQuestions = useChatConfigStore((s) => s.starterQuestions);
14
+ const [page, setPage] = useState(0);
15
+ const items = starterQuestions?.items ?? [];
16
+ if (items.length === 0) return null;
17
+ const pageSizeRaw = starterQuestions?.pageSize;
18
+ const pageSize = Number.isInteger(pageSizeRaw) && pageSizeRaw !== undefined
19
+ ? Math.min(6, Math.max(2, pageSizeRaw as number))
20
+ : 3;
21
+ const canRotate = items.length > pageSize;
22
+ const shown = canRotate
23
+ ? Array.from({ length: pageSize }, (_, offset) => items[(page * pageSize + offset) % items.length])
24
+ : items;
25
+ const handleRotate = () => {
26
+ setPage((value) => (value + 1) % Math.max(1, Math.ceil(items.length / pageSize)));
27
+ };
28
+ return (
29
+ <section className="chat-page__starter-questions mx-page mt-3 flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs">
30
+ <header className="flex items-center justify-between gap-2">
31
+ <span className="flex min-w-0 items-center gap-1.5 truncate text-base font-semibold text-foreground">
32
+ <Sparkle size={16} weight="fill" className="text-primary" />
33
+ {starterQuestions?.title || '猜你想问'}
34
+ </span>
35
+ {canRotate ? (
36
+ <button
37
+ type="button"
38
+ className="flex min-h-11 shrink-0 cursor-pointer items-center gap-1 rounded-full px-3 text-sm font-medium text-primary active:opacity-80"
39
+ onClick={handleRotate}
40
+ >
41
+ <ArrowsClockwise size={16} className="text-primary" aria-hidden="true" />
42
+ <span className="whitespace-nowrap">换一换</span>
43
+ </button>
44
+ ) : null}
45
+ </header>
46
+ <div className="flex flex-col gap-1.5">
47
+ {shown.map((item, pageIndex) => (
48
+ <button
49
+ key={item.label + '#' + pageIndex}
50
+ type="button"
51
+ className="flex min-h-11 w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-2 text-left active:bg-muted"
52
+ onClick={() => onCommand(item.query?.trim() ? item.query : item.label)}
53
+ >
54
+ <span className="flex min-w-0 flex-1 items-center gap-2 truncate text-sm text-foreground">{item.label}</span>
55
+ <CaretRight size={16} weight="bold" className="shrink-0 text-muted-foreground" />
56
+ </button>
57
+ ))}
58
+ </div>
59
+ </section>
60
+ );
61
+ }
@@ -78,8 +78,20 @@ describe('欢迎区表面(L1)', () => {
78
78
  expect(cls.title).not.toContain('text-foreground');
79
79
  });
80
80
 
81
+ it('实体表面栅格(2026-11):brand/subtle 带 mx-page 屏边距 + mt-3 + py-5 最小垂直内距', () => {
82
+ for (const surface of ['brand', 'subtle'] as const) {
83
+ const cls = welcomeSurfaceClasses(surface);
84
+ expect(cls.container).toContain('mx-page');
85
+ expect(cls.container).toContain('mt-3');
86
+ expect(cls.container).toContain('py-5');
87
+ // 缺 mx-page 时欢迎卡 0px 贴屏边(真实构建 case 实测);不与 pb-4/pt-6 固定段混串。
88
+ expect(cls.container).not.toContain('pb-4');
89
+ expect(cls.container).not.toContain('pt-6');
90
+ }
91
+ });
92
+
81
93
  it('default / subtle:不误伤出厂深色文字', () => {
82
- expect(welcomeSurfaceClasses('default')).toEqual({ container: '', title: 'text-foreground', subtitle: 'text-muted-foreground' });
94
+ expect(welcomeSurfaceClasses('default')).toEqual({ container: 'pb-4 pt-6', title: 'text-foreground', subtitle: 'text-muted-foreground' });
83
95
  const subtle = welcomeSurfaceClasses('subtle');
84
96
  expect(subtle.container).toContain('bg-card');
85
97
  expect(subtle.title).toBe('text-foreground');
@@ -11,7 +11,7 @@
11
11
  "id": "welcome",
12
12
  "area": "welcome",
13
13
  "selector": ".chat-page__welcome",
14
- "drivenBy": ["chat.json welcome.title", "chat.json welcome.subtitle"],
14
+ "drivenBy": ["chat.json welcome.title", "chat.json welcome.subtitle", "chat.json welcome.badge"],
15
15
  "brandable": true
16
16
  },
17
17
  {
@@ -32,7 +32,7 @@
32
32
  "id": "home-slot",
33
33
  "area": "home",
34
34
  "selector": ".chat-page__home-slot",
35
- "drivenBy": ["客户端槽 home"],
35
+ "drivenBy": ["客户端槽 home", "HomeSlotMeta(register 第三参数:lifecycle home-only|persistent / gutter inset|bleed / hideBottomQuickCommands)"],
36
36
  "brandable": false
37
37
  },
38
38
  {
@@ -42,6 +42,13 @@
42
42
  "drivenBy": ["客户端槽 conversationOverlay"],
43
43
  "brandable": false
44
44
  },
45
+ {
46
+ "id": "starter-questions",
47
+ "area": "starter-questions",
48
+ "selector": ".chat-page__starter-questions",
49
+ "drivenBy": ["chat.json starterQuestions.title", "chat.json starterQuestions.pageSize", "chat.json starterQuestions.items[].label/query"],
50
+ "brandable": true
51
+ },
45
52
  {
46
53
  "id": "quick-commands",
47
54
  "area": "quick-commands",
package/src/shell.test.ts CHANGED
@@ -21,6 +21,7 @@ const SELECTOR_SOURCES: Record<string, string[]> = {
21
21
  '.chat-page__body': ['ChatPage.tsx'],
22
22
  '.history-entry': ['components/HistoryEntry/index.tsx'],
23
23
  '.chat-page__home-slot': ['ChatPage.tsx'],
24
+ '.chat-page__starter-questions': ['components/StarterQuestions/index.tsx'],
24
25
  '.chat-page__conversation-overlay': ['ChatPage.tsx'],
25
26
  '.quick-commands': ['components/QuickCommands/index.tsx'],
26
27
  '.tbox-chat-input': ['components/ChatInput/index.tsx'],
@@ -150,13 +150,18 @@
150
150
  (contract.json 是封闭清单,加键即 doctor/主题包门禁报错)。 */
151
151
  .chat-page__welcome--brand {
152
152
  border-radius: var(--tbox-radius-lg);
153
- /* 三停渐变全用现有平台变量(不引 color-mix:兼容门禁要求 color-mix 必须带静态回退)。
154
- 上层叠 18% 黑罩:任何品牌色下 14px 副标题对比度都能到 5:1 以上——
155
- 渐变本身在 primary 停点上只有 4.17:1,不足以承载小字正文。 */
153
+ /* 全用现有平台变量,不引 color-mix(兼容门禁要求 color-mix 必须带静态回退)。
154
+ 文字承载渐变只走 primary-dark → primary 双停(浅字对比度由 shell.contrast 的
155
+ primary-light/primary-dark 对保障);--tbox-accent 降级为右上角低占比径向氛围光晕——
156
+ 浅暖金 accent 直接垫在字下(三停 62%→100% 段)时叠 18% 黑罩仍只有 ~3.1:1
157
+ (真实构建实测),角部化之后文字区对比度与 accent 选色解耦。
158
+ min-height 保住最小迎宾块高度(subtitle 缺席时也不塌成细条)。 */
159
+ min-height: 96px;
156
160
  background-color: var(--tbox-primary-dark);
157
161
  background-image:
158
- linear-gradient(0deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)),
159
- linear-gradient(142deg, var(--tbox-primary-dark) 0%, var(--tbox-primary) 62%, var(--tbox-accent) 100%);
162
+ linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
163
+ radial-gradient(circle at 92% 18%, var(--tbox-accent) 0%, transparent 48%),
164
+ linear-gradient(142deg, var(--tbox-primary-dark) 0%, var(--tbox-primary) 100%);
160
165
  box-shadow: var(--tbox-shadow-md);
161
166
  }
162
167