ConfidenceTemplate.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Services\Templates;
  3. class ConfidenceTemplate extends AbstractTemplate
  4. {
  5. public function render(): array
  6. {
  7. // 示例:处理 email 模板的渲染逻辑
  8. $value = $this->getParam('value', 1, '0');
  9. // 根据 format 调整渲染逻辑
  10. $props = ['value' => $value];
  11. $output = [];
  12. switch ($this->options['format']) {
  13. case 'react':
  14. $output = [
  15. 'props' => base64_encode(\json_encode($props)),
  16. 'html' => '',
  17. 'tag' => 'span',
  18. 'tpl' => 'cf',
  19. ];
  20. break;
  21. case 'unity':
  22. $output = [
  23. 'props' => base64_encode(\json_encode($props)),
  24. 'tpl' => 'cf',
  25. ];
  26. break;
  27. case 'markdown':
  28. $output = ["`$value`"];
  29. break;
  30. case 'html':
  31. $output = ["<span>{$value}</span>"];
  32. break;
  33. default:
  34. $output = [$value];
  35. break;
  36. }
  37. return $output;
  38. }
  39. }