| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- // 江中猴菇饮 OTC · VOC 深度洞察报告生成入口
- //
- // 用法:node scripts/tools/gen-houguyin.js
- //
- // 输出:reports/jiangzhong-houguyin-voc-insight-report.html
- const fs = require('fs');
- const path = require('path');
- const { buildHTML, CHAPTERS, CHAPTER_SUBSECTIONS } = require('./houguyin-render.js');
- const HGY = require('./houguyin-analyze.js');
- const ROOT = path.resolve(__dirname, '..', '..');
- const OUT_PATH = path.join(ROOT, 'reports', 'jiangzhong-houguyin-voc-insight-report.html');
- function main() {
- const t0 = Date.now();
- console.log('╔═══════════════════════════════════════════════════════════╗');
- console.log('║ 江中猴菇饮 OTC · VOC 深度洞察报告生成(反向定位方法论) ║');
- console.log('╚═══════════════════════════════════════════════════════════╝');
- const data = HGY.loadMerged();
- const meta = HGY.getMeta(data);
- const stage = meta.stage;
- console.log(` 采集阶段: ${stage}`);
- console.log(` 输出: ${path.relative(ROOT, OUT_PATH)}`);
- // 计算 slide 总数
- let slideTotal = 2;
- for (const c of CHAPTERS) {
- slideTotal += 1 + (CHAPTER_SUBSECTIONS[c.key] || []).length;
- }
- console.log(` 章节: 9 大章(人群全景/未满足需求/猴菇饮机会/KANO-JTBD/场景/竞品/机会/蓝图/真声洞察)`);
- console.log(` slide 总数: ${slideTotal}`);
- if (meta.comments > 0) {
- console.log(` VOC 数据: ${meta.comments} 条评论 / ${Object.keys(meta.platforms || {}).length} 平台`);
- } else {
- console.log(` ⚠ VOC 数据待采集(Batch 2 将填充真实评论)`);
- }
- // 生成 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(` ✅ 生成完成`);
- console.log(` 路径: ${path.relative(ROOT, OUT_PATH)}`);
- console.log(` 大小: ${sizeKB} KB`);
- console.log(` 耗时: ${ms} ms`);
- console.log(` 阶段: ${stage}`);
- }
- if (require.main === module) {
- main();
- }
- module.exports = { main };
|