Files
jiang13-bbs/frontend/lib/ads.ts
freefire d7c6b3a961 feat: 帖子收藏与用户关注
- 新增收藏功能:favorite 服务与 handler、FavoriteButton 组件
- 新增关注功能:follow 服务与 handler、FollowButton 组件
- 用户主页适配关注/粉丝与收藏展示
- flash 消息工具、广告与侧边栏组件微调
2026-09-26 03:02:40 +08:00

28 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 首页侧栏图片广告展示尺寸(与 .j13-ad-promo 宽一致:248 = 两列文字 + 中间 6px 间距) */
export const AD_IMAGE_WIDTH = 248;
export const AD_IMAGE_HEIGHT = 60;
/** 单列文字槽宽度:(248 - 6) / 2 */
export const AD_TEXT_COL_WIDTH = 121;
/** 购买页建议文案 */
export const AD_IMAGE_SIZE_LABEL = `${AD_IMAGE_WIDTH}×${AD_IMAGE_HEIGHT}`;
export const AD_IMAGE_SIZE_LABEL_2X = `${AD_IMAGE_WIDTH * 2}×${AD_IMAGE_HEIGHT * 2}`;
/** 广告悬停提示第二行:统一免责声明 */
export const AD_TIP_DISCLAIMER = "斟酌选择,本站不做担保。";
/** 广告悬停提示延迟弹出时长(毫秒):停留一会再显示 */
export const AD_TIP_DELAY_MS = 600;
/** 到期时间展示格式:2026-10-01 23:59 */
export function formatAdEndsAt(value: string): string {
const d = new Date(value);
if (Number.isNaN(d.getTime())) return "";
const p = (n: number) => String(n).padStart(2, "0");
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
}
/** 广告悬停提示:首行到期时间(可选),第二行免责声明(\n 由气泡 pre-line 换行) */
export function adHoverTip(endsAt?: string | null): string {
const t = endsAt ? formatAdEndsAt(endsAt) : "";
return t ? `到期时间:${t}\n${AD_TIP_DISCLAIMER}` : AD_TIP_DISCLAIMER;
}