templates.service.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.templatesService = exports.TemplatesService = void 0;
  4. class TemplatesService {
  5. // 模板数据
  6. templates = [
  7. // 广告营销
  8. { id: 1, name: '产品推广', category: '广告营销', content: '【{{product}}】限时优惠!{{feature1}}、{{feature2}},立即购买享折扣!', description: '用于产品宣传推广' },
  9. { id: 2, name: '活动邀请', category: '广告营销', content: '诚邀您参加{{event}}!{{time}}开始,{{location}},期待与您相见!', description: '邀请用户参加活动' },
  10. { id: 3, name: '促销公告', category: '广告营销', content: '🎉{{discount}}优惠进行中!{{product}}直降{{price}},名额有限,先到先得!', description: '促销活动宣传' },
  11. // 知识付费
  12. { id: 4, name: '课程介绍', category: '知识付费', content: '{{course}}课程招生中!由{{teacher}}主讲,{{content}},报名即送{{gift}}!', description: '在线课程推广' },
  13. { id: 5, name: '知识分享', category: '知识付费', content: '今日分享:{{topic}}。{{point1}}。{{point2}}。关注我们获取更多干货!', description: '知识内容分享' },
  14. { id: 6, name: '电子书推广', category: '知识付费', content: '《{{book}}》免费领取!{{description}},立即下载开启阅读之旅!', description: '电子书营销' },
  15. // 短视频
  16. { id: 7, name: '剧情脚本', category: '短视频', content: '【剧情】{{scene}}:{{character}}:{{dialogue}}', description: '短视频剧情文案' },
  17. { id: 8, name: '口播脚本', category: '短视频', content: '大家好,我是{{name}}!今天给大家介绍{{topic}}。{{content}}。喜欢记得点赞关注!', description: '真人出镜口播' },
  18. { id: 9, name: '种草推荐', category: '短视频', content: '姐妹们!{{product}}真的绝了!{{experience}},我用了{{time}}效果{{result}}!', description: '好物推荐文案' },
  19. // 企业宣传
  20. { id: 10, name: '公司介绍', category: '企业宣传', content: '{{company}}成立于{{year}}年,专注于{{industry}}。我们提供{{service}},联系电话:{{phone}}', description: '企业简介' },
  21. { id: 11, name: '招聘宣传', category: '企业宣传', content: '【招聘】{{company}}诚聘{{position}}!要求:{{requirement}},待遇:{{benefit}},欢迎投递简历!', description: '招聘信息' },
  22. { id: 12, name: '品牌故事', category: '企业宣传', content: '{{brand}}的诞生源于{{origin}}。{{story}}。这就是我们的初心与坚持。', description: '品牌文化宣传' },
  23. // 日常生活
  24. { id: 13, name: '生日祝福', category: '日常生活', content: '🎂生日快乐!愿你{{wish1}},{{wish2}}。新的一岁,万事胜意!', description: '生日祝福语' },
  25. { id: 14, name: '节日问候', category: '日常生活', content: '{{festival}}到!祝你{{greeting}}!{{detail}}', description: '节日祝福' },
  26. { id: 15, name: '日常分享', category: '日常生活', content: '今日份{{topic}}:{{content}}。{{feeling}}', description: '日常记录分享' },
  27. // 新闻资讯
  28. { id: 16, name: '新闻播报', category: '新闻资讯', content: '各位观众晚上好!今天是{{date}},以下是今日要闻:{{news1}};{{news2}};{{news3}}。', description: '新闻播报稿' },
  29. { id: 17, name: '热点解读', category: '新闻资讯', content: '【热点】{{event}}引发关注。{{analysis}}。对此,你怎么看?', description: '热点事件分析' },
  30. { id: 18, name: '行业报告', category: '新闻资讯', content: '{{industry}}行业动态:{{trend}}。数据显示{{data}}。预计{{prediction}}。', description: '行业分析报告' },
  31. ];
  32. // 分类列表
  33. categories = ['广告营销', '知识付费', '短视频', '企业宣传', '日常生活', '新闻资讯'];
  34. /**
  35. * 获取所有分类
  36. */
  37. getCategories() {
  38. return this.categories;
  39. }
  40. /**
  41. * 获取模板分类列表
  42. */
  43. getTemplateCategories() {
  44. return this.categories.map(cat => ({
  45. name: cat,
  46. count: this.templates.filter(t => t.category === cat).length
  47. }));
  48. }
  49. /**
  50. * 获取所有模板
  51. */
  52. getTemplates() {
  53. return this.templates;
  54. }
  55. /**
  56. * 按分类获取模板
  57. */
  58. getTemplatesByCategory(category) {
  59. if (!category)
  60. return this.templates;
  61. return this.templates.filter(t => t.category === category);
  62. }
  63. /**
  64. * 获取单个模板
  65. */
  66. getTemplateById(id) {
  67. return this.templates.find(t => t.id === id);
  68. }
  69. /**
  70. * 创建模板
  71. */
  72. createTemplate(data) {
  73. const newTemplate = {
  74. id: this.templates.length + 1,
  75. ...data,
  76. };
  77. this.templates.push(newTemplate);
  78. return newTemplate;
  79. }
  80. /**
  81. * 更新模板
  82. */
  83. updateTemplate(id, data) {
  84. const index = this.templates.findIndex(t => t.id === id);
  85. if (index === -1)
  86. return null;
  87. this.templates[index] = { ...this.templates[index], ...data };
  88. return this.templates[index];
  89. }
  90. /**
  91. * 删除模板
  92. */
  93. deleteTemplate(id) {
  94. const index = this.templates.findIndex(t => t.id === id);
  95. if (index === -1)
  96. return false;
  97. this.templates.splice(index, 1);
  98. return true;
  99. }
  100. }
  101. exports.TemplatesService = TemplatesService;
  102. exports.templatesService = new TemplatesService();