Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: billboard in sidebar (#13962)

Rdmclin27fe751eaec10
diff --git a/locales/en-US/notification.json b/locales/en-US/notification.json
index 8e8dfe24774..81892314466 100644
--- a/locales/en-US/notification.json
+++ b/locales/en-US/notification.json
@@ -1,4 +1,6 @@
{
+ "billboard.learnMore": "Learn more",
+ "billboard.menuLabel": "Announcements",
"inbox.archiveAll": "Archive all",
"inbox.empty": "No notifications yet",
"inbox.emptyUnread": "No unread notifications",
diff --git a/locales/zh-CN/notification.json b/locales/zh-CN/notification.json
index 4608094defe..e5d7fa43463 100644
--- a/locales/zh-CN/notification.json
+++ b/locales/zh-CN/notification.json
@@ -1,4 +1,6 @@
{
+ "billboard.learnMore": "了解更多",
+ "billboard.menuLabel": "公告",
"inbox.archiveAll": "全部归档",
"inbox.empty": "暂无通知",
"inbox.emptyUnread": "没有未读通知",
diff --git a/packages/edge-config/src/index.ts b/packages/edge-config/src/index.ts
index b34b3958a7d..e98ce4f9ad2 100644
--- a/packages/edge-config/src/index.ts
+++ b/packages/edge-config/src/index.ts
@@ -46,6 +46,12 @@ export class EdgeConfig {
debug('Feature flags retrieved: %O', featureFlags);
return featureFlags;
};
+
+ getBillboards = async () => {
+ const billboards = await this.getValue('billboards');
+ debug('Billboards retrieved: %O', billboards);
+ return billboards;
+ };
}
export * from './types';
diff --git a/packages/edge-config/src/types.ts b/packages/edge-config/src/types.ts
index ba442fc6127..f2e1084a2b0 100644
--- a/packages/edge-config/src/types.ts
+++ b/packages/edge-config/src/types.ts
@@ -1,5 +1,66 @@
import type { BusinessEdgeConfigData } from '@lobechat/business-config/server';
+/**
+ * Billboard 单条 item 的可本地化字段。
+ * cover / linkUrl / 顺序 / 时间窗口不翻译。
+ */
+export interface BillboardItemLocaleFields {
+ description?: string;
+ linkLabel?: string;
+ title?: string;
+}
+
+/**
+ * Billboard 轮播项(Home sidebar 左下角运营卡片的单条内容)
+ */
+export interface BillboardItem {
+ cover?: string | null;
+ description: string;
+ /**
+ * 每个 locale 的覆盖文案。缺失时回退到默认字段(title / description / linkLabel)。
+ * key 采用 LobeHub locale code(如 `zh-CN`、`en-US`、`ja-JP`)。
+ */
+ i18n?: Record<string, BillboardItemLocaleFields>;
+ id: number;
+ linkLabel?: string | null;
+ linkUrl?: string | null;
+ title: string;
+}
+
+/**
+ * Billboard 级别的可本地化字段(当前仅 title)。
+ */
+export interface BillboardLocaleFields {
+ title?: string;
+}
+
+/**
+ * Billboard set(一组 items 在前端轮播)。
+ * 在 Sprint-style 模型下,每个 env 最多 1 个 set;
+ * 实际展示还受 startAt / endAt 时间窗口约束。
+ */
+export interface BillboardSet {
+ /** ISO timestamp — 时间窗口结束,到点后 LobeHub 不再展示 */
+ endAt: string;
+ /**
+ * 按 locale 覆盖 billboard 级别的文案(当前仅 title,用于 ? 菜单)。
+ */
+ i18n?: Record<string, BillboardLocaleFields>;
+ id: number;
+ items: BillboardItem[];
+ /** 唯一标识符 */
+ slug: string;
+ /** ISO timestamp — 时间窗口开始,未到时 LobeHub 不展示 */
+ startAt: string;
+ /** 用于 ? 菜单展示 */
+ title: string;
+}
+
+/**
+ * Edge Config 中存放的 Billboard 纯内容。Sprint-style 每个 env 只有 1 条或 null。
+ */
+export type BillboardSnapshot = BillboardSet | null;
+
/**
* EdgeConfig complete configuration type
*/
@@ -13,6 +74,12 @@ export interface EdgeConfigData extends BusinessEdgeConfigData {
*/
assistant_whitelist?: string[];
+ /**
+ * Billboard snapshot. 每个 Vercel 部署读自己 store 里的 `billboards` key——
+ * dev 部署指向 dev store,prod 部署指向 prod store,LobeHub 侧无感知。
+ */
+ billboards?: BillboardSnapshot;
+
/**
* Feature flags configuration
*/
diff --git a/packages/types/src/serverConfig.ts b/packages/types/src/serverConfig.ts
index b6da2a5cc14..d87a04670d3 100644
--- a/packages/types/src/serverConfig.ts
+++ b/packages/types/src/serverConfig.ts
@@ -76,7 +76,44 @@ export interface GlobalServerConfig {
};
}
+export interface GlobalBillboardItemLocaleFields {
+ description?: string;
+ linkLabel?: string;
+ title?: string;
+}
+
+export interface GlobalBillboardItem {
+ cover?: string | null;
+ description: string;
+ /**
+ * 按 locale 覆盖的文案。缺失 locale 或 locale 内某字段缺失时回退到默认字段。
+ */
+ i18n?: Record<string, GlobalBillboardItemLocaleFields>;
+ id: number;
+ linkLabel?: string | null;
+ linkUrl?: string | null;
+ title: string;
+}
+
+export interface GlobalBillboardLocaleFields {
+ title?: string;
+}
+
+export interface GlobalBillboard {
+ endAt: string;
+ /**
+ * 按 locale 覆盖 billboard 级别字段(当前仅 title)。缺失时回退到默认 title。
+ */
+ i18n?: Record<string, GlobalBillboardLocaleFields>;
+ id: number;
+ items: GlobalBillboardItem[];
+ slug: string;
+ startAt: string;
+ title: string;
+}
+
export interface GlobalRuntimeConfig {
+ billboard?: GlobalBillboard | null;
serverConfig: GlobalServerConfig;
serverFeatureFlags: IFeatureFlagsState;
}
diff --git a/src/features/Billboard/Carousel.tsx b/src/features/Billboard/Carousel.tsx
new file mode 100644
index 00000000000..b42bba03a9f
--- /dev/null
+++ b/src/features/Billboard/Carousel.tsx
@@ -0,0 +1,249 @@
+'use client';
+
+import { ActionIcon, Button, Flexbox, Tooltip } from '@lobehub/ui';
+import { Carousel as AntCarousel } from 'antd';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { X } from 'lucide-react';
+import { motion } from 'motion/react';
+import { type ComponentRef, memo, useLayoutEffect, useMemo, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import type { GlobalBillboard, GlobalBillboardItem } from '@/types/serverConfig';
+
+import { resolveBillboardItem } from './locale';
+
+type BillboardItem = GlobalBillboardItem;
+
+interface BillboardCarouselProps {
+ cardAttr?: string;
+ closing?: boolean;
+ exitTarget?: { x: number; y: number };
+ onAnimationFinish?: () => void;
+ onClose: () => void;
+ set: GlobalBillboard;
+}
+
+const styles = createStaticStyles(({ css }) => ({
+ action: css`
+ display: block;
+ width: 100%;
+ margin-block-start: 8px;
+ `,
+ card: css`
+ position: fixed;
+ z-index: 1000;
+ inset-block-end: 56px;
+ inset-inline-start: 8px;
+ transform-origin: bottom left;
+
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+
+ width: 300px;
+ max-width: calc(100vw - 32px);
+ padding: 0;
+ border: 1px solid ${cssVar.colorBorder};
+ border-radius: 12px;
+
+ background: ${cssVar.colorBgContainer};
+ box-shadow: 0 4px 24px rgb(0 0 0 / 12%);
+ `,
+ closeButton: css`
+ position: absolute;
+ z-index: 2;
+ inset-block-start: 8px;
+ inset-inline-end: 8px;
+ `,
+ description: css`
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 4;
+
+ font-size: 14px;
+ color: ${cssVar.colorTextSecondary};
+ text-overflow: ellipsis;
+ `,
+ dot: css`
+ cursor: pointer;
+
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+
+ background: ${cssVar.colorFillSecondary};
+
+ transition: all 0.2s;
+ `,
+ dotActive: css`
+ width: 18px;
+ border-radius: 3px;
+ background: ${cssVar.colorPrimary};
+ `,
+ dots: css`
+ padding-block-end: 10px;
+ `,
+ image: css`
+ display: block;
+
+ width: 100%;
+ height: 140px;
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+
+ object-fit: cover;
+ `,
+ itemBody: css`
+ padding: 12px;
+ `,
+ title: css`
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+
+ font-size: 16px;
+ font-weight: 600;
+ color: ${cssVar.colorText};
+ text-overflow: ellipsis;
+ `,
+}));
+
+const ItemContent = memo<{ item: BillboardItem }>(({ item }) => {
+ const { t, i18n } = useTranslation('notification');
+ const resolved = useMemo(() => resolveBillboardItem(item, i18n.language), [item, i18n.language]);
+
+ const titleRef = useRef<HTMLDivElement>(null);
+ const descRef = useRef<HTMLDivElement>(null);
+ const [titleOverflow, setTitleOverflow] = useState(false);
+ const [descOverflow, setDescOverflow] = useState(false);
+
+ useLayoutEffect(() => {
+ const el = titleRef.current;
+ if (!el) return;
+ setTitleOverflow(el.scrollHeight > el.clientHeight + 1);
+ }, [resolved.title]);
+
+ useLayoutEffect(() => {
+ const el = descRef.current;
+ if (!el) return;
+ setDescOverflow(el.scrollHeight > el.clientHeight + 1);
+ }, [resolved.description]);
+
+ const titleNode = (
+ <div className={styles.title} ref={titleRef}>
+ {resolved.title}
+ </div>
+ );
+
+ const descNode = resolved.description && (
+ <div className={styles.description} ref={descRef}>
+ {resolved.description}
+ </div>
+ );
+
+ return (
+ <Flexbox gap={0}>
+ {item.cover && <img alt="" className={styles.image} src={item.cover} />}
+ <Flexbox className={styles.itemBody} gap={4}>
+ {titleOverflow ? (
+ <Tooltip placement="top" title={resolved.title}>
+ {titleNode}
+ </Tooltip>
+ ) : (
+ titleNode
+ )}
+ {descNode &&
+ (descOverflow ? (
+ <Tooltip placement="top" title={resolved.description}>
+ {descNode}
+ </Tooltip>
+ ) : (
+ descNode
+ ))}
+ {item.linkUrl && (
+ <a
+ className={styles.action}
+ href={item.linkUrl}
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <Button block size="small" type="primary">
+ {resolved.linkLabel ?? t('billboard.learnMore')}
+ </Button>
+ </a>
+ )}
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+ItemContent.displayName = 'BillboardItemContent';
+
+const BillboardCarousel = memo<BillboardCarouselProps>(
+ ({ set, onClose, closing, exitTarget, onAnimationFinish, cardAttr }) => {
+ const [paused, setPaused] = useState(false);
+ const [current, setCurrent] = useState(0);
+ const carouselRef = useRef<ComponentRef<typeof AntCarousel>>(null);
+
+ if (set.items.length === 0) return null;
+
+ const single = set.items.length === 1;
+
+ const cardDataProps = cardAttr ? { [cardAttr]: '' } : {};
+
+ return (
+ <motion.div
+ {...cardDataProps}
+ className={styles.card}
+ initial={{ opacity: 0, scale: 0.92, y: 16 }}
+ transition={{ duration: 0.35, ease: [0.2, 0.8, 0.2, 1] }}
+ animate={
+ closing
+ ? { opacity: 0, scale: 0.15, x: exitTarget?.x ?? 0, y: exitTarget?.y ?? 40 }
+ : { opacity: 1, scale: 1, x: 0, y: 0 }
+ }
+ onMouseEnter={() => setPaused(true)}
+ onMouseLeave={() => setPaused(false)}
+ onAnimationComplete={() => {
+ if (closing) onAnimationFinish?.();
+ }}
+ >
+ <ActionIcon className={styles.closeButton} icon={X} size={14} onClick={onClose} />
+ {single ? (
+ <ItemContent item={set.items[0]} />
+ ) : (
+ <>
+ <AntCarousel
+ adaptiveHeight
+ autoplay={!paused}
+ autoplaySpeed={6000}
+ beforeChange={(_: number, next: number) => setCurrent(next)}
+ dots={false}
+ ref={carouselRef}
+ >
+ {set.items.map((item) => (
+ <div key={item.id}>
+ <ItemContent item={item} />
+ </div>
+ ))}
+ </AntCarousel>
+ <Flexbox horizontal className={styles.dots} gap={6} justify="center">
+ {set.items.map((item, idx) => (
+ <div
+ className={`${styles.dot} ${current === idx ? styles.dotActive : ''}`}
+ key={item.id}
+ onClick={() => carouselRef.current?.goTo(idx)}
+ />
+ ))}
+ </Flexbox>
+ </>
+ )}
+ </motion.div>
+ );
+ },
+);
+
+BillboardCarousel.displayName = 'BillboardCarousel';
+
+export default BillboardCarousel;
diff --git a/src/features/Billboard/MenuItems.tsx b/src/features/Billboard/MenuItems.tsx
new file mode 100644
index 00000000000..919532398ac
--- /dev/null
+++ b/src/features/Billboard/MenuItems.tsx
@@ -0,0 +1,57 @@
+import type { MenuProps } from '@lobehub/ui';
+import { Icon } from '@lobehub/ui';
+import { Megaphone } from 'lucide-react';
+import { useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useGlobalStore } from '@/store/global';
+import { useServerConfigStore } from '@/store/serverConfig';
+
+import { billboardDismissKey } from './index';
+import { resolveBillboardTitle } from './locale';
+
+export const useBillboardMenuItems = (): MenuProps['items'] => {
+ const billboard = useServerConfigStore((s) => s.billboard);
+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
+ const { i18n } = useTranslation();
+
+ return useMemo(() => {
+ if (!billboard || billboard.items.length === 0) return [];
+ const now = Date.now();
+ const start = Date.parse(billboard.startAt);
+ const end = Date.parse(billboard.endAt);
+ const inWindow = Number.isFinite(start) && Number.isFinite(end) && start <= now && now <= end;
+ if (!inWindow) return [];
+ const title = resolveBillboardTitle(billboard, i18n.language);
+ return [
+ {
+ icon: <Icon icon={Megaphone} />,
+ key: `billboard-${billboard.slug}`,
+ label: (
+ <span
+ title={title}
+ style={{
+ display: 'inline-block',
+ maxWidth: 200,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ verticalAlign: 'middle',
+ whiteSpace: 'nowrap',
+ }}
+ >
+ {title}
+ </span>
+ ),
+ onClick: () => {
+ const slug = billboardDismissKey(billboard.slug);
+ const current = useGlobalStore.getState().status.readNotificationSlugs ?? [];
+ if (current.includes(slug)) {
+ updateSystemStatus({
+ readNotificationSlugs: current.filter((s) => s !== slug),
+ });
+ }
+ },
+ },
+ ];
+ }, [billboard, i18n.language, updateSystemStatus]);
+};
diff --git a/src/features/Billboard/index.tsx b/src/features/Billboard/index.tsx
new file mode 100644
index 00000000000..db9813d1d88
--- /dev/null
+++ b/src/features/Billboard/index.tsx
@@ -0,0 +1,74 @@
+'use client';
+
+import { memo, useCallback, useState } from 'react';
+
+import { useGlobalStore } from '@/store/global';
+import { useServerConfigStore } from '@/store/serverConfig';
+
+import BillboardCarousel from './Carousel';
+
+export const billboardDismissKey = (slug: string) => `billboard:${slug}`;
+export const BILLBOARD_ANCHOR_ATTR = 'data-billboard-anchor';
+const CARD_ATTR = 'data-billboard-card';
+
+const Billboard = memo(() => {
+ const billboard = useServerConfigStore((s) => s.billboard);
+ const updateSystemStatus = useGlobalStore((s) => s.updateSystemStatus);
+ const dismissedSlugs = useGlobalStore((s) => s.status.readNotificationSlugs ?? []);
+ const [closing, setClosing] = useState(false);
+ const [exitTarget, setExitTarget] = useState<{ x: number; y: number }>({ x: 0, y: 40 });
+
+ const inWindow = billboard
+ ? (() => {
+ const now = Date.now();
+ const start = Date.parse(billboard.startAt);
+ const end = Date.parse(billboard.endAt);
+ return Number.isFinite(start) && Number.isFinite(end) && start <= now && now <= end;
+ })()
+ : false;
+
+ const isDismissed = billboard
+ ? dismissedSlugs.includes(billboardDismissKey(billboard.slug))
+ : true;
+
+ const handleCloseStart = useCallback(() => {
+ const anchor = document.querySelector<HTMLElement>(`[${BILLBOARD_ANCHOR_ATTR}]`);
+ const card = document.querySelector<HTMLElement>(`[${CARD_ATTR}]`);
+ if (anchor && card) {
+ const anchorRect = anchor.getBoundingClientRect();
+ const cardRect = card.getBoundingClientRect();
+ setExitTarget({
+ x: anchorRect.left + anchorRect.width / 2 - (cardRect.left + cardRect.width / 2),
+ y: anchorRect.top + anchorRect.height / 2 - (cardRect.top + cardRect.height / 2),
+ });
+ }
+ setClosing(true);
+ }, []);
+
+ const handleAnimationFinish = useCallback(() => {
+ if (!billboard) return;
+ const slug = billboardDismissKey(billboard.slug);
+ const current = useGlobalStore.getState().status.readNotificationSlugs ?? [];
+ if (!current.includes(slug)) {
+ updateSystemStatus({ readNotificationSlugs: [...current, slug] });
+ }
+ setClosing(false);
+ }, [billboard, updateSystemStatus]);
+
+ if (!billboard || !inWindow || isDismissed || billboard.items.length === 0) return null;
+
+ return (
+ <BillboardCarousel
+ cardAttr={CARD_ATTR}
+ closing={closing}
+ exitTarget={exitTarget}
+ set={billboard}
+ onAnimationFinish={handleAnimationFinish}
+ onClose={handleCloseStart}
+ />
+ );
+});
+
+Billboard.displayName = 'Billboard';
+
+export default Billboard;
diff --git a/src/features/Billboard/locale.test.ts b/src/features/Billboard/locale.test.ts
new file mode 100644
index 00000000000..c20c3b48c68
--- /dev/null
+++ b/src/features/Billboard/locale.test.ts
@@ -0,0 +1,114 @@
+import { describe, expect, it } from 'vitest';
+
+import type { GlobalBillboard, GlobalBillboardItem } from '@/types/serverConfig';
+
+import { resolveBillboardItem, resolveBillboardTitle } from './locale';
+
+const base: GlobalBillboardItem = {
+ description: 'Default description',
+ id: 1,
+ linkLabel: 'Default label',
+ title: 'Default title',
+};
+
+describe('resolveBillboardItem', () => {
+ it('falls back to default fields when i18n is missing', () => {
+ expect(resolveBillboardItem(base, 'zh-CN')).toEqual({
+ description: 'Default description',
+ linkLabel: 'Default label',
+ title: 'Default title',
+ });
+ });
+
+ it('uses the exact locale match when present', () => {
+ const item: GlobalBillboardItem = {
+ ...base,
+ i18n: {
+ 'zh-CN': { description: '中文描述', linkLabel: '查看', title: '中文标题' },
+ },
+ };
+
+ expect(resolveBillboardItem(item, 'zh-CN')).toEqual({
+ description: '中文描述',
+ linkLabel: '查看',
+ title: '中文标题',
+ });
+ });
+
+ it('falls back to base locale when regional variant missing', () => {
+ const item: GlobalBillboardItem = {
+ ...base,
+ i18n: {
+ zh: { title: '通用中文标题' },
+ },
+ };
+
+ expect(resolveBillboardItem(item, 'zh-HK').title).toBe('通用中文标题');
+ });
+
+ it('falls back to sibling regional locale when base missing', () => {
+ const item: GlobalBillboardItem = {
+ ...base,
+ i18n: {
+ 'zh-CN': { title: '简体标题' },
+ },
+ };
+
+ expect(resolveBillboardItem(item, 'zh-TW').title).toBe('简体标题');
+ });
+
+ it('uses default when locale entry exists but specific field missing', () => {
+ const item: GlobalBillboardItem = {
+ ...base,
+ i18n: {
+ 'ja-JP': { title: '日本語タイトル' },
+ },
+ };
+
+ expect(resolveBillboardItem(item, 'ja-JP')).toEqual({
+ description: 'Default description',
+ linkLabel: 'Default label',
+ title: '日本語タイトル',
+ });
+ });
+
+ it('returns null linkLabel when neither locale nor default has it', () => {
+ const item: GlobalBillboardItem = {
+ ...base,
+ linkLabel: null,
+ };
+
+ expect(resolveBillboardItem(item, 'en-US').linkLabel).toBeNull();
+ });
+});
+
+describe('resolveBillboardTitle', () => {
+ const baseBillboard: GlobalBillboard = {
+ endAt: '2026-12-31T00:00:00.000Z',
+ id: 1,
+ items: [],
+ slug: 'test',
+ startAt: '2026-01-01T00:00:00.000Z',
+ title: 'Default billboard title',
+ };
+
+ it('falls back to default title when i18n is missing', () => {
+ expect(resolveBillboardTitle(baseBillboard, 'zh-CN')).toBe('Default billboard title');
+ });
+
+ it('uses locale override when present', () => {
+ const billboard: GlobalBillboard = {
+ ...baseBillboard,
+ i18n: { 'zh-CN': { title: '中文标题' } },
+ };
+ expect(resolveBillboardTitle(billboard, 'zh-CN')).toBe('中文标题');
+ });
+
+ it('falls back to sibling regional locale via base code', () => {
+ const billboard: GlobalBillboard = {
+ ...baseBillboard,
+ i18n: { 'zh-CN': { title: '简体标题' } },
+ };
+ expect(resolveBillboardTitle(billboard, 'zh-TW')).toBe('简体标题');
+ });
+});
diff --git a/src/features/Billboard/locale.ts b/src/features/Billboard/locale.ts
new file mode 100644
index 00000000000..5428f684477
--- /dev/null
+++ b/src/features/Billboard/locale.ts
@@ -0,0 +1,49 @@
+import type {
+ GlobalBillboard,
+ GlobalBillboardItem,
+ GlobalBillboardItemLocaleFields,
+ GlobalBillboardLocaleFields,
+} from '@/types/serverConfig';
+
+export interface ResolvedBillboardItem {
+ description: string;
+ linkLabel: string | null;
+ title: string;
+}
+
+/**
+ * locale 候选优先级:完整 code(zh-CN) → 基础 code(zh) → 其它共享同基础的 code(zh-HK)→ 默认字段。
+ * 只命中 i18n 中存在的 key,避免把 undefined 当作有效值覆盖默认。
+ */
+const pickLocaleEntry = <T>(i18n: Record<string, T> | undefined, locale: string): T | undefined => {
+ if (!i18n) return undefined;
+
+ if (i18n[locale]) return i18n[locale];
+
+ const base = locale.split('-')[0];
+ if (i18n[base]) return i18n[base];
+
+ const sameBase = Object.keys(i18n).find((key) => key.split('-')[0] === base);
+ return sameBase ? i18n[sameBase] : undefined;
+};
+
+export const resolveBillboardItem = (
+ item: GlobalBillboardItem,
+ locale: string,
+): ResolvedBillboardItem => {
+ const entry = pickLocaleEntry<GlobalBillboardItemLocaleFields>(item.i18n, locale);
+
+ return {
+ description: entry?.description ?? item.description,
+ linkLabel: entry?.linkLabel ?? item.linkLabel ?? null,
+ title: entry?.title ?? item.title,
+ };
+};
+
+/**
+ * 解析 billboard 级别字段(目前只有 title,用于 ? 菜单展示)。
+ */
+export const resolveBillboardTitle = (billboard: GlobalBillboard, locale: string): string => {
+ const entry = pickLocaleEntry<GlobalBillboardLocaleFields>(billboard.i18n, locale);
+ return entry?.title ?? billboard.title;
+};
diff --git a/src/locales/default/notification.ts b/src/locales/default/notification.ts
index 70b3ff28fe9..cddb6d8fb7e 100644
--- a/src/locales/default/notification.ts
+++ b/src/locales/default/notification.ts
@@ -1,4 +1,6 @@
export default {
+ 'billboard.learnMore': 'Learn more',
+ 'billboard.menuLabel': 'Announcements',
'inbox.archiveAll': 'Archive all',
'inbox.empty': 'No notifications yet',
'inbox.emptyUnread': 'No unread notifications',
diff --git a/src/routes/(main)/home/_layout/Footer/index.test.tsx b/src/routes/(main)/home/_layout/Footer/index.test.tsx
index 4c32d449cc1..f5f57fd8173 100644
--- a/src/routes/(main)/home/_layout/Footer/index.test.tsx
+++ b/src/routes/(main)/home/_layout/Footer/index.test.tsx
@@ -8,6 +8,7 @@ const analyticsTrack = vi.fn();
vi.mock('react-i18next', () => ({
useTranslation: () => ({
+ i18n: { language: 'en-US' },
t: (key: string) =>
({
'agentOnboardingPromo.actionLabel': 'Try it now',
diff --git a/src/routes/(main)/home/_layout/Footer/index.tsx b/src/routes/(main)/home/_layout/Footer/index.tsx
index 117aea7cbeb..884d03e2f90 100644
--- a/src/routes/(main)/home/_layout/Footer/index.tsx
+++ b/src/routes/(main)/home/_layout/Footer/index.tsx
@@ -25,6 +25,8 @@ import { Link, useNavigate } from 'react-router-dom';
import ChangelogModal from '@/components/ChangelogModal';
import HighlightNotification from '@/components/HighlightNotification';
import { DOCUMENTS_REFER_URL, GITHUB } from '@/const/url';
+import Billboard from '@/features/Billboard';
+import { useBillboardMenuItems } from '@/features/Billboard/MenuItems';
import ThemeButton from '@/features/User/UserPanel/ThemeButton';
import { useFeedbackModal } from '@/hooks/useFeedbackModal';
import { useNavLayout } from '@/hooks/useNavLayout';
@@ -64,6 +66,7 @@ const Footer = memo(() => {
const navigate = useNavigate();
const { analytics } = useAnalytics();
const { footer } = useNavLayout();
+ const billboardMenuItems = useBillboardMenuItems();
const enableAgentOnboarding = useServerConfigStore((s) => s.featureFlags.enableAgentOnboarding);
const isMobile = useServerConfigStore((s) => !!s.isMobile);
const serverConfigInit = useServerConfigStore((s) => s.serverConfigInit);
@@ -332,6 +335,9 @@ const Footer = memo(() => {
},
]
: []),
+ ...(billboardMenuItems && billboardMenuItems.length > 0
+ ? [{ type: 'divider' as const }, ...billboardMenuItems]
+ : []),
],
[
footer.showSettingsEntry,
@@ -343,6 +349,7 @@ const Footer = memo(() => {
isDevMode,
shouldShowProductHuntMenuEntry,
t,
+ billboardMenuItems,
],
);
@@ -352,7 +359,12 @@ const Footer = memo(() => {
<Flexbox horizontal align={'center'} gap={2} justify={'space-between'} padding={8}>
<Flexbox horizontal align={'center'} flex={1} gap={2}>
<DropdownMenu items={helpMenuItems} placement="topLeft">
- <ActionIcon aria-label={t('userPanel.help')} icon={CircleHelp} size={16} />
+ <ActionIcon
+ aria-label={t('userPanel.help')}
+ data-billboard-anchor=""
+ icon={CircleHelp}
+ size={16}
+ />
</DropdownMenu>
{!footer.hideGitHub && (
<a aria-label={'GitHub'} href={GITHUB} rel="noopener noreferrer" target={'_blank'}>
@@ -401,6 +413,7 @@ const Footer = memo(() => {
onClose={activePromotion.onClose}
/>
)}
+ <Billboard />
</>
);
});
diff --git a/src/server/routers/lambda/config/index.ts b/src/server/routers/lambda/config/index.ts
index e327981eeed..ac7568e77d0 100644
--- a/src/server/routers/lambda/config/index.ts
+++ b/src/server/routers/lambda/config/index.ts
@@ -1,13 +1,59 @@
+import { EdgeConfig } from '@lobechat/edge-config';
import debug from 'debug';
import { businessConfigEndpoints } from '@/business/server/lambda-routers/config';
import { getServerFeatureFlagsStateFromEdgeConfig } from '@/config/featureFlags';
import { publicProcedure, router } from '@/libs/trpc/lambda';
import { getServerDefaultAgentConfig, getServerGlobalConfig } from '@/server/globalConfig';
-import { type GlobalRuntimeConfig } from '@/types/serverConfig';
+import {
+ type GlobalBillboard,
+ type GlobalBillboardItem,
+ type GlobalRuntimeConfig,
+} from '@/types/serverConfig';
const log = debug('config-router');
+const isObject = (value: unknown): value is Record<string, unknown> =>
+ typeof value === 'object' && value !== null && !Array.isArray(value);
+
+const normalizeBillboardItem = (raw: unknown): GlobalBillboardItem | null => {
+ if (!isObject(raw)) return null;
+ if (typeof raw.title !== 'string') return null;
+ if (typeof raw.description !== 'string') return null;
+ return raw as unknown as GlobalBillboardItem;
+};
+
+const normalizeBillboard = (raw: unknown): GlobalBillboard | null => {
+ if (!isObject(raw)) return null;
+ if (typeof raw.slug !== 'string' || raw.slug.length === 0) return null;
+ if (typeof raw.title !== 'string') return null;
+ if (typeof raw.startAt !== 'string' || typeof raw.endAt !== 'string') return null;
+ if (!Array.isArray(raw.items)) return null;
+
+ const items = raw.items
+ .map((item) => normalizeBillboardItem(item))
+ .filter((item): item is GlobalBillboardItem => item !== null);
+
+ return { ...(raw as unknown as GlobalBillboard), items };
+};
+
+const getActiveBillboard = async (): Promise<GlobalBillboard | null> => {
+ if (!EdgeConfig.isEnabled()) return null;
+ try {
+ const data = await new EdgeConfig().getBillboards();
+ if (!data) return null;
+ const normalized = normalizeBillboard(data);
+ if (!normalized) {
+ log('[Billboard] EdgeConfig payload failed validation, ignoring:', data);
+ return null;
+ }
+ return normalized;
+ } catch (err) {
+ log('[Billboard] Failed to read from EdgeConfig:', err);
+ return null;
+ }
+};
+
export const configRouter = router({
getDefaultAgentConfig: publicProcedure.query(async () => {
return getServerDefaultAgentConfig();
@@ -16,24 +62,15 @@ export const configRouter = router({
getGlobalConfig: publicProcedure.query(async ({ ctx }): Promise<GlobalRuntimeConfig> => {
log('[GlobalConfig] Starting global config retrieval for user:', ctx.userId || 'anonymous');
- const [serverConfig, serverFeatureFlags] = await Promise.all([
+ const [serverConfig, serverFeatureFlags, billboard] = await Promise.all([
getServerGlobalConfig(),
getServerFeatureFlagsStateFromEdgeConfig(ctx.userId || undefined),
+ getActiveBillboard(),
]);
log('[GlobalConfig] Server config retrieved');
- log(
- '[GlobalConfig] Final feature flags to return (evaluated booleans only):',
- serverFeatureFlags,
- );
-
- const result = { serverConfig, serverFeatureFlags };
- log(
- '[GlobalConfig] Returning global config with feature flags keys:',
- Object.keys(serverFeatureFlags),
- );
-
- return result;
+
+ return { billboard, serverConfig, serverFeatureFlags };
}),
...businessConfigEndpoints,
diff --git a/src/store/serverConfig/action.ts b/src/store/serverConfig/action.ts
index 24147999084..f434a1590b1 100644
--- a/src/store/serverConfig/action.ts
+++ b/src/store/serverConfig/action.ts
@@ -36,6 +36,7 @@ export class ServerConfigActionImpl {
onSuccess: (data) => {
this.#set(
{
+ billboard: data.billboard ?? null,
featureFlags: data.serverFeatureFlags,
serverConfig: data.serverConfig,
serverConfigInit: true,
diff --git a/src/store/serverConfig/store.ts b/src/store/serverConfig/store.ts
index 6d96fedd4c8..d0d633655a1 100644
--- a/src/store/serverConfig/store.ts
+++ b/src/store/serverConfig/store.ts
@@ -9,7 +9,7 @@ import { type IFeatureFlagsState } from '@/config/featureFlags';
import { DEFAULT_FEATURE_FLAGS, mapFeatureFlagsEnvToState } from '@/config/featureFlags';
import { createDevtools } from '@/store/middleware/createDevtools';
import { expose } from '@/store/middleware/expose';
-import { type GlobalServerConfig } from '@/types/serverConfig';
+import { type GlobalBillboard, type GlobalServerConfig } from '@/types/serverConfig';
import { merge } from '@/utils/merge';
import { flattenActions } from '../utils/flattenActions';
@@ -17,6 +17,7 @@ import { type ServerConfigAction } from './action';
import { createServerConfigSlice } from './action';
interface ServerConfigState {
+ billboard?: GlobalBillboard | null;
featureFlags: IFeatureFlagsState;
isMobile?: boolean;
segmentVariants?: string;
@@ -25,6 +26,7 @@ interface ServerConfigState {
}
const initialState: ServerConfigState = {
+ billboard: null,
featureFlags: mapFeatureFlagsEnvToState(DEFAULT_FEATURE_FLAGS),
segmentVariants: '',
serverConfig: { aiProvider: {}, telemetry: {} },