aiCreateDialog.vue 63 KB

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