/** * ═══════════════════════════════════════════════════ * 海报模板 · 1080×1920 (9:16) * ═══════════════════════════════════════════════════ * * 适用于:放假通知、收稿海报、活动公告等 */ import { STYLES } from '../config.js' const W = STYLES.sizes.poster.width const H = STYLES.sizes.poster.height /** * 生成海报 HTML * @param {object} data * @param {string} data.title - 大标题 * @param {string} data.subtitle - 副标题(可选) * @param {string} data.body - 正文内容 * @param {string[]} data.details - 详情列表(如时间/地点/要求) * @param {string} data.cta - 行动号召(如「欢迎投稿」) * @param {string} data.footer - 底部信息(如主办方/联系方式) * @param {string} data.tag - 角标标签(如「通知」) * @param {'default'|'notice'|'recruit'} data.style - 海报风格 */ export function posterCard(data) { const { title = '', subtitle = '', body = '', details = [], cta = '', footer = '', tag = '', style = 'default', } = data const C = STYLES.colors const F = STYLES.fonts const T = STYLES.typography // 详情列表渲染 const detailsHtml = details.map((d, i) => { // 支持 key: value 格式 const colonIdx = d.indexOf(':') if (colonIdx > 0 && colonIdx < 20) { const key = d.slice(0, colonIdx) const val = d.slice(colonIdx + 1) return `
${key} ${val}
` } return `
${d}
` }).join('\n') return `
${style === 'notice' ? ` ${tag ? `
${tag}
` : ''}
${title}
${subtitle ? `
${subtitle}
` : ''}
` : style === 'recruit' ? `
${tag || '征稿启事'}
${title}
${subtitle ? `
${subtitle}
` : ''} ` : ` ${tag ? `
${tag}
` : ''}
${title}
${subtitle ? `
${subtitle}
` : ''}
`} ${body ? `

${body}

` : ''} ${details.length > 0 ? `
${detailsHtml}
` : ''}
${cta ? `
${cta}
` : ''}
` }