| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // 江中猴菇饮 OTC · VOC 深度洞察报告 v2 生成入口
- //
- // v2 核心变化:从"方法论展示"转为"用户决策路径追踪"
- // 新叙事结构:全景漏斗 → 嵌套洞察 → 痛声地图 → 产品适配 → 定位推导 → 行动蓝图
- //
- // 用法:node scripts/tools/gen-houguyin-v2.js
- // 输出:reports/jiangzhong-houguyin-voc-v2-report.html
- const fs = require('fs');
- const path = require('path');
- const { buildHTML, CHAPTERS, CHAPTER_SUBSECTIONS } = require('./houguyin-v2-render.js');
- const HGY = require('./houguyin-analyze.js');
- const ROOT = path.resolve(__dirname, '..', '..');
- const OUT_PATH = path.join(ROOT, 'reports', 'jiangzhong-houguyin-voc-v2-report.html');
- function main() {
- const t0 = Date.now();
- console.log('╔═══════════════════════════════════════════════════════════════╗');
- console.log('║ 江中猴菇饮 OTC · VOC 深度洞察报告 v2(用户决策路径追踪) ║');
- console.log('║ 叙事线:全景漏斗 → 嵌套洞察 → 痛声 → 适配 → 定位 → 行动 ║');
- console.log('╚═══════════════════════════════════════════════════════════════╝');
- const data = HGY.loadMerged();
- const meta = HGY.getMeta(data);
- console.log(` 数据阶段: ${meta.stage}`);
- console.log(` 输出: ${path.relative(ROOT, OUT_PATH)}`);
- // 计算 slide 总数
- let slideTotal = 2; // cover + agenda
- for (const c of CHAPTERS) {
- slideTotal += 1 + (CHAPTER_SUBSECTIONS[c.key] || []).length; // divider + subsections
- }
- console.log(` 章节: ${CHAPTERS.length} 章`);
- CHAPTERS.forEach(c => console.log(` Ch${c.num} ${c.title} (${(CHAPTER_SUBSECTIONS[c.key]||[]).length} 子章)`));
- console.log(` slide 总数: ${slideTotal}`);
- if (meta.comments > 0) {
- console.log(` VOC 数据: ${meta.comments} 条评论 / ${Object.keys(meta.platforms || {}).length} 平台`);
- } else {
- console.log(` ⚠ VOC 数据待采集`);
- }
- // 生成 HTML
- const html = buildHTML({
- product: '江中猴菇饮',
- collectedAt: meta.collectedAt,
- });
- // 写入
- fs.mkdirSync(path.dirname(OUT_PATH), { recursive: true });
- fs.writeFileSync(OUT_PATH, html, 'utf8');
- const sizeKB = (Buffer.byteLength(html, 'utf8') / 1024).toFixed(1);
- const ms = Date.now() - t0;
- console.log('');
- console.log(` ✅ v2 报告生成完成`);
- console.log(` 路径: ${path.relative(ROOT, OUT_PATH)}`);
- console.log(` 大小: ${sizeKB} KB`);
- console.log(` 耗时: ${ms} ms`);
- }
- if (require.main === module) {
- main();
- }
- module.exports = { main };
|