voc-validation-ch7-action.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // ==============================================================================
  2. // VOC 验证报告 · Ch7 落地行动 · 4 子章(快照模式)
  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 renderAction1Priority({ slideNum } = {}) { return fromSnapshot('action-1', slideNum); }
  24. function renderAction2Thresholds({ slideNum } = {}) { return fromSnapshot('action-2', slideNum); }
  25. function renderAction3Roadmap({ slideNum } = {}) { return fromSnapshot('action-3', slideNum); }
  26. function renderAction4NextStage({ slideNum } = {}) { return fromSnapshot('action-4', slideNum); }
  27. module.exports = {
  28. renderAction1Priority,
  29. renderAction2Thresholds,
  30. renderAction3Roadmap,
  31. renderAction4NextStage,
  32. };