aiCreateDialog copy.vue 61 KB

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