Ship the page-focused follow reply with the news and shop updates.
Replace the subscribe welcome with page-generation examples, add the trial news003 WeChat share card, and let OneShop checkout return to an order or recharge page. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 对照渲染 news002 / news003 的公众号分享卡和正文。页面结构相同。
|
||||
*
|
||||
* node scripts/preview-news003-template.mjs [输出路径]
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { convertDailyNewsHtmlToWechatInlineArticle } from '../wechat-daily-news-inline.mjs';
|
||||
|
||||
const LEAD = ['国际油价一夜上涨', '布伦特原油隔夜上涨约 4%。国内成品油调价窗口就在这两天。', '明天加油,每升多花近两毛'];
|
||||
const ITEMS = [
|
||||
['东博会在南宁开幕', '本届参展企业超过三千家。主办方预计到场采购商多于去年。'],
|
||||
['央行维持政策利率', '公开市场继续净投放,资金面保持平稳。银行间利率围绕政策利率波动。'],
|
||||
['高铁新线开始试运行', '沿线车站完成联调。正式通车日期还要等监管部门公布。'],
|
||||
['沪指窄幅整理', '成交额较前一日略有萎缩。权重股分化,题材股成交靠前。'],
|
||||
['芯片厂上调资本开支', '先进制程订单排到明年二季度。设备交货周期仍在拉长。'],
|
||||
['冷空气开始南下', '明起华北有明显降温。部分地区风力加大,出行要注意。'],
|
||||
];
|
||||
|
||||
const leadThumb = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="640" height="360"><rect width="640" height="360" fill="#1b3a6b"/><rect y="210" width="640" height="150" fill="#c8362f"/><circle cx="470" cy="120" r="46" fill="#f4e7c5"/></svg>')}`;
|
||||
const thumb = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="72" height="54"><rect width="72" height="54" fill="#e4e4e4"/><path d="M0 40 L18 22 L32 34 L50 14 L72 36 V54 H0 Z" fill="#bdbdbd"/></svg>')}`;
|
||||
|
||||
function page(templateId) {
|
||||
const [title, body, why] = LEAD;
|
||||
const lead = `<a class="lead-card" data-event-key="lead"><div class="media"><img src="${leadThumb}" alt="${title}"></div><div class="body"><span class="tag">能源</span><h3>${title}</h3><p>${body}</p><div class="why"><b>为什么重要</b>:${why}</div></div></a>`;
|
||||
const cards = ITEMS.map(([itemTitle, itemBody], index) =>
|
||||
`<div class="card" data-event-key="k${index}"><div class="media"><img src="${thumb}" alt="${itemTitle}"></div><div class="body"><span class="tag">要闻</span><h3>${itemTitle}</h3><p>${itemBody}</p><div class="why"><b>为什么重要</b>:这句只留在页面上。</div></div></div>`,
|
||||
).join('\n');
|
||||
return `<html data-news-template="${templateId}"><head>
|
||||
<title>每日新闻早报 · 2026年11月21日</title>
|
||||
<meta name="description" content="今日要闻">
|
||||
</head><body>
|
||||
<div class="masthead"><h1>每日新闻早报</h1><div class="meta"><b>2026年11月21日</b> · 星期六 · 第 280 期</div></div>
|
||||
<div class="lede">中美外长再次通话 · 东博会南宁开幕 · 央行维持政策利率</div>
|
||||
<div class="section" id="headlines"><div class="section-title"><h2>今日头条</h2></div>${lead}${cards}</div>
|
||||
</body></html>`;
|
||||
}
|
||||
|
||||
function column(label, html, cover) {
|
||||
const article = convertDailyNewsHtmlToWechatInlineArticle(html, {
|
||||
includeFixedLayout: false,
|
||||
imageUrlMap: new Map([[leadThumb, leadThumb], [thumb, thumb]]),
|
||||
});
|
||||
return `<section class="phone"><p class="label">${label}</p>
|
||||
<div class="share"><img src="${cover}" alt=""><div><p class="share-title">${article.title}</p><p class="share-digest">${article.digest}</p></div></div>
|
||||
<div class="screen">${article.content}</div></section>`;
|
||||
}
|
||||
|
||||
const brandCover = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><rect width="120" height="120" fill="#1a1a2e"/><text x="60" y="66" fill="#fff" font-size="14" text-anchor="middle">早报</text></svg>')}`;
|
||||
const out = process.argv[2] || path.join(process.cwd(), '.tmp', 'news003-preview.html');
|
||||
const html = `<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>公众号对照 · news002 / news003</title>
|
||||
<style>
|
||||
body{margin:0;background:#f3f3f3;font-family:-apple-system,"PingFang SC",sans-serif}
|
||||
h1{font-size:16px;font-weight:600;margin:0;padding:16px 16px 0}
|
||||
.note{margin:6px 16px 12px;color:#666;font-size:13px}
|
||||
.row{display:flex;gap:16px;align-items:flex-start;padding:0 16px 32px;overflow:auto}
|
||||
.phone{width:390px;flex:0 0 390px;background:#ededed;border:1px solid #e5e5e5;border-radius:16px;overflow:hidden}
|
||||
.label{margin:0;padding:10px 14px;background:#fafafa;border-bottom:1px solid #eee;font-size:13px;font-weight:650}
|
||||
.share{display:flex;gap:10px;margin:12px;padding:10px;background:#fff;border-radius:6px}
|
||||
.share img{width:52px;height:52px;object-fit:cover;border-radius:2px;flex:0 0 52px}
|
||||
.share-title{margin:0;font-size:15px;font-weight:650;line-height:1.35;color:#111}
|
||||
.share-digest{margin:4px 0 0;font-size:12px;color:#888;line-height:1.4}
|
||||
.screen{margin:0 12px 16px;padding:12px 14px 20px;background:#fff;border-radius:6px}
|
||||
</style></head><body>
|
||||
<h1>公众号对照</h1>
|
||||
<p class="note">两边是同一份 news002 页面。上面是分享卡,下面是打开后的正文。左边标题是栏目名,右边标题是这条新闻里跟读者有关的具体变化。其余列表保持紧凑。</p>
|
||||
<div class="row">
|
||||
${column('现在 · news002', page('news002'), brandCover)}
|
||||
${column('转发 · news003', page('news003'), brandCover)}
|
||||
</div>
|
||||
</body></html>`;
|
||||
fs.mkdirSync(path.dirname(out), { recursive: true });
|
||||
fs.writeFileSync(out, html);
|
||||
console.log(`news003 wechat preview written to ${out}`);
|
||||
Reference in New Issue
Block a user