aiCreateDialog.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. <template>
  2. <el-dialog title="AI生成PPT" :visible.sync="dialogVisibleAiCreate" :append-to-body="true" width="700px"
  3. :before-close="handleClose" class="dialog_diy">
  4. <div style="height: 500px; padding: 15px" v-loading="loading" element-loading-text="小可正在努力生成中,请稍等...">
  5. <!-- <div class="t_box">
  6. <span>选择:</span>
  7. <el-radio-group v-model="radio" @change="changeRadio">
  8. <el-radio :label="0">PPT</el-radio>
  9. <el-radio :label="1">教案</el-radio>
  10. <el-radio :label="2">视频</el-radio>
  11. </el-radio-group>
  12. </div> -->
  13. <div class="t_box" v-if="steps == 1" style="height: 100%">
  14. <textarea style="height: 100%;width:calc(100% - 260px)" rows="10" class="binfo_input binfo_textarea"
  15. cols placeholder="请生成大纲" v-model="outline"></textarea>
  16. <div class="template_box">
  17. <span class="title">选择模板</span>
  18. <div class="template_list">
  19. <div class="template_item" :class="{ active: index == templateIndex }"
  20. v-for="(item, index) in templateList" :key="index" @click="changeTemplate(index)">
  21. <img :src="item.img" alt="" />
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div style="height: 100%" v-else>
  27. <wOffice v-if="url" :url="url"></wOffice>
  28. </div>
  29. </div>
  30. <span slot="footer" class="dialog-footer">
  31. <el-button @click="aiGet(2)" type="primary" :disabled="loading">重新生成大纲</el-button>
  32. <el-button @click="aiGet(1)" type="primary" :disabled="loading">{{
  33. url ? "重新生成PPT" : "生成PPT"
  34. }}</el-button>
  35. <el-button @click="steps = 1" type="primary" v-if="steps == 2">上一步</el-button>
  36. <el-button @click="steps = 2" type="primary" v-else-if="steps == 1 && url">下一步</el-button>
  37. <el-button @click="confirm" type="primary">确 定</el-button>
  38. <el-button @click="close">关 闭</el-button>
  39. </span>
  40. </el-dialog>
  41. </template>
  42. <script>
  43. import Pptxgen from "pptxgenjs";
  44. import wOffice from "../components/wOffice.vue";
  45. import { v4 as uuidv4 } from "uuid";
  46. export default {
  47. components: {
  48. wOffice,
  49. },
  50. props: {
  51. dialogVisibleAiCreate: {
  52. type: Boolean,
  53. default: false,
  54. },
  55. courseName: {
  56. type: String,
  57. default: "",
  58. },
  59. infoData: {
  60. type: Array,
  61. default: "",
  62. },
  63. courseTypeId: {
  64. type: Array,
  65. default: "",
  66. },
  67. CourseTypeJson: {
  68. type: Object,
  69. default: () => ({}),
  70. },
  71. courseState: {
  72. type: Number,
  73. },
  74. lineCount: {
  75. type: Number,
  76. },
  77. unitJson: {
  78. type: Array,
  79. }
  80. },
  81. // 根据用户给你的参考资料
  82. data() {
  83. return {
  84. userid: this.$route.query.userid,
  85. radio: 0,
  86. aiJson: {
  87. ppt: `## 任务
  88. 请生成关于${this.courseName},为教师生成这节课的教学ppt,页数在20页左右。PPT的内容主要是讲解该课程中所有可能涉及到的知识点。
  89. ## 工作流
  90. 1. 从用户提供的参考资料中提取10个最重要的知识点(知识点水平限制在小学和初中),并输出。
  91. 2. 针对10个知识点中的每个,你使用1~3页ppt详细的对知识点进行讲解。你的讲解词应该在100token左右
  92. 3. 讲解完所有知识点后,再根据知识点出5道单选题(放在5页ppt中)
  93. ## 限制
  94. - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
  95. - 你不能输出违反伦理的内容`,
  96. word: "",
  97. video: "",
  98. },
  99. aiUrl: {
  100. ppt: "",
  101. word: "",
  102. video: "",
  103. },
  104. detail: "",
  105. loading: false,
  106. url: "",
  107. uJson: {},
  108. outline: "",
  109. steps: 1,
  110. // templateList: [
  111. // // { img: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model1-11719468995661.png', img2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model1-21719469026755.png',color:'17094F' },
  112. // // { img: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model2-11719469051869.png', img2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model2-21719469040181.png',color:'052B37' },
  113. // // { img: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model3-11719469071576.png', img2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model3-21719469092087.png',color:'1D5869' },
  114. // // { img: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model4-11719469106190.png', img2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model-4-21719469125318.png',color:'372213' },
  115. // // { img: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model5-11719295908696.png', img2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/model5-21719295930345.png',color:'674D40' },
  116. // { img: require('../../../assets/icon/ppt/model1-1.png'), img2: require('../../../assets/icon/ppt/model1-2.png'),color:'17094F' },
  117. // { img: require('../../../assets/icon/ppt/model2-1.png'), img2: require('../../../assets/icon/ppt/model2-2.png'),color:'052B37' },
  118. // { img: require('../../../assets/icon/ppt/model3-1.png'), img2: require('../../../assets/icon/ppt/model3-2.png'),color:'1D5869' },
  119. // { img: require('../../../assets/icon/ppt/model4-1.png'), img2: require('../../../assets/icon/ppt/model4-2.png'),color:'372213' },
  120. // { img: require('../../../assets/icon/ppt/model5-1.png'), img2: require('../../../assets/icon/ppt/model5-2.png'),color:'674D40' },
  121. // ],
  122. templateList: [
  123. {
  124. img: require('../../../assets/icon/ppt/model1-1.png'),
  125. img1: {
  126. img: require('../../../assets/icon/ppt/model1-1.png'),
  127. setting: {
  128. x: "5%",
  129. y: 3,
  130. w: "90%",
  131. color: '17094F',
  132. fontSize: 38,
  133. align: "center",
  134. }
  135. },
  136. img2: [
  137. {
  138. img: require('../../../assets/icon/ppt/model1-2.png'),
  139. title: {
  140. x: "5%", // 横坐标
  141. y: 1.1,
  142. w: "90%",
  143. color: '17094F',
  144. bold: true,
  145. fontSize: 35, // 字号
  146. align: "center",
  147. },
  148. subTitle: {
  149. x: "5%", // 横坐标
  150. y: 1.8,
  151. w: "90%",
  152. color: "222222",
  153. fontSize: 20, // 字号
  154. align: "center",
  155. },
  156. content: {
  157. x: "20%", // 横坐标
  158. y: 3.2,
  159. w: "60%",
  160. color: "444444",
  161. fontSize: 18, // 字号
  162. align: "center",
  163. }
  164. }
  165. ],
  166. imgEnd: {
  167. img: require('../../../assets/icon/ppt/model1-1.png'),
  168. setting: {
  169. x: "5%",
  170. y: 3,
  171. w: "90%",
  172. color: '17094F',
  173. fontSize: 38,
  174. align: "center",
  175. }
  176. }
  177. },
  178. {
  179. img: require('../../../assets/icon/ppt/model2-1.png'),
  180. img1: {
  181. img: require('../../../assets/icon/ppt/model2-1.png'),
  182. setting: {
  183. x: "5%",
  184. y: 3,
  185. w: "90%",
  186. color: '052B37',
  187. fontSize: 38,
  188. align: "center",
  189. }
  190. },
  191. img2: [
  192. {
  193. img: require('../../../assets/icon/ppt/model2-2.png'),
  194. title: {
  195. x: "5%", // 横坐标
  196. y: 1.1,
  197. w: "90%",
  198. color: '052B37',
  199. bold: true,
  200. fontSize: 35, // 字号
  201. align: "center",
  202. },
  203. subTitle: {
  204. x: "5%", // 横坐标
  205. y: 1.8,
  206. w: "90%",
  207. color: "222222",
  208. fontSize: 20, // 字号
  209. align: "center",
  210. },
  211. content: {
  212. x: "20%", // 横坐标
  213. y: 3.2,
  214. w: "60%",
  215. color: "444444",
  216. fontSize: 18, // 字号
  217. align: "center",
  218. }
  219. }
  220. ],
  221. imgEnd: {
  222. img: require('../../../assets/icon/ppt/model2-1.png'),
  223. setting: {
  224. x: "5%",
  225. y: 3,
  226. w: "90%",
  227. color: '052B37',
  228. fontSize: 38,
  229. align: "center",
  230. }
  231. }
  232. },
  233. {
  234. img: require('../../../assets/icon/ppt/model3-1.png'),
  235. img1: {
  236. img: require('../../../assets/icon/ppt/model3-1.png'),
  237. setting: {
  238. x: "5%",
  239. y: 3,
  240. w: "90%",
  241. color: '1D5869',
  242. fontSize: 38,
  243. align: "center",
  244. }
  245. },
  246. img2: [
  247. {
  248. img: require('../../../assets/icon/ppt/model3-2.png'),
  249. title: {
  250. x: "5%", // 横坐标
  251. y: 1.1,
  252. w: "90%",
  253. color: '1D5869',
  254. bold: true,
  255. fontSize: 35, // 字号
  256. align: "center",
  257. },
  258. subTitle: {
  259. x: "5%", // 横坐标
  260. y: 1.8,
  261. w: "90%",
  262. color: "222222",
  263. fontSize: 20, // 字号
  264. align: "center",
  265. },
  266. content: {
  267. x: "20%", // 横坐标
  268. y: 3.2,
  269. w: "60%",
  270. color: "444444",
  271. fontSize: 18, // 字号
  272. align: "center",
  273. }
  274. }
  275. ],
  276. imgEnd: {
  277. img: require('../../../assets/icon/ppt/model3-1.png'),
  278. setting: {
  279. x: "5%",
  280. y: 3,
  281. w: "90%",
  282. color: '1D5869',
  283. fontSize: 38,
  284. align: "center",
  285. }
  286. }
  287. },
  288. {
  289. img: require('../../../assets/icon/ppt/model4-1.png'),
  290. img1: {
  291. img: require('../../../assets/icon/ppt/model4-1.png'),
  292. setting: {
  293. x: "5%",
  294. y: 3,
  295. w: "90%",
  296. color: '372213',
  297. fontSize: 38,
  298. align: "center",
  299. }
  300. },
  301. img2: [
  302. {
  303. img: require('../../../assets/icon/ppt/model4-2.png'),
  304. title: {
  305. x: "5%", // 横坐标
  306. y: 1.1,
  307. w: "90%",
  308. color: '372213',
  309. bold: true,
  310. fontSize: 35, // 字号
  311. align: "center",
  312. },
  313. subTitle: {
  314. x: "5%", // 横坐标
  315. y: 1.8,
  316. w: "90%",
  317. color: "222222",
  318. fontSize: 20, // 字号
  319. align: "center",
  320. },
  321. content: {
  322. x: "20%", // 横坐标
  323. y: 3.2,
  324. w: "60%",
  325. color: "444444",
  326. fontSize: 18, // 字号
  327. align: "center",
  328. }
  329. }
  330. ],
  331. imgEnd: {
  332. img: require('../../../assets/icon/ppt/model4-1.png'),
  333. setting: {
  334. x: "5%",
  335. y: 3,
  336. w: "90%",
  337. color: '372213',
  338. fontSize: 38,
  339. align: "center",
  340. }
  341. },
  342. color: '372213'
  343. },
  344. {
  345. img: require('../../../assets/icon/ppt/model5-1.png'),
  346. img1: {
  347. img: require('../../../assets/icon/ppt/model5-1.png'),
  348. setting: {
  349. x: "5%",
  350. y: 3,
  351. w: "90%",
  352. color: '674D40',
  353. fontSize: 38,
  354. align: "center",
  355. }
  356. },
  357. img2: [
  358. {
  359. img: require('../../../assets/icon/ppt/model5-2.png'),
  360. title: {
  361. x: "5%", // 横坐标
  362. y: 1.1,
  363. w: "90%",
  364. color: '674D40',
  365. bold: true,
  366. fontSize: 35, // 字号
  367. align: "center",
  368. },
  369. subTitle: {
  370. x: "5%", // 横坐标
  371. y: 1.8,
  372. w: "90%",
  373. color: "222222",
  374. fontSize: 20, // 字号
  375. align: "center",
  376. },
  377. content: {
  378. x: "20%", // 横坐标
  379. y: 3.2,
  380. w: "60%",
  381. color: "444444",
  382. fontSize: 18, // 字号
  383. align: "center",
  384. }
  385. }
  386. ],
  387. imgEnd: {
  388. img: require('../../../assets/icon/ppt/model5-1.png'),
  389. setting: {
  390. x: "5%",
  391. y: 3,
  392. w: "90%",
  393. color: '674D40',
  394. fontSize: 38,
  395. align: "center",
  396. }
  397. },
  398. },
  399. {
  400. img: require('../../../assets/icon/ppt/model6-1.png'),
  401. img1: {
  402. img: require('../../../assets/icon/ppt/model6-1-2.png'),
  403. setting: {
  404. x: "35%",
  405. y: 2.3,
  406. w: "60%",
  407. bold: true,
  408. color: 'EA7A93',
  409. fontSize: 38,
  410. align: "center",
  411. }
  412. },
  413. img2: [
  414. // {
  415. // img:require('../../../assets/icon/ppt/model6-2.png'),
  416. // title: {
  417. // x: "5%", // 横坐标
  418. // y: 1.1,
  419. // w: "90%",
  420. // color: '4F73DA',
  421. // bold: true,
  422. // fontSize: 35, // 字号
  423. // align: "center",
  424. // },
  425. // subTitle: {
  426. // x: "5%", // 横坐标
  427. // y: 1.8,
  428. // w: "90%",
  429. // color: "333333",
  430. // fontSize: 20, // 字号
  431. // align: "center",
  432. // },
  433. // content: {
  434. // x: "20%", // 横坐标
  435. // y: 3.2,
  436. // w: "60%",
  437. // color: "333333",
  438. // fontSize: 18, // 字号
  439. // align: "center",
  440. // }
  441. // },//内容页1
  442. // {
  443. // img: require('../../../assets/icon/ppt/model6-2.png'),
  444. // title: {
  445. // x: "2.5%", // 横坐标
  446. // y: 2.3,
  447. // w: "30%",
  448. // color: 'ffffff',
  449. // bold: true,
  450. // fontSize: 35, // 字号
  451. // align: "left",
  452. // },
  453. // subTitle: {
  454. // x: "2.5%", // 横坐标
  455. // y: 3.1,
  456. // w: "30%",
  457. // color: "ffffff",
  458. // fontSize: 20, // 字号
  459. // align: "left",
  460. // },
  461. // content: {
  462. // x: "45%", // 横坐标
  463. // y: 2.8,
  464. // w: "45%",
  465. // color: "333333",
  466. // fontSize: 18, // 字号
  467. // align: "left",
  468. // },
  469. // square: {
  470. // x: 0,
  471. // y: 0,
  472. // w: "35%",
  473. // h: "100%",
  474. // fill: { color: "4F73DA" }
  475. // },
  476. // square2: {
  477. // x: "35%",
  478. // y: 0,
  479. // w: "2.5%",
  480. // h: "100%",
  481. // fill: { color: "C2CFEF" }
  482. // }
  483. // },//内容页2
  484. // {
  485. // img: require('../../../assets/icon/ppt/model6-2.png'),
  486. // title: {
  487. // x: "5%", // 横坐标
  488. // y: 1,
  489. // w: "60%",
  490. // color: '4F73DA',
  491. // bold: true,
  492. // fontSize: 35, // 字号
  493. // align: "left",
  494. // },
  495. // subTitle: {
  496. // x: "5%", // 横坐标
  497. // y: 1.7,
  498. // w: "60%",
  499. // color: "333333",
  500. // fontSize: 20, // 字号
  501. // align: "left",
  502. // },
  503. // content: {
  504. // x: "5%", // 横坐标
  505. // y: 2.5,
  506. // w: "60%",
  507. // color: "333333",
  508. // fontSize: 18, // 字号
  509. // align: "left",
  510. // },
  511. // image: {
  512. // x: "70%",
  513. // y: "22%",
  514. // w: "30%",
  515. // h: "56%",
  516. // sizing: "contain",
  517. // path: require('../../../assets/icon/ppt/model6-3.png')
  518. // },
  519. // },//内容页3
  520. {
  521. img: require('../../../assets/icon/ppt/model6-2.png'),
  522. title: {
  523. x: "50%", // 横坐标
  524. y: "5%",
  525. h: 40,
  526. margin: 10,
  527. // w: "60%",
  528. color: 'ffffff',
  529. fill: { color: "4F73DA"},
  530. bold: true,
  531. fontSize: 35, // 字号
  532. align: "center",
  533. },
  534. subTitle: {
  535. x: "10%", // 横坐标
  536. y: 1.7,
  537. w: "80%",
  538. color: "333333",
  539. fontSize: 20, // 字号
  540. align: "left",
  541. },
  542. content: {
  543. x: "10%", // 横坐标
  544. y: 2.5,
  545. w: "80%",
  546. color: "333333",
  547. fontSize: 18, // 字号
  548. align: "left",
  549. },
  550. image: {
  551. x: "2.5%",
  552. y: "10%",
  553. w: "95%",
  554. h: "80%",
  555. sizing: "contain",
  556. path: require('../../../assets/icon/ppt/model6-4.png')
  557. },
  558. },//内容页4
  559. // {
  560. // img: require('../../../assets/icon/ppt/model6-2.png'),
  561. // title: {
  562. // x: 0, // 横坐标
  563. // y: "30%",
  564. // w: "35%",
  565. // h: "40%",
  566. // color: 'ffffff',
  567. // bold: true,
  568. // fontSize: 30, // 字号
  569. // align: "right",
  570. // fill: { color: "4F73DA"},
  571. // margin: 10,
  572. // },
  573. // subTitle: {
  574. // x: "37.5%", // 横坐标
  575. // y: 1,
  576. // w: "53%",
  577. // color: "333333",
  578. // fontSize: 20, // 字号
  579. // align: "left",
  580. // },
  581. // content: {
  582. // x: "37.5%", // 横坐标
  583. // y: 2,
  584. // w: "53%",
  585. // color: "333333",
  586. // fontSize: 18, // 字号
  587. // align: "left",
  588. // },
  589. // square: {
  590. // x: "5%",
  591. // y: "10%",
  592. // w: "90%",
  593. // h: "80%",
  594. // fill: { color: "ffffff" },
  595. // line: {
  596. // width: '2',
  597. // color: "3B4564"
  598. // }
  599. // },
  600. // }, //内容页5
  601. ],
  602. imgEnd: {
  603. img: require('../../../assets/icon/ppt/model6-1-2.png'),
  604. setting: {
  605. x: "35%",
  606. y: 2.3,
  607. w: "60%",
  608. color: 'EA7A93',
  609. fontSize: 38,
  610. align: "center",
  611. }
  612. },
  613. },
  614. ],
  615. templateIndex: 0,
  616. };
  617. },
  618. watch: {
  619. dialogVisibleAiCreate(newValue, oldValue) {
  620. if (newValue) {
  621. this.loading = false;
  622. // this.aiGet(2);
  623. this.templateIndex = 5
  624. let array = [
  625. {
  626. "page": 1,
  627. "title": "引入阶段",
  628. "task": "课程背景",
  629. "points": "同学们,让我们一起了解一下这门有趣的熊猫课程吧!今天,我们将探索熊猫的生活环境,并尝试去理解这些环境是如何影响熊猫的生存的。"
  630. },
  631. {
  632. "page": 2,
  633. "title": "引入阶段",
  634. "task": "整体目标和任务要求",
  635. "points": "这门课程的主要目标是让大家了解熊猫生活的环境以及生存所需的关键因素。我们将完成一个任务,具体要求是观察、记录、绘制和制作模型哦!"
  636. },
  637. {
  638. "page": 3,
  639. "title": "引入阶段",
  640. "task": "驱动性问题",
  641. "points": "大家思考一下这样一个问题:‘熊猫的生活环境对它们的生存有何重要影响?’ 我们接下去的活动将帮助大家找到答案。"
  642. },
  643. {
  644. "page": 4,
  645. "title": "引入阶段",
  646. "task": "观察与记录技巧",
  647. "points": "今天我们会运用图片和视频,来帮助大家观察熊猫栖息地和它们所吃的竹子等特征。细心观察,并将所见的特征记录下来是非常重要的技能哦!"
  648. },
  649. {
  650. "page": 5,
  651. "title": "探究阶段",
  652. "task": "绘图工具和材料",
  653. "points": "现在我们分发绘图工具和材料,来学习基本的绘图和建模技巧吧!熟练掌握这些工具会帮助我们更好地记录和展示我们的观察结果。"
  654. },
  655. {
  656. "page": 6,
  657. "title": "探究阶段",
  658. "task": "观察和记录特征",
  659. "points": "让我们好好观察一下身边的常见物体,把它们的特征记录下来。这个过程会训练你们的观察力和手眼协调能力。"
  660. },
  661. {
  662. "page": 7,
  663. "title": "探究阶段",
  664. "task": "转换二维图像",
  665. "points": "接下来,我们要把记录的三维物体转化为二维图像。这个步骤非常有趣,大家可以尽情发挥自己的绘画天赋哦!"
  666. },
  667. {
  668. "page": 8,
  669. "title": "探究阶段",
  670. "task": "三维模型制作",
  671. "points": "现在我们提供一些简单的材料,比如纸张和纸板,示范一下如何制作三维模型。记住,比例和结构是模型制作的关键!"
  672. },
  673. {
  674. "page": 9,
  675. "title": "评估与反馈阶段",
  676. "task": "评估和检查",
  677. "points": "大家完成了任务后,我们来检查和评估你们的二维图像和三维模型。确保它们的结构合理、比例协调。"
  678. },
  679. {
  680. "page": 10,
  681. "title": "评估与反馈阶段",
  682. "task": "提出改进建议",
  683. "points": "针对你们完成的作品,我们会提出一些改进建议。大家也可以相互评价,分享制作经验,这样可以互相学习哦!"
  684. },
  685. {
  686. "page": 11,
  687. "title": "评估与反馈阶段",
  688. "task": "任务总结",
  689. "points": "最后,我们要总结这次任务的执行情况,并表扬表现特别突出的同学。希望大家都能有所收获,并继续努力!"
  690. },
  691. {
  692. "page": 12,
  693. "title": "练习",
  694. "task": "练习1:二维图像绘制",
  695. "points": "选择一件日常物品(如书本、杯子),观察其特征,尝试通过手绘将其转换为二维图像。示例:通过绘制书本的正面、侧面和顶面图,展示其主要特征和比例关系。"
  696. },
  697. {
  698. "page": 13,
  699. "title": "练习",
  700. "task": "练习2:三维模型制作",
  701. "points": "使用纸张和纸板制作简单的模型,比如一个基本的房子或盒子。关注其结构和比例哦! 示例:通过折叠和粘贴纸张,制作一个四面体,确保各个面的比例协调,结构稳定。"
  702. }
  703. ]
  704. this.createPpt(array);
  705. }
  706. },
  707. },
  708. methods: {
  709. handleClose(done) {
  710. this.close();
  711. done();
  712. },
  713. close() {
  714. this.$emit("update:dialogVisibleAiCreate", false);
  715. },
  716. confirm() {
  717. if (this.url) {
  718. this.$emit("createAiPpt", this.uJson);
  719. } else {
  720. this.$message.error("请点击“生成PPT”按钮");
  721. }
  722. },
  723. changeRadio() {
  724. if (this.radio == 0) {
  725. this.detail = this.aiJson.ppt;
  726. }
  727. if (this.radio == 1) {
  728. this.detail = this.aiJson.word;
  729. }
  730. if (this.radio == 2) {
  731. this.detail = this.aiJson.video;
  732. }
  733. },
  734. createFileid(url) {
  735. let _this = this;
  736. return new Promise((resolve, reject) => {
  737. try {
  738. _this.ajax
  739. .put("https://gpt4.cocorobo.cn/upload_file_knowledge", {
  740. url: url,
  741. })
  742. .then((res) => {
  743. let _data = res.data.FunctionResponse;
  744. if (_data.result && _data.result.id) {
  745. resolve(_data.result.id);
  746. }
  747. })
  748. .catch(function (error) {
  749. resolve("");
  750. });
  751. } catch (e) {
  752. resolve();
  753. }
  754. });
  755. },
  756. async aiGet(type) {
  757. if (this.loading) {
  758. this.$message.error("正在生成中,请稍后");
  759. return;
  760. }
  761. this.url = "";
  762. this.uJson = {};
  763. let _this = this;
  764. let fileid = [];
  765. if (_this.infoData.length) {
  766. for (var i = 0; i < _this.infoData.length; i++) {
  767. if (_this.infoData[i].fileid) {
  768. fileid.push(_this.infoData[i].fileid);
  769. } else {
  770. let _fileid = await _this.createFileid(_this.infoData[i].url);
  771. if (_fileid) {
  772. _this.infoData[i].fileid = _fileid;
  773. _this.$forceUpdate();
  774. fileid.push(_fileid);
  775. }
  776. }
  777. }
  778. }
  779. console.log("fileid=========", fileid);
  780. let mclass = [];
  781. if (_this.courseTypeId.length) {
  782. for (var i = 0; i < _this.courseTypeId.length; i++) {
  783. let _sid = _this.courseTypeId[i];
  784. for (
  785. var j = 0;
  786. j <
  787. _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"].length;
  788. j++
  789. ) {
  790. if (
  791. _sid ==
  792. _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j].id
  793. ) {
  794. mclass.push(
  795. _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j]
  796. .name
  797. );
  798. }
  799. }
  800. }
  801. }
  802. let message = "";
  803. if (type == 1) {
  804. message = `NOTICE
  805. Role: 你是ppt内容设计大师,能力是从用户提供的文件资料中提取最重要的学科概念作为ppt参考内容,最后根据Context要求的流程要求输出ppt内容。
  806. Output: Provide your output in json format.
  807. Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
  808. ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
  809. Instruction: Based on the context, follow "Format example", write content.
  810. # Context
  811. ## 任务
  812. 你会收到一节课的教学ppt大纲<大纲内容>,你需要细化大纲每个部分(除了测试题部分),生成详细每一页ppt的内容参考#每一页输出格式。
  813. # 目标
  814. 生成教师可用直接拿来上课的ppt,ppt中用亲切的口吻告诉学生,他们该做什么,以及介绍相关的知识点(知识点需要详细的说明)。必要时使用bullet point。最终生成12页左右的ppt。
  815. # 每一页输出格式
  816. - 页数:序列数字
  817. - 标题:环节
  818. - 子标题:步骤或者知识点或测试题序号
  819. - 内容:用亲切的口吻告诉学生本步骤应做什么?或者是用亲切的口吻向学生介绍知识点,多条时可使用bullet point;或者是给学生测试题。
  820. ## 大纲内容
  821. ${_this.outline.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').replaceAll('\n', '')}
  822. # Format example
  823. [{"page": "页码(数字)","title": "学科概念(请从给你的大纲中摘取)(标题)","task": "知识点(请从给你的大纲中摘取)(子标题)","points": "内容:用亲切的口吻告诉学生本步骤应做什么?或者是用亲切的口吻向学生介绍知识点,多条时可使用bullet point;或者是给学生测试题。"}]`;
  824. } else {
  825. if (this.courseState == 4) {
  826. message = `# 任务
  827. 请根据参考资料,生成关于${this.courseName},为教师生成这节课的教学ppt的大纲,大纲的主要内容课程知识点的讲解与相关练习和测试。你的输出应该符合#输出格式
  828. ${mclass.length ? "#参考资料\n面向年级:" + mclass.join(",") : ""}
  829. # 输出格式
  830. - 标题:
  831. --步骤
  832. --知识点
  833. # 限制
  834. - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
  835. - 你不能输出违反伦理的内容`;
  836. } else if (this.courseState == 5) {
  837. message = `# 任务
  838. 请根据<任务教案>,为教师生成本的教学ppt的大纲,大纲包含各环节的步骤,学科知识点。
  839. # 参考资料
  840. 任务教案:${_this.unitJson[0].chapterInfo[0].taskJson[_this.lineCount].taskDetail3.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').replaceAll('\n', '')}
  841. ${mclass.length ? "面向年级:" + mclass.join(",") : ""}
  842. # 输出格式
  843. - 标题:
  844. --步骤
  845. --知识点
  846. # 限制
  847. - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
  848. - 你不能输出违反伦理的内容
  849. `
  850. }
  851. }
  852. // let params = JSON.stringify({
  853. // // "model": "Chat",
  854. // model: 'gpt-3.5-turbo',
  855. // temperature: 0,
  856. // max_tokens: 4096,
  857. // top_p: 1,
  858. // frequency_penalty: 0,
  859. // presence_penalty: 0,
  860. // messages: [{
  861. // content: message,
  862. // role: 'user'
  863. // }],
  864. // stream: false,
  865. // uid: this.userid,
  866. // mind_map_question: "",
  867. // })
  868. // _this.loading = true
  869. // _this.ajax.post('https://gpt4.cocorobo.cn/chat', params).then(function (response) {
  870. // console.log(response);
  871. // let data = response.data.FunctionResponse
  872. // if (data.choices && data.choices.length && data.choices[0].message) {
  873. // console.log(data.choices[0].message.content);
  874. // try {
  875. // let _data = JSON.parse(data.choices[0].message.content)
  876. // _this.createPpt(_data)
  877. // } catch (e) {
  878. // console.log('error_________________'+e);
  879. // _this.$message.error(data.choices[0].message.content)
  880. // _this.loading = false
  881. // }
  882. // }
  883. // }).catch(function (error) {
  884. // _this.loading = false
  885. // console.log(error);
  886. // });
  887. let parm = {
  888. assistant_id:
  889. type == 1
  890. ? "6063369f-289a-11ef-8bf4-12e77c4cb76b"
  891. : "f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b",
  892. message: [{ type: "text", text: message.replaceAll('\n', " ") }],
  893. session_name: uuidv4(),
  894. userId: this.userid,
  895. file_ids: fileid.length ? [...fileid] : "",
  896. };
  897. _this.loading = true;
  898. this.ajax
  899. .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", parm)
  900. .then((response) => {
  901. console.log(response);
  902. let data = response.data.FunctionResponse;
  903. if (data.message) {
  904. console.log(data.message);
  905. if (type == 1) {
  906. try {
  907. let _data = JSON.parse(
  908. data.message.replaceAll("```json", "").replaceAll("```", "")
  909. );
  910. _this.createPpt(_data);
  911. _this.steps = 2;
  912. } catch (e) {
  913. console.log("error_________________" + e);
  914. // _this.$message.error(data.message)
  915. try {
  916. let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
  917. let match = data.message.match(regex);
  918. let _data2 = JSON.parse(match[0]);
  919. _this.createPpt(_data2);
  920. _this.steps = 2;
  921. // let _data = JSON.parse(data.message.match(/(?<=```json).*?(?=```)/)[0])
  922. // var message = data.message;
  923. // var jsonStart = message.indexOf("```json") + 7; // `+ 7` 是为了跳过 ```json
  924. // var jsonEnd = message.indexOf("```", jsonStart);
  925. // if (jsonStart !== -1 && jsonEnd !== -1) {
  926. // var jsonString = message
  927. // .substring(jsonStart, jsonEnd)
  928. // .trim();
  929. // var _data2 = JSON.parse(jsonString);
  930. // _this.createPpt(_data2);
  931. // _this.steps = 2;
  932. // } else {
  933. // _this.$message.error("生成失败,正在重新生成");
  934. // _this.aiGet(type);
  935. // }
  936. } catch (error) {
  937. _this.$message.error("生成失败,正在重新生成");
  938. _this.loading = false;
  939. _this.aiGet(type);
  940. }
  941. }
  942. } else {
  943. _this.outline = data.message;
  944. _this.steps = 1;
  945. _this.loading = false;
  946. }
  947. }
  948. })
  949. .catch((error) => {
  950. _this.loading = false;
  951. console.log(error);
  952. });
  953. },
  954. generateRandomNumber(min, max) {
  955. // min 是随机数范围的最小值,max 是随机数范围的最大值
  956. return Math.floor(Math.random() * (max - min + 1)) + min;
  957. },
  958. createPpt(arr) {
  959. let array = arr
  960. // 1. 创建PPT
  961. const pres = new Pptxgen();
  962. const _slideTou = pres.addSlide();
  963. _slideTou.background = { path: this.templateList[this.templateIndex].img1.img }
  964. let title = ''
  965. if (this.courseState == 4) {
  966. title = this.courseName
  967. } else if (this.courseState == 5) {
  968. title = this.unitJson[0].chapterInfo[0].taskJson[this.lineCount].task
  969. }
  970. _slideTou.addText(title, this.templateList[this.templateIndex].img1.setting);
  971. for (var i = 0; i < array.length; i++) {
  972. // 2. 创建一个PPT页面,每调用一次 pres.addSlide() 都可以生成一张新的页面
  973. // 建议把每个页面的构造抽成一个个函数,然后通过函数调用生成新页面,代码不会很乱
  974. const _slide = pres.addSlide();
  975. const randomNum = this.generateRandomNumber(0, (this.templateList[this.templateIndex].img2.length - 1))
  976. let pContent = this.templateList[this.templateIndex].img2[randomNum]
  977. _slide.background = { path: pContent.img }
  978. // 3. 调用addTetx(),在PPT页面中插入文字“Hello World from PptxGenJS...”
  979. // 括号里面是对文字的配置,文字横坐标x为1.5,纵坐标y为1.5,字体颜色 363636……
  980. // 关于坐标长度与px的转换 x 1 = 127~128px 左右
  981. const page = i + 1 > 10 ? i + 1 : "0" + (i + 1);
  982. if(pContent.square){
  983. _slide.addText("", pContent.square);
  984. _slide.addText("", pContent.square2);
  985. }
  986. if(pContent.image){
  987. _slide.addImage(pContent.image);
  988. }
  989. const tempResult1 = page + " " + array[i].title;
  990. _slide.addText(tempResult1, pContent.title);
  991. const tempResult2 = array[i].task;
  992. _slide.addText(tempResult2, pContent.subTitle);
  993. let tempResult3 = '';
  994. if (typeof array[i].points == 'object') {
  995. if (Array.isArray(array[i].points)) {
  996. tempResult3 = array[i].points.join('\n')
  997. } else {
  998. tempResult3 = JSON.stringify(array[i].points)
  999. }
  1000. } else {
  1001. tempResult3 = array[i].points
  1002. }
  1003. _slide.addText(tempResult3, pContent.content);
  1004. }
  1005. const _slideWei = pres.addSlide();
  1006. _slideWei.background = { path: this.templateList[this.templateIndex].imgEnd.img }
  1007. _slideWei.addText("谢谢观看,下课!", this.templateList[this.templateIndex].imgEnd.setting);
  1008. // 获取PPTX文件的ArrayBuffer
  1009. // 保存为 Blob 并处理
  1010. pres.write("blob").then((blob) => {
  1011. // 现在你有了一个 Blob 对象
  1012. console.log(blob);
  1013. const file = new File([blob], title + ".pptx", {
  1014. type: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  1015. });
  1016. console.log(pres);
  1017. this.beforeUpload(file);
  1018. });
  1019. },
  1020. beforeUpload(event) {
  1021. var file = event;
  1022. var credentials = {
  1023. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  1024. secretAccessKey: "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",
  1025. }; //秘钥形式的登录上传
  1026. window.AWS.config.update(credentials);
  1027. window.AWS.config.region = "cn-northwest-1"; //设置区域
  1028. var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  1029. var _this = this;
  1030. if (file) {
  1031. var params = {
  1032. Key:
  1033. file.name.split(".")[0] +
  1034. new Date().getTime() +
  1035. "." +
  1036. file.name.split(".")[file.name.split(".").length - 1],
  1037. ContentType: file.type,
  1038. Body: file,
  1039. "Access-Control-Allow-Credentials": "*",
  1040. ACL: "public-read",
  1041. }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  1042. var options = {
  1043. partSize: 2048 * 1024 * 1024,
  1044. queueSize: 2,
  1045. leavePartsOnError: true,
  1046. };
  1047. bucket
  1048. .upload(params, options)
  1049. .on("httpUploadProgress", function (evt) {
  1050. //这里可以写进度条
  1051. // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
  1052. })
  1053. .send(function (err, data) {
  1054. _this.loading = false;
  1055. if (err) {
  1056. _this.$message.error("上传失败");
  1057. } else {
  1058. _this.url = data.Location;
  1059. _this.uJson = {
  1060. name: file.name,
  1061. url: data.Location,
  1062. type: 3,
  1063. };
  1064. console.log(data.Location);
  1065. }
  1066. });
  1067. }
  1068. },
  1069. changeTemplate(index) {
  1070. this.templateIndex = index;
  1071. }
  1072. },
  1073. };
  1074. </script>
  1075. <style scoped>
  1076. .dialog_diy>>>.el-dialog {
  1077. height: auto;
  1078. margin: 15vh auto 0 !important;
  1079. }
  1080. .dialog_diy>>>.el-dialog__header {
  1081. background: #454545 !important;
  1082. padding: 15px 20px;
  1083. }
  1084. .dialog_diy>>>.el-dialog__body {
  1085. height: calc(100% - 124px);
  1086. box-sizing: border-box;
  1087. padding: 0px;
  1088. }
  1089. .dialog_diy>>>.el-dialog__title {
  1090. color: #fff;
  1091. }
  1092. .dialog_diy>>>.el-dialog__headerbtn {
  1093. top: 19px;
  1094. }
  1095. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
  1096. color: #fff;
  1097. }
  1098. .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
  1099. color: #fff;
  1100. }
  1101. .dialog_diy>>>.el-dialog__body,
  1102. .dialog_diy>>>.el-dialog__footer {
  1103. background: #fafafa;
  1104. }
  1105. .binfo_input {
  1106. width: 100%;
  1107. margin: 0;
  1108. padding: 5px 7px;
  1109. display: block;
  1110. min-width: 0;
  1111. outline: none;
  1112. box-sizing: border-box;
  1113. background: none;
  1114. border: none;
  1115. border-radius: 4px;
  1116. background: #fff;
  1117. font-size: 15px;
  1118. resize: none;
  1119. font-family: "Microsoft YaHei";
  1120. min-height: 48px;
  1121. /* border: 1px solid #3682fc00; */
  1122. border: 1.5px solid #cad1dc;
  1123. }
  1124. .binfo_textarea {
  1125. border: 1.5px solid #cad1dc;
  1126. font-size: 15px;
  1127. resize: none;
  1128. /* background: #f6f6f6; */
  1129. font-family: "Microsoft YaHei";
  1130. }
  1131. .binfo_textarea:focus-visible {
  1132. border: 1.5px solid #3681fc !important;
  1133. }
  1134. .binfo_textarea::-webkit-scrollbar {
  1135. /*滚动条整体样式*/
  1136. width: 6px;
  1137. /*高宽分别对应横竖滚动条的尺寸*/
  1138. height: 6px;
  1139. }
  1140. /*定义滚动条轨道 内阴影+圆角*/
  1141. .binfo_textarea::-webkit-scrollbar {
  1142. border-radius: 10px;
  1143. background-color: #eee;
  1144. }
  1145. /*定义滑块 内阴影+圆角*/
  1146. .binfo_textarea::-webkit-scrollbar-thumb {
  1147. border-radius: 10px;
  1148. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  1149. background-color: rgba(0, 0, 0, 0.1);
  1150. }
  1151. .t_box {
  1152. display: flex;
  1153. margin-bottom: 15px;
  1154. display: flex;
  1155. justify-content: space-between;
  1156. }
  1157. .t_box>span:nth-child(1) {
  1158. min-width: 80px;
  1159. font-size: 16px;
  1160. color: #000;
  1161. }
  1162. .template_box {
  1163. width: 250px;
  1164. }
  1165. .template_box>.title {
  1166. font-size: 18px;
  1167. margin-bottom: 10px;
  1168. display: block;
  1169. }
  1170. .template_list {
  1171. overflow: auto;
  1172. width: 100%;
  1173. height: calc(100% - 31px);
  1174. }
  1175. .template_item {
  1176. cursor: pointer;
  1177. width: 100%;
  1178. height: 165px;
  1179. overflow: hidden;
  1180. border-radius: 5px;
  1181. box-sizing: border-box;
  1182. border: 5px solid #e5e5e5ee;
  1183. }
  1184. .template_item+.template_item {
  1185. margin-top: 10px;
  1186. }
  1187. .template_item.active {
  1188. border: 5px solid #0061ff;
  1189. }
  1190. .template_item>img {
  1191. width: 100%;
  1192. height: 100%;
  1193. object-fit: cover;
  1194. }
  1195. </style>