voc-validation-ch4-positioning.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // ==============================================================================
  2. // VOC 验证报告 · Ch4 定位与话术 · 5 子章(快照模式)
  3. // 详见 ch2-package.js 头部说明。
  4. // ==============================================================================
  5. const fs = require('fs');
  6. const path = require('path');
  7. let _snapshot = null;
  8. function getSnapshot() {
  9. if (!_snapshot) {
  10. _snapshot = JSON.parse(fs.readFileSync(
  11. path.join(__dirname, '..', '_slides-snapshot.json'), 'utf8',
  12. ));
  13. }
  14. return _snapshot;
  15. }
  16. function fromSnapshot(id, slideNum) {
  17. const sec = getSnapshot()[id];
  18. if (!sec) {
  19. return `<section class="report-section" id="${id}" data-slide-num="${slideNum}"><div class="section-inner"><h2 class="text-h1">[Missing] ${id}</h2></div></section>`;
  20. }
  21. return sec.html.replace(/data-slide-num="[^"]+"/, `data-slide-num="${slideNum}"`);
  22. }
  23. function renderPositioning1DMY({ slideNum } = {}) { return fromSnapshot('positioning-1', slideNum); }
  24. function renderPositioning2Safety({ slideNum } = {}) { return fromSnapshot('positioning-2', slideNum); }
  25. function renderPositioning3Antidote({ slideNum } = {}) { return fromSnapshot('positioning-3', slideNum); }
  26. function renderPositioning4Social({ slideNum } = {}) { return fromSnapshot('positioning-4', slideNum); }
  27. function renderPositioning5Channel({ slideNum } = {}) { return fromSnapshot('positioning-5', slideNum); }
  28. module.exports = {
  29. renderPositioning1DMY,
  30. renderPositioning2Safety,
  31. renderPositioning3Antidote,
  32. renderPositioning4Social,
  33. renderPositioning5Channel,
  34. };