12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493 |
- <template>
- <el-dialog title="AI生成PPT" :visible.sync="dialogVisibleAiCreate" :append-to-body="true" width="700px" :before-close="handleClose" class="dialog_diy">
- <div style="height: 500px; padding: 15px" v-loading="loading" element-loading-text="小可正在努力生成中,请稍等...">
- <div class="c_pub_button_confirm stopBtn" v-if="loading && stopPpt" @click="cancelAjax()">停止</div>
- <!-- <div class="t_box">
- <span>选择:</span>
- <el-radio-group v-model="radio" @change="changeRadio">
- <el-radio :label="0">PPT</el-radio>
- <el-radio :label="1">教案</el-radio>
- <el-radio :label="2">视频</el-radio>
- </el-radio-group>
- </div> -->
- <div class="t_box" v-if="steps == 1" style="height: 100%">
- <textarea style="height: 100%; width: calc(100% - 260px)" rows="10" class="binfo_input binfo_textarea" cols placeholder="请生成大纲" v-model="outline"></textarea>
- <div class="template_box">
- <span class="title">选择模板</span>
- <div class="template_list">
- <div class="template_item" :class="{ active: index == templateIndex }" v-for="(item, index) in templateList" :key="index" @click="changeTemplate(index)">
- <img :src="item.img" alt="" />
- </div>
- </div>
- </div>
- </div>
- <div style="height: 100%" v-else>
- <wOffice v-if="url" :url="url"></wOffice>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="aiGet()" type="primary" :disabled="loading || tloading">重新生成大纲</el-button>
- <el-button @click="aiGetPPt()" type="primary" :disabled="loading || tloading">{{ url ? "重新生成PPT" : "生成PPT" }}</el-button>
- <el-button @click="steps = 1" type="primary" v-if="steps == 2">上一步</el-button>
- <el-button @click="steps = 2" type="primary" v-else-if="steps == 1 && url">下一步</el-button>
- <el-button @click="confirm" type="primary">确 定</el-button>
- <el-button @click="close">关 闭</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import Pptxgen from "pptxgenjs";
- import wOffice from "../components/wOffice.vue";
- import { v4 as uuidv4 } from "uuid";
- var OpenCC = require("opencc-js");
- let converter2 = OpenCC.Converter({
- from: 'cn',
- to: 'hk'
- })
- export default {
- components: {
- wOffice,
- },
- props: {
- dialogVisibleAiCreate: {
- type: Boolean,
- default: false,
- },
- courseName: {
- type: String,
- default: "",
- },
- infoData: {
- type: Array,
- default: "",
- },
- courseTypeId: {
- type: Array,
- default: "",
- },
- CourseTypeJson: {
- type: Object,
- default: () => ({}),
- },
- courseState: {
- type: Number,
- },
- lineCount: {
- type: Number,
- },
- unitJson: {
- type: Array,
- },
- languageSetting: {
- type: Number,
- default: 0,
- }
- },
- // 根据用户给你的参考资料
- data() {
- return {
- userid: this.$route.query.userid,
- radio: 0,
- aiJson: {
- ppt: `## 任务
- 请生成关于${this.courseName},为教师生成这节课的教学ppt,页数在20页左右。PPT的内容主要是讲解该课程中所有可能涉及到的知识点。
- ## 工作流
- 1. 从用户提供的参考资料中提取10个最重要的知识点(知识点水平限制在小学和初中),并输出。
- 2. 针对10个知识点中的每个,你使用1~3页ppt详细的对知识点进行讲解。你的讲解词应该在100token左右
- 3. 讲解完所有知识点后,再根据知识点出5道单选题(放在5页ppt中)
- ## 限制
- - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
- - 你不能输出违反伦理的内容`,
- word: "",
- video: "",
- },
- aiUrl: {
- ppt: "",
- word: "",
- video: "",
- },
- detail: "",
- loading: false,
- tloading: false,
- tcancelSource: null,
- stopPpt: null,
- url: "",
- uJson: {},
- outline: "",
- steps: 1,
- // templateList: [
- // // { 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' },
- // // { 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' },
- // // { 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' },
- // // { 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' },
- // // { 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' },
- // { img: require('../../../assets/icon/ppt/model1-1.png'), img2: require('../../../assets/icon/ppt/model1-2.png'),color:'17094F' },
- // { img: require('../../../assets/icon/ppt/model2-1.png'), img2: require('../../../assets/icon/ppt/model2-2.png'),color:'052B37' },
- // { img: require('../../../assets/icon/ppt/model3-1.png'), img2: require('../../../assets/icon/ppt/model3-2.png'),color:'1D5869' },
- // { img: require('../../../assets/icon/ppt/model4-1.png'), img2: require('../../../assets/icon/ppt/model4-2.png'),color:'372213' },
- // { img: require('../../../assets/icon/ppt/model5-1.png'), img2: require('../../../assets/icon/ppt/model5-2.png'),color:'674D40' },
- // ],
- templateList: [{
- img: require('../../../assets/icon/ppt/model6-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model6-1-2.png'),
- setting: {
- x: "35%",
- y: 2.3,
- w: "60%",
- bold: true,
- color: 'EA7A93',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '4F73DA',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }, //内容页1
- {
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: "2.5%", // 横坐标
- y: 2.3,
- w: "30%",
- color: 'ffffff',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "left",
- },
- subTitle: {
- x: "2.5%", // 横坐标
- y: 3.1,
- w: "30%",
- color: "ffffff",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "45%", // 横坐标
- y: 2.8,
- w: "45%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- square: {
- x: 0,
- y: 0,
- w: "35%",
- h: "100%",
- fill: { color: "4F73DA" }
- },
- square2: {
- x: "35%",
- y: 0,
- w: "2.5%",
- h: "100%",
- fill: { color: "C2CFEF" }
- }
- }, //内容页2
- {
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1,
- w: "60%",
- color: '4F73DA',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "left",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.7,
- w: "60%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "5%", // 横坐标
- y: 2.5,
- w: "60%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- image: {
- x: "70%",
- y: "22%",
- w: "30%",
- h: "56%",
- sizing: "contain",
- path: require('../../../assets/icon/ppt/model6-3.png')
- },
- }, //内容页3
- {
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: "10%", // 横坐标
- y: "4%",
- h: 0.75,
- w: "80%",
- color: 'ffffff',
- fill: { color: "4F73DA" },
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "10%", // 横坐标
- y: 1.5,
- w: "80%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "10%", // 横坐标
- y: 2.3,
- w: "80%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- image: {
- x: "2.5%",
- y: "10%",
- w: "95%",
- h: "80%",
- sizing: "contain",
- path: require('../../../assets/icon/ppt/model6-4.png')
- },
- }, //内容页4
- {
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: 0, // 横坐标
- y: "30%",
- w: "35%",
- h: "40%",
- color: 'ffffff',
- bold: true,
- fontSize: 30, // 字号
- fontFace: '黑体',
- align: "right",
- fill: { color: "4F73DA" },
- margin: 10,
- },
- subTitle: {
- x: "37.5%", // 横坐标
- y: 1,
- w: "53%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "37.5%", // 横坐标
- y: 2,
- w: "53%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- square: {
- x: "5%",
- y: "10%",
- w: "90%",
- h: "80%",
- fill: { color: "ffffff" },
- line: {
- width: '2',
- color: "3B4564"
- }
- },
- }, //内容页5
- {
- img: require('../../../assets/icon/ppt/model6-2.png'),
- title: {
- x: "17%", // 横坐标
- y: "20%",
- h: 0.75,
- w: "66%",
- color: 'ffffff',
- fill: { color: "4F73DA" },
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 3,
- w: "90%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "5%", // 横坐标
- y: 3.8,
- w: "90%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- image: {
- x: 0,
- y: 0,
- w: "100%",
- h: "45%",
- sizing: "contain",
- path: require('../../../assets/icon/ppt/model6-6.png')
- },
- }, //内容页6
- {
- img: require('../../../assets/icon/ppt/model6-7-1.png'),
- title: {
- x: "45%", // 横坐标
- y: 1.3,
- w: "50%",
- color: '4F73DA',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "left",
- },
- subTitle: {
- x: "45%", // 横坐标
- y: 2,
- w: "50%",
- color: "333333",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "left",
- },
- content: {
- x: "45%", // 横坐标
- y: 3.2,
- w: "50%",
- color: "333333",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- },
- image: {
- x: "20%",
- y: 0,
- w: "80%",
- h: "100%",
- sizing: "contain",
- path: require('../../../assets/icon/ppt/model6-7-2.png')
- },
- }, //内容页7
- ],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model6-1-2.png'),
- setting: {
- x: "35%",
- y: 2.3,
- w: "60%",
- color: 'EA7A93',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- },
- {
- img: require('../../../assets/icon/ppt/model1-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model1-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '17094F',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model1-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '17094F',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "222222",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "444444",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model1-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '17094F',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- }
- },
- {
- img: require('../../../assets/icon/ppt/model2-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model2-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '052B37',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model2-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '052B37',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "222222",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "444444",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model2-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '052B37',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- }
- },
- {
- img: require('../../../assets/icon/ppt/model3-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model3-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '1D5869',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model3-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '1D5869',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "222222",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "444444",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model3-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '1D5869',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- }
- },
- {
- img: require('../../../assets/icon/ppt/model4-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model4-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '372213',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model4-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '372213',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "222222",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "444444",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model4-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '372213',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- color: '372213'
- },
- {
- img: require('../../../assets/icon/ppt/model5-1.png'),
- img1: {
- img: require('../../../assets/icon/ppt/model5-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '674D40',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- img2: [{
- img: require('../../../assets/icon/ppt/model5-2.png'),
- title: {
- x: "5%", // 横坐标
- y: 1.1,
- w: "90%",
- color: '674D40',
- bold: true,
- fontSize: 35, // 字号
- fontFace: '黑体',
- align: "center",
- },
- subTitle: {
- x: "5%", // 横坐标
- y: 1.8,
- w: "90%",
- color: "222222",
- fontSize: 20, // 字号
- fontFace: '黑体',
- align: "center",
- },
- content: {
- x: "20%", // 横坐标
- y: 3.2,
- w: "60%",
- color: "444444",
- fontSize: 18, // 字号
- fontFace: '黑体',
- align: "left",
- }
- }],
- imgEnd: {
- img: require('../../../assets/icon/ppt/model5-1.png'),
- setting: {
- x: "5%",
- y: 3,
- w: "90%",
- color: '674D40',
- fontSize: 38,
- fontFace: '黑体',
- align: "center",
- }
- },
- },
- ],
- templateIndex: 0,
- };
- },
- watch: {
- dialogVisibleAiCreate(newValue, oldValue) {
- if (newValue) {
- this.loading = false;
- this.aiGet();
- // this.templateIndex = 5
- // let array = [
- // {
- // "page": 1,
- // "title": "引入阶段",
- // "task": "课程背景",
- // "points": "同学们,让我们一起了解一下这门有趣的熊猫课程吧!今天,我们将探索熊猫的生活环境,并尝试去理解这些环境是如何影响熊猫的生存的。"
- // },
- // {
- // "page": 2,
- // "title": "引入阶段",
- // "task": "整体目标和任务要求",
- // "points": "这门课程的主要目标是让大家了解熊猫生活的环境以及生存所需的关键因素。我们将完成一个任务,具体要求是观察、记录、绘制和制作模型哦!"
- // },
- // {
- // "page": 3,
- // "title": "引入阶段",
- // "task": "驱动性问题",
- // "points": "大家思考一下这样一个问题:‘熊猫的生活环境对它们的生存有何重要影响?’ 我们接下去的活动将帮助大家找到答案。"
- // },
- // {
- // "page": 4,
- // "title": "引入阶段",
- // "task": "观察与记录技巧",
- // "points": "今天我们会运用图片和视频,来帮助大家观察熊猫栖息地和它们所吃的竹子等特征。细心观察,并将所见的特征记录下来是非常重要的技能哦!"
- // },
- // {
- // "page": 5,
- // "title": "探究阶段",
- // "task": "绘图工具和材料",
- // "points": "现在我们分发绘图工具和材料,来学习基本的绘图和建模技巧吧!熟练掌握这些工具会帮助我们更好地记录和展示我们的观察结果。"
- // },
- // {
- // "page": 6,
- // "title": "探究阶段",
- // "task": "观察和记录特征",
- // "points": "让我们好好观察一下身边的常见物体,把它们的特征记录下来。这个过程会训练你们的观察力和手眼协调能力。"
- // },
- // {
- // "page": 7,
- // "title": "探究阶段",
- // "task": "转换二维图像",
- // "points": "接下来,我们要把记录的三维物体转化为二维图像。这个步骤非常有趣,大家可以尽情发挥自己的绘画天赋哦!"
- // },
- // {
- // "page": 8,
- // "title": "探究阶段",
- // "task": "三维模型制作",
- // "points": "现在我们提供一些简单的材料,比如纸张和纸板,示范一下如何制作三维模型。记住,比例和结构是模型制作的关键!"
- // },
- // {
- // "page": 9,
- // "title": "评估与反馈阶段",
- // "task": "评估和检查",
- // "points": "大家完成了任务后,我们来检查和评估你们的二维图像和三维模型。确保它们的结构合理、比例协调。"
- // },
- // {
- // "page": 10,
- // "title": "评估与反馈阶段",
- // "task": "提出改进建议",
- // "points": "针对你们完成的作品,我们会提出一些改进建议。大家也可以相互评价,分享制作经验,这样可以互相学习哦!"
- // },
- // {
- // "page": 11,
- // "title": "评估与反馈阶段",
- // "task": "任务总结",
- // "points": "最后,我们要总结这次任务的执行情况,并表扬表现特别突出的同学。希望大家都能有所收获,并继续努力!"
- // },
- // {
- // "page": 12,
- // "title": "练习",
- // "task": "练习1:二维图像绘制",
- // "points": "选择一件日常物品(如书本、杯子),观察其特征,尝试通过手绘将其转换为二维图像。示例:通过绘制书本的正面、侧面和顶面图,展示其主要特征和比例关系。"
- // },
- // {
- // "page": 13,
- // "title": "练习",
- // "task": "练习2:三维模型制作",
- // "points": "使用纸张和纸板制作简单的模型,比如一个基本的房子或盒子。关注其结构和比例哦! 示例:通过折叠和粘贴纸张,制作一个四面体,确保各个面的比例协调,结构稳定。"
- // }
- // ]
- // this.createPpt(array);
- }
- },
- },
- methods: {
- getLang() {
- let lang = ''
- if (this.languageSetting == 0) {
- lang = 'Chinese.'
- } else if (this.languageSetting == 1) {
- lang = 'Traditional Chinese.'
- } else if (this.languageSetting == 2) {
- lang = 'English.'
- }
- return lang
- },
- cancelAjax() {
- this.$message.success("已经成功停止")
- this.stopPpt.cancel('Request canceled by the user.');
- this.stopPpt = null;
- this.loading = false
- },
- handleClose(done) {
- this.close();
- done();
- },
- close() {
- this.$emit("update:dialogVisibleAiCreate", false);
- },
- confirm() {
- if (this.url) {
- this.$emit("createAiPpt", this.uJson);
- } else {
- this.$message.error("请点击“生成PPT”按钮");
- }
- },
- changeRadio() {
- if (this.radio == 0) {
- this.detail = this.aiJson.ppt;
- }
- if (this.radio == 1) {
- this.detail = this.aiJson.word;
- }
- if (this.radio == 2) {
- this.detail = this.aiJson.video;
- }
- },
- createFileid(url) {
- let _this = this;
- return new Promise((resolve, reject) => {
- try {
- _this.ajax
- .put("https://gpt4.cocorobo.cn/upload_file_knowledge", {
- url: url,
- })
- .then((res) => {
- let _data = res.data.FunctionResponse;
- if (_data.result && _data.result.id) {
- resolve(_data.result.id);
- }
- })
- .catch(function(error) {
- resolve("");
- });
- } catch (e) {
- resolve();
- }
- });
- },
- async aiGetPPt() {
- if (this.loading || this.tloading) {
- this.$message.error("正在生成中,请稍后");
- return;
- }
- let _this = this;
- let fileid = [];
- if (_this.infoData.length) {
- for (var i = 0; i < _this.infoData.length; i++) {
- if (_this.infoData[i].fileid) {
- fileid.push(_this.infoData[i].fileid);
- } else {
- let _fileid = await _this.createFileid(_this.infoData[i].url);
- if (_fileid) {
- _this.infoData[i].fileid = _fileid;
- _this.$forceUpdate();
- fileid.push(_fileid);
- }
- }
- }
- }
- console.log("fileid=========", fileid);
- let mclass = [];
- if (_this.courseTypeId.length) {
- for (var i = 0; i < _this.courseTypeId.length; i++) {
- let _sid = _this.courseTypeId[i];
- for (
- var j = 0; j <
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"].length; j++
- ) {
- if (
- _sid ==
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j].id
- ) {
- mclass.push(
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j]
- .name
- );
- }
- }
- }
- }
- let message = "";
- if (!_this.outline) {
- _this.$message.error("请先生成大纲内容");
- return;
- }
- message = `NOTICE
- Role: 你是ppt内容设计大师,能力是从用户提供的文件资料中提取最重要的学科概念作为ppt参考内容,最后根据Context要求的流程要求输出ppt内容。
- Output: Provide your output in json format.
- Language: ${this.getLang()}
- ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
- Instruction: Based on the context, follow "Format example", write content.
- # Context
- ## 任务
- 你会收到一节课的教学ppt大纲<大纲内容>,你需要细化大纲每个部分(除了测试题部分),生成详细每一页ppt的内容参考#每一页输出格式。
- # 目标
- 生成教师可用直接拿来上课的ppt,ppt中用亲切的口吻告诉学生,他们该做什么,以及介绍相关的知识点(知识点需要详细的说明)。必要时使用bullet point。最终生成12页左右的ppt。
- # 每一页输出格式
- - 页数:序列数字
- - 标题:环节
- - 子标题:步骤或者知识点或测试题序号
- - 内容:用亲切的口吻告诉学生本步骤应做什么?或者是用亲切的口吻向学生介绍知识点,多条时可使用bullet point;或者是给学生测试题。
- ## 大纲内容
- ${_this.outline.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').replaceAll('\n', '')}
- # Format example
- [{"page": "页码(数字)","title": "学科概念(请从给你的大纲中摘取)(标题)","task": "知识点(请从给你的大纲中摘取)(子标题)","points": "内容:用亲切的口吻告诉学生本步骤应做什么?或者是用亲切的口吻向学生介绍知识点,多条时可使用bullet point;或者是给学生测试题。"}]`;
- this.url = "";
- this.uJson = {};
- _this.stopPpt = _this.ajax.setCancelSource();
- let parm = {
- assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
- message: [{ type: "text", text: this.languageSetting == 1 ? converter2(message.replaceAll('\n', " ")) : message.replaceAll('\n', " ") }],
- session_name: uuidv4(),
- userId: this.userid,
- file_ids: fileid.length ? [...fileid] : "",
- model: 'gpt-4o-2024-08-06',
- };
- _this.loading = true;
- this.ajax
- .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", parm, _this.stopPpt)
- .then((response) => {
- console.log(response);
- let data = response.data.FunctionResponse;
- if (data.message) {
- console.log(data.message);
- try {
- let _data = JSON.parse(
- data.message.replaceAll("```json", "").replaceAll("```", "")
- );
- _this.createPpt(_data);
- _this.steps = 2;
- } catch (e) {
- console.log("error_________________" + e);
- try {
- let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
- let match = data.message.match(regex);
- let _data2 = JSON.parse(match[0]);
- _this.createPpt(_data2);
- _this.steps = 2;
- } catch (error) {
- _this.$message.error("生成失败,正在重新生成");
- _this.loading = false;
- _this.stopPpt = null
- _this.aiGetPPt();
- }
- }
- }
- })
- .catch((error) => {
- _this.loading = false;
- _this.stopPpt = null
- console.log(error);
- });
- },
- async aiGet() {
- if (this.loading || this.tloading) {
- this.$message.error("正在生成中,请稍后");
- return;
- }
- let _this = this;
- let fileid = [];
- if (_this.infoData.length) {
- for (var i = 0; i < _this.infoData.length; i++) {
- if (_this.infoData[i].fileid) {
- fileid.push(_this.infoData[i].fileid);
- } else {
- let _fileid = await _this.createFileid(_this.infoData[i].url);
- if (_fileid) {
- _this.infoData[i].fileid = _fileid;
- _this.$forceUpdate();
- fileid.push(_fileid);
- }
- }
- }
- }
- console.log("fileid=========", fileid);
- let mclass = [];
- if (_this.courseTypeId.length) {
- for (var i = 0; i < _this.courseTypeId.length; i++) {
- let _sid = _this.courseTypeId[i];
- for (
- var j = 0; j <
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"].length; j++
- ) {
- if (
- _sid ==
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j].id
- ) {
- mclass.push(
- _this.CourseTypeJson["34628934-d02f-11ec-8c78-005056b86db5"][j]
- .name
- );
- }
- }
- }
- }
- let message = "";
- if (this.courseState == 4) {
- message = `NOTICE Language: ${this.getLang()}
- # 任务
- 请根据参考资料,生成关于${this.courseName},为教师生成这节课的教学ppt的大纲,大纲的主要内容课程知识点的讲解与相关练习和测试。你的输出应该符合#输出格式
- ${mclass.length ? "#参考资料\n面向年级:" + mclass.join(",") : ""}
- # 输出格式
- - 标题:
- --步骤
- --知识点
- # 限制
- - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
- - 你不能输出违反伦理的内容`;
- } else if (this.courseState == 5) {
- message = `NOTICE Language: ${this.getLang()}
- # 任务
- 请根据<任务教案>,为教师生成本的教学ppt的大纲,大纲包含各环节的步骤,学科知识点。
- # 参考资料
- 任务教案:${_this.unitJson[0].chapterInfo[0].taskJson[_this.lineCount].taskDetail3.replaceAll('#', '').replaceAll('*', '').replaceAll('-', '').replaceAll('\n', '')}
- ${mclass.length ? "面向年级:" + mclass.join(",") : ""}
- # 输出格式
- - 标题:
- --步骤
- --知识点
- # 限制
- - 你不能输出错误的知识,如果你实在不清楚,输出“对不起,我不确定”
- - 你不能输出违反伦理的内容
- `
- }
- this.url = "";
- this.uJson = {};
- let _uid = uuidv4()
- _this.stopPpt = _this.ajax.setCancelSource();
- let parm = {
- assistant_id: "f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b",
- message: [{ type: "text", text: this.languageSetting == 1 ? converter2(message.replaceAll('\n', " ")) : message.replaceAll('\n', " ") }],
- session_name: _uid,
- userId: _this.userid,
- uid: _uid,
- file_ids: fileid.length ? [...fileid] : "",
- model: 'gpt-4o-2024-08-06',
- };
- _this.loading = true;
- _this.tloading = true;
- _this.ajax
- .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", parm, _this.stopPpt)
- .then((response) => {
- let data = response.data.FunctionResponse;
- console.log(response);
- if (converter2(response.data.FunctionResponse.result) == converter2("发送成功")) {} else {
- _this.$message.warning(response.data.FunctionResponse.result);
- }
- // if (data.message) {
- // console.log(data.message);
- // _this.outline = data.message;
- // _this.steps = 1;
- // _this.stopPpt = null
- // _this.loading = false;
- // }
- })
- .catch((error) => {
- _this.loading = false;
- _this.tloading = false;
- _this.stopPpt = null
- console.log(error);
- });
- await _this.aiGetgetAiContent(_uid)
- },
- aiGetgetAiContent(_uid) {
- try {
- this.tcancelSource = new EventSource(`https://gpt4.cocorobo.cn/question/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/ https://gpt4.cocorobo.cn/stream/
- } catch (error) {
- console.log('EventSource error:', error);
- this.$message.error("哎呀,请求太多了,服务器忙不过来了,请稍等再重试")
- this.loading = false
- this.tLoading = false
- this.tcancelSource = null
- return;
- }
- let _allText = "";
- let _mdText = "";
- let _iindex = 0
- this.tcancelSource.onmessage = _e => {
- let _eData = JSON.parse(_e.data).content;
- if (_eData.replace("'", "").replace("'", "") == "[DONE]") {
- //对话已经完成
- _mdText = _mdText.replace("_", "").replace(/【[^】]*source[^】]*】/g, '').replaceAll("<br>", "");
- this.tcancelSource.close();
- this.tcancelSource = null;
- this.outline = _mdText;
- this.loading = false
- this.tloading = false
- this.stopPpt = null
- return;
- } else {
- _iindex++
- //对话还在继续
- let _text = "";
- _text = _eData.replaceAll("'", "");
- if (_allText == "") {
- _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
- } else {
- _allText += _text;
- }
- _mdText = _allText + "_";
- _mdText = _mdText.replace(/\\n/g, "\n");
- _mdText = _mdText.replace(/\\/g, "");
- if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
- //转化返回的回复流数据
- if (_iindex == 10) {
- this.outline = _mdText;
- _iindex = 0
- }
- if(this.loading){
- this.loading = false
- this.steps = 1;
- }
- // 处理流数据
- }
- // this.$forceUpdate();
- };
- let _this = this
- this.tcancelSource.onerror = function(event) {
- // 处理错误,可以尝试重新连接
- console.log('EventSource error:', event);
- _this.$message.error("哎呀,请求太多了,服务器忙不过来了,请稍等再重试")
- _this.loading = false
- _this.tloading = false
- _this.stopPpt = null
- _this.tcancelSource.close();
- _this.tcancelSource = null;
- };
- },
- generateRandomNumber(min, max) {
- // min 是随机数范围的最小值,max 是随机数范围的最大值
- return Math.floor(Math.random() * (max - min + 1)) + min;
- },
- createPpt(arr) {
- let array = arr
- // 1. 创建PPT
- const pres = new Pptxgen();
- const _slideTou = pres.addSlide();
- _slideTou.background = { path: this.templateList[this.templateIndex].img1.img }
- let title = ''
- if (this.courseState == 4) {
- title = this.courseName
- } else if (this.courseState == 5) {
- title = this.unitJson[0].chapterInfo[0].taskJson[this.lineCount].task
- }
- _slideTou.addText(title, this.templateList[this.templateIndex].img1.setting);
- for (var i = 0; i < array.length; i++) {
- // 2. 创建一个PPT页面,每调用一次 pres.addSlide() 都可以生成一张新的页面
- // 建议把每个页面的构造抽成一个个函数,然后通过函数调用生成新页面,代码不会很乱
- const _slide = pres.addSlide();
- const randomNum = this.generateRandomNumber(0, (this.templateList[this.templateIndex].img2.length - 1))
- let pContent = this.templateList[this.templateIndex].img2[randomNum]
- _slide.background = { path: pContent.img }
- // 3. 调用addTetx(),在PPT页面中插入文字“Hello World from PptxGenJS...”
- // 括号里面是对文字的配置,文字横坐标x为1.5,纵坐标y为1.5,字体颜色 363636……
- // 关于坐标长度与px的转换 x 1 = 127~128px 左右
- const page = i + 1 > 10 ? i + 1 : "0" + (i + 1);
- if (pContent.square) {
- _slide.addText("", pContent.square);
- _slide.addText("", pContent.square2);
- }
- if (pContent.image) {
- _slide.addImage(pContent.image);
- }
- const tempResult1 = page + " " + array[i].title;
- _slide.addText(tempResult1, pContent.title);
- const tempResult2 = array[i].task;
- _slide.addText(tempResult2, pContent.subTitle);
- let tempResult3 = '';
- if (typeof array[i].points == 'object') {
- if (Array.isArray(array[i].points)) {
- for (var k = 0; k < array[i].points.length; k++) {
- array[i].points[k] = '· ' + array[i].points[k]
- }
- tempResult3 = array[i].points.join('\n')
- } else {
- tempResult3 = JSON.stringify(array[i].points)
- }
- } else {
- tempResult3 = array[i].points
- }
- _slide.addText(tempResult3, pContent.content);
- }
- const _slideWei = pres.addSlide();
- _slideWei.background = { path: this.templateList[this.templateIndex].imgEnd.img }
- _slideWei.addText("谢谢观看,下课!", this.templateList[this.templateIndex].imgEnd.setting);
- // 获取PPTX文件的ArrayBuffer
- // 保存为 Blob 并处理
- pres.write("blob").then((blob) => {
- // 现在你有了一个 Blob 对象
- console.log(blob);
- const file = new File([blob], title + ".pptx", {
- type: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
- });
- console.log(pres);
- this.beforeUpload(file);
- });
- },
- beforeUpload(event) {
- var file = event;
- var credentials = {
- accessKeyId: "AKIATLPEDU37QV5CHLMH",
- secretAccessKey: "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",
- }; //秘钥形式的登录上传
- window.AWS.config.update(credentials);
- window.AWS.config.region = "cn-northwest-1"; //设置区域
- var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
- var _this = this;
- if (file) {
- var params = {
- Key: file.name.split(".")[0] +
- new Date().getTime() +
- "." +
- file.name.split(".")[file.name.split(".").length - 1],
- ContentType: file.type,
- Body: file,
- "Access-Control-Allow-Credentials": "*",
- ACL: "public-read",
- }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
- var options = {
- partSize: 2048 * 1024 * 1024,
- queueSize: 2,
- leavePartsOnError: true,
- };
- bucket
- .upload(params, options)
- .on("httpUploadProgress", function(evt) {
- //这里可以写进度条
- // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
- })
- .send(function(err, data) {
- _this.loading = false;
- if (err) {
- _this.$message.error("上传失败");
- } else {
- _this.url = data.Location;
- _this.uJson = {
- name: file.name,
- url: data.Location,
- type: 3,
- };
- console.log(data.Location);
- }
- });
- }
- },
- changeTemplate(index) {
- this.templateIndex = index;
- }
- },
- };
- </script>
- <style scoped>
- .dialog_diy>>>.el-dialog {
- height: auto;
- margin: 15vh auto 0 !important;
- }
- .dialog_diy>>>.el-dialog__header {
- background: #454545 !important;
- padding: 15px 20px;
- }
- .dialog_diy>>>.el-dialog__body {
- height: calc(100% - 124px);
- box-sizing: border-box;
- padding: 0px;
- }
- .dialog_diy>>>.el-dialog__title {
- color: #fff;
- }
- .dialog_diy>>>.el-dialog__headerbtn {
- top: 19px;
- }
- .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
- color: #fff;
- }
- .dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
- color: #fff;
- }
- .dialog_diy>>>.el-dialog__body,
- .dialog_diy>>>.el-dialog__footer {
- background: #fafafa;
- }
- .binfo_input {
- width: 100%;
- margin: 0;
- padding: 5px 7px;
- display: block;
- min-width: 0;
- outline: none;
- box-sizing: border-box;
- background: none;
- border: none;
- border-radius: 4px;
- background: #fff;
- font-size: 15px;
- resize: none;
- font-family: "Microsoft YaHei";
- min-height: 48px;
- /* border: 1px solid #3682fc00; */
- border: 1.5px solid #cad1dc;
- }
- .binfo_textarea {
- border: 1.5px solid #cad1dc;
- font-size: 15px;
- resize: none;
- /* background: #f6f6f6; */
- font-family: "Microsoft YaHei";
- }
- .binfo_textarea:focus-visible {
- border: 1.5px solid #3681fc !important;
- }
- .binfo_textarea::-webkit-scrollbar {
- /*滚动条整体样式*/
- width: 6px;
- /*高宽分别对应横竖滚动条的尺寸*/
- height: 6px;
- }
- /*定义滚动条轨道 内阴影+圆角*/
- .binfo_textarea::-webkit-scrollbar {
- border-radius: 10px;
- background-color: #eee;
- }
- /*定义滑块 内阴影+圆角*/
- .binfo_textarea::-webkit-scrollbar-thumb {
- border-radius: 10px;
- -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
- background-color: rgba(0, 0, 0, 0.1);
- }
- .t_box {
- display: flex;
- margin-bottom: 15px;
- display: flex;
- justify-content: space-between;
- }
- .t_box>span:nth-child(1) {
- min-width: 80px;
- font-size: 16px;
- color: #000;
- }
- .template_box {
- width: 250px;
- }
- .template_box>.title {
- font-size: 18px;
- margin-bottom: 10px;
- display: block;
- }
- .template_list {
- overflow: auto;
- width: 100%;
- height: calc(100% - 31px);
- }
- .template_item {
- cursor: pointer;
- width: 100%;
- height: 165px;
- overflow: hidden;
- border-radius: 5px;
- box-sizing: border-box;
- border: 5px solid #e5e5e5ee;
- }
- .template_item+.template_item {
- margin-top: 10px;
- }
- .template_item.active {
- border: 5px solid #0061ff;
- }
- .template_item>img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- .stopBtn {
- z-index: 999999;
- position: absolute;
- left: 50%;
- top: calc(50% + 70px);
- transform: translateX(-50%);
- }
- </style>
|