index.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  1. <template>
  2. <div class="pptEasyClass">
  3. <div class="pec_main" v-loading="pageLoading">
  4. <!-- 录音转文字 -->
  5. <iframe allow="camera *; microphone *;display-capture;midi;encrypted-media;" :src="iframeSrcop" ref="iiframe"
  6. v-show="false"></iframe>
  7. <div class="pec_header">
  8. <div class="pec_h_left">
  9. <!-- || tType == 1 -->
  10. <div @click.stop="back" class="backBtn" v-if="screenType != 2 && noLogin != 2 ">
  11. <img src="../../assets/icon/newIcon/return.svg" alt="" />
  12. </div>
  13. <div @click.stop="gotoCourseManage" class="backBtn" v-if="screenType == 2 && tType == 1 && noLogin != 2 && noLogin != 4 && noLogin != 3">
  14. <img src="../../assets/icon/newIcon/return.svg" alt="" />
  15. </div>
  16. <div @click.stop="gotoCourseManage2" class="backBtn" v-if="screenType == 2 && tType == 1 && noLogin == 3">
  17. <img src="../../assets/icon/newIcon/return.svg" alt="" />
  18. </div>
  19. <div @click.stop="gotoCourseManage3" class="backBtn" v-if="screenType == 2 && tType == 1 && noLogin == 4">
  20. <img src="../../assets/icon/newIcon/return.svg" alt="" />
  21. </div>
  22. <div v-if="tcid" class="class-info-group">
  23. <span class="class-label">{{ lang.ssClass }}</span>
  24. <span class="class-value class-value2" @click="openSelectClass">
  25. {{ className }}
  26. <svg t="1776672009773" class="xia-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
  27. p-id="4735" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12">
  28. <path
  29. d="M562.5 771c-14.3 14.3-33.7 27.5-52 23.5-18.4 3.1-35.7-11.2-50-23.5L18.8 327.3c-22.4-22.4-22.4-59.2 0-81.6s59.2-22.4 81.6 0L511.5 668l412.1-422.3c22.4-22.4 59.2-22.4 81.6 0s22.4 59.2 0 81.6L562.5 771z"
  30. p-id="4736" fill="currentColor"></path>
  31. </svg>
  32. </span>
  33. </div>
  34. <div v-if="tcid" class="class-info-group">
  35. <span class="class-label" v-if="inviteCode">{{ lang.ssInviteCode }}</span>
  36. <span class="class-value" v-if="inviteCode">{{ inviteCode }}</span>
  37. </div>
  38. <div @click.stop="openShareDialog" class="shareBtn" v-if="tcid && tType == 1">
  39. <img src="../../assets/share.svg" alt="" />
  40. </div>
  41. </div>
  42. <div class="pec_h_center">
  43. <el-tooltip effect="dark" :content="lang.ssRefresh" placement="bottom">
  44. <div class="refresh_icon" @click="refreshCourse">
  45. <img src="../../assets/icon/course/refresh-2.svg" />
  46. </div>
  47. </el-tooltip>
  48. <el-tooltip class="item" effect="dark"
  49. :content="recordedForm.status == 1 ? lang.ssFinishClassRecording : lang.ssBeginClassRecording"
  50. placement="bottom"
  51. v-show="(jArray.includes(oid) || jArray.includes(org)) && courseDetail.userid == userid && tcid">
  52. <div class="pec_h_r_btn_refresh" :class="{ 'recording': recordedForm.status == 1 }"
  53. @click="toggleRecording">
  54. <svg t="1772588344140" viewBox="0 0 1024 1024" p-id="1693" width="200" height="200">
  55. <path
  56. d="M512 1024a512.568889 512.568889 0 0 1-512-512 512.625778 512.625778 0 0 1 512-512 512.568889 512.568889 0 0 1 512 512 512.568889 512.568889 0 0 1-512 512zM512 73.329778c-241.948444 0-438.670222 196.835556-438.670222 438.670222S270.051556 950.670222 512 950.670222s438.670222-196.835556 438.670222-438.670222S753.948444 73.329778 512 73.329778z m0 686.592a245.191111 245.191111 0 1 1 0-490.382222 245.191111 245.191111 0 0 1 0 490.382222z"
  57. p-id="1694"></path>
  58. </svg>
  59. <span>{{ recordedForm.status == 1 ? lang.ssStopRecording2 : lang.ssRecord }}</span>
  60. </div>
  61. </el-tooltip>
  62. <el-tooltip effect="dark" :content="courseDetail.title" placement="bottom">
  63. <div class="pec_h_l_title">
  64. <span>{{ courseDetail.title }}</span>
  65. </div>
  66. </el-tooltip>
  67. <div class="free-browse-switch" v-if="courseDetail.userid == userid">
  68. <el-switch v-model="freeBrowse" :active-value="false" :inactive-value="true" class="custom-switch"
  69. active-color="#03ae2b" inactive-color="#d8d8d8" @change="onFreeBrowseChange"></el-switch>
  70. <span class="switch-label" :class="{ active: freeBrowse }">{{ freeBrowse ? lang.ssFreeBrowse :
  71. lang.ssFollowMode }}</span>
  72. </div>
  73. <!-- <div class="free-browse-switch" v-if="courseDetail.userid == userid">
  74. <el-switch v-model="isCan" :active-value="true" :inactive-value="false" class="custom-switch"
  75. active-color="#03ae2b" inactive-color="#d8d8d8" @change="onIsCanChange"></el-switch>
  76. <span class="switch-label" :class="{ active: isCan }">{{ isCan ? lang.ssShowResult : lang.ssHideResult }}</span>
  77. </div> -->
  78. <div class="free-browse-switch" v-if="tType == 2">
  79. <span class="switch-label" :class="{ active: freeBrowse }">{{ freeBrowse ? lang.ssFreeBrowse :
  80. lang.ssFollowMode }}</span>
  81. </div>
  82. </div>
  83. <div class="pec_h_right">
  84. <div class="pec_h_r_btnArea">
  85. <!-- openObserveDialog -->
  86. <!-- toggleRecording -->
  87. <div class="pec_h_r_btn_uploadVoiceBtn" @click="uploadVoiceBtn" v-if="courseDetail.userid == userid"
  88. v-show="false">
  89. <span>{{ lang.ssUploadRecordingFile }}</span>
  90. </div>
  91. <div class="pec_h_r_btn_afterClass" @click="afterClass" v-if="courseDetail.userid == userid">
  92. <img src="../../assets/icon/newIcon/afterClass.svg" alt="" />
  93. <span>{{ lang.ssEndClass }}</span>
  94. </div>
  95. <div class="name_box" v-if="tType == 2">
  96. {{ userJson.username }}
  97. </div>
  98. <div class="pec_h_r_btn_afterClass" v-if="tType == 2" @click="afterClass2">
  99. {{ lang.ssExit }}
  100. </div>
  101. <!-- tType == 2 && courseDetail.userid == userid && object.keys(pptJSON).length > 0 -->
  102. <div class="pec_h_r_btn_analyze" v-show="courseDetail.userid == userid && Object.keys(pptJSON).length > 0 && tcid" @click="openDataBoard">
  103. {{ lang.ssAnalyze }}
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="pec_content">
  109. <iframe allow="camera *; microphone *;display-capture;midi;encrypted-media;clipboard-write;clipboard-read"
  110. webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" frameborder="no" border="0" :src="iframeSrc"
  111. v-if="showIframe && !pptCheckDialog" style="width: 100%; height: 100%; border: none" ref="ppt"></iframe>
  112. </div>
  113. </div>
  114. <!-- 课堂观察弹窗 -->
  115. <el-dialog :visible.sync="showObserveDialog" :close-on-click-modal="false" :close-on-press-escape="false"
  116. :show-close="true" width="90%" top="5vh" class="observe-dialog">
  117. <iframe v-if="showObserveDialog" :src="observeDialogUrl" frameborder="0"
  118. style="width: 100%; height: 85vh; border: none;"></iframe>
  119. </el-dialog>
  120. <selectTeachingClassDialog :courseDetail="courseDetail" :userId="userid" ref="selectTeachingClassDialogRef" @success="selectClassSuccess" @changeClassList="changeClassList"/>
  121. <!-- 消息提示组件 -->
  122. <messageInstruction ref="messageInstructionRef"></messageInstruction>
  123. <!-- 确认提示组件 -->
  124. <confirmInstruction ref="confirmInstructionRef"></confirmInstruction>
  125. <!-- 分享弹窗 -->
  126. <shareDialog ref="shareDialogRef"></shareDialog>
  127. <!-- 数据看板 -->
  128. <dataBoard ref="dataBoardRef" :courseDetail="courseDetail" :classList="classList" :pptJSON="pptJSON"></dataBoard>
  129. </div>
  130. </template>
  131. <script>
  132. import { myMixin } from '../../mixins/mixin';
  133. import selectTeachingClassDialog from "../dialog/selectTeachingClassDialog2.vue";
  134. import messageInstruction from '../components/messageInstruction.vue';
  135. import confirmInstruction from '../components/confirmInstruction.vue';
  136. import shareDialog from './shareDialog.vue';
  137. import dataBoard from './dataBoard/teacher.vue';
  138. const getFile = (url) => {
  139. return new Promise((resolve, reject) => {
  140. var credentials = {
  141. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  142. secretAccessKey: "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",
  143. }; //秘钥形式的登录上传
  144. window.AWS.config.update(credentials);
  145. window.AWS.config.region = "cn-northwest-1"; //设置区域
  146. let url2 = url;
  147. let _url2 = "";
  148. if (
  149. url2.indexOf("https://view.officeapps.live.com/op/view.aspx?src=") != -1
  150. ) {
  151. _url2 = url2.split(
  152. "https://view.officeapps.live.com/op/view.aspx?src="
  153. )[1];
  154. } else {
  155. _url2 = url2;
  156. }
  157. var s3 = new window.AWS.S3({ params: { Bucket: "ccrb" } });
  158. let name = decodeURIComponent(_url2.split("https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/")[1])
  159. var params = {
  160. Bucket: "ccrb",
  161. Key: name
  162. };
  163. s3.getObject(params, function (err, data) {
  164. if (err) {
  165. console.log(err, err.stack)
  166. resolve({ data: 1 });
  167. }else {
  168. resolve({ data: data.Body });
  169. console.log(data);
  170. } // sxuccessful response
  171. });
  172. // axios({
  173. // method: "get",
  174. // url,
  175. // responseType: "blob",
  176. // })
  177. // .then((data) => {
  178. // resolve({ data: data.data });
  179. // })
  180. // .catch((error) => {
  181. // resolve({ data: 1 });
  182. // // reject(error.toString());
  183. // });
  184. });
  185. };
  186. export default {
  187. mixins: [myMixin],
  188. components: {
  189. messageInstruction,
  190. confirmInstruction,
  191. selectTeachingClassDialog,
  192. shareDialog,
  193. dataBoard
  194. },
  195. data() {
  196. return {
  197. id: this.$route.query.courseId,
  198. userid: this.$route.query.userid,
  199. classId: this.$route.query.cid,
  200. role: this.$route.query.role,
  201. oid: this.$route.query.oid,
  202. org: this.$route.query.org,
  203. tType: this.$route.query.tType,
  204. courseType: this.$route.query.type,
  205. screenType: this.$route.query.screenType,
  206. tcid2: this.$route.query.tcid,
  207. noLogin: this.$route.query.noLogin,
  208. classList: [],
  209. tcid: "",
  210. className: "",
  211. showIframe: false,
  212. iframeSrc: "",
  213. courseDetail: {},
  214. pageLoading: false,
  215. inviteCode: "",
  216. startTime: "",
  217. freeBrowse: true, // 默认自由浏览
  218. opertimer: null, // 定时器
  219. jArray: [],
  220. // 录音相关变量
  221. languageRadio: 2, // 语言选择
  222. recordedForm: {
  223. status: 0, // 0: 未开始, 1: 录音中, 2: 暂停, 3: 结束
  224. startTime: 0,
  225. endTime: 0,
  226. timeDuration: 0,
  227. textList: [],
  228. audioBlob: []
  229. },
  230. controlsStatus: 0, // 控制状态
  231. showIndexPage: true, // 显示索引页
  232. pageStatus: 1, // 页面状态
  233. editorBarData: {
  234. type: "0",
  235. content: ""
  236. },
  237. uploadFileLoading: false, // 上传文件加载状态
  238. transcriptionData: {
  239. content: ""
  240. },
  241. showGetTextLoading: false, // 显示获取文本加载状态
  242. // 弹窗相关
  243. showObserveDialog: false, // 显示课堂观察弹窗
  244. observeDialogUrl: "", // 课堂观察链接
  245. // 录音时间记录
  246. recordingStartTime: "", // 开始录音时间
  247. recordingEndTime: "", // 结束录音时间
  248. isResultArray: [],
  249. isCan: false,
  250. timeoutPan: null,
  251. dataBoardDebounce: null,
  252. isTimeOutPan: false,
  253. pptJSON: {},
  254. pptCheckDialog: false,
  255. };
  256. },
  257. computed: {
  258. iframeSrcop() {
  259. if (this.$region == 'hk') {
  260. return `https://cloud.cocorobo.hk/browser/public/index.html`;
  261. } else if (this.$region == 'com') {
  262. return `https://cloud.cocorobo.com/browser/public/index.html`;
  263. } else {
  264. return `https://beta.cloud.cocorobo.cn/browser/public/index.html`;
  265. }
  266. }
  267. },
  268. methods: {
  269. openSelectClass(){
  270. this.$refs.selectTeachingClassDialogRef.open({classList:this.classList}, this.tcid2)
  271. },
  272. addInviteCodeOne(cid) {
  273. return new Promise((resolve)=>{
  274. let params = [
  275. {
  276. courseId: this.id,
  277. inviteCode: cid,
  278. },
  279. ];
  280. this.ajax
  281. .post(this.$store.state.api + "add_courseInviteCode2", params)
  282. .then((res) => {
  283. console.log(res.data)
  284. resolve(res.data)
  285. })
  286. .catch((err) => {
  287. resolve(err.messages)
  288. console.error(err);
  289. });
  290. })
  291. },
  292. async selectClassSuccess(classId){
  293. if(classId){
  294. let data = await this.addInviteCodeOne(classId)
  295. console.log("addInviteCodeOne",data)
  296. this.tcid2 = classId
  297. this.getClassName()
  298. this.getCourseDetail();
  299. }else if(this.tcid2){
  300. this.ticd2 = ''
  301. this.getCourseDetail();
  302. }
  303. // this.gotoCourse(classId);
  304. this.pptCheckDialog = false
  305. this.$refs.selectTeachingClassDialogRef.close();
  306. this.setoTime("1");
  307. },
  308. async changeClassList(data){
  309. this.classList = JSON.parse(JSON.stringify(data))
  310. let params = [{
  311. cid:this.id,
  312. juri:this.classList.map(i=>i.id).join(',')
  313. }]
  314. this.ajax.post(this.$store.state.api+"update_CourseJuriById",params).then(res=>{
  315. if(res.data==1){
  316. console.log(this.lang.ssModifySuccess)
  317. }
  318. })
  319. //this.inviteCodeFn();
  320. },
  321. goTo(path) {
  322. this.$router.push(path);
  323. },
  324. refreshCourse() {
  325. this.getCourseDetail();
  326. },
  327. audioStart() {
  328. this.onStartRecordWithMicrosoft();
  329. },
  330. async toggleRecording() {
  331. return new Promise(async resolve => {
  332. if (this.recordedForm.status == 1) {
  333. // 检查录音时间是否至少为5秒
  334. const now = new Date(await this.getServerTime());
  335. const duration = (now - new Date(this.recordingStartTime)) / 1000;
  336. if (duration < 5) {
  337. this.$message.warning(this.lang.ssRecordingTimeAtLeast5Seconds);
  338. return;
  339. }
  340. this.$refs.confirmInstructionRef.open({
  341. title: this.lang.ssStopRecordingConfirm,
  342. message: this.lang.ssStopRecordingNotice,
  343. cancelText: this.lang.ssCancel,
  344. submitText: this.lang.ssConfirm,
  345. submitCallback: () => {
  346. console.log("确定")
  347. this.onFinishRecordWithMicrosoft().then(() => {
  348. resolve(true)
  349. });
  350. },
  351. cancelCallback: () => {
  352. console.log("取消")
  353. resolve(false)
  354. },
  355. })
  356. // this.$confirm(this.lang.ssStopRecordingNotice, this.lang.ssStopRecordingConfirm, {
  357. // confirmButtonText: this.lang.ssConfirm,
  358. // cancelButtonText: this.lang.ssCancel,
  359. // confirmButtonClass: "pptEasyClassConfirmButtonText",
  360. // cancelButtonClass: "pptEasyClassCancelButtonText"
  361. // }).then(() => {
  362. // console.log("确定")
  363. // // this.$message({
  364. // // dangerouslyUseHTMLString: true,
  365. // // customClass:"pptEasyClassMessage",
  366. // // message: '已停止录制 <p style="color:#3AB855;text-decoration: underline;cursor: pointer;float:right;margin-left:10px" target="_blank">查看结果</p>'
  367. // // });
  368. // this.onFinishRecordWithMicrosoft().then(() => {
  369. // resolve(true)
  370. // });
  371. // }).catch(() => {
  372. // console.log("取消")
  373. // resolve(false)
  374. // });
  375. } else {
  376. console.log('recordingEndTime',this.recordingEndTime)
  377. const now = new Date(await this.getServerTime());
  378. console.log('now', now)
  379. const duration = (now - new Date(this.recordingEndTime)) / 1000;
  380. if (duration < 5) {
  381. this.$message.warning(this.lang.ssRecordingTimeAtLeast5Seconds);
  382. return;
  383. }
  384. this.onStartRecordWithMicrosoft();
  385. resolve(true)
  386. }
  387. })
  388. // })
  389. },
  390. // ============ start 微软录音转译
  391. async onStartRecordWithMicrosoft() {
  392. let iiframe = this.$refs["iiframe"];
  393. iiframe.contentWindow.window.document.getElementById(
  394. "languageOptions"
  395. ).selectedIndex = this.languageRadio;
  396. // 录音开始
  397. let flag = true;
  398. console.log("开始录音", iiframe);
  399. this.recordedForm.status = 1;
  400. // 记录开始录音时间
  401. this.recordingStartTime = await this.getServerTime();
  402. iiframe.contentWindow.window.onRecognizedResult = e => {
  403. console.log("onRecognizedResult", e);
  404. this.recordedForm.endTime = this.recordedForm.timeDuration;
  405. if (flag) {
  406. this.controlsStatus = 1;
  407. this.showIndexPage = false;
  408. this.pageStatus = 2;
  409. this.editorBarData.type = "0";
  410. flag = false;
  411. this.uploadFileLoading = false;
  412. this.transcriptionData.content = "";
  413. this.editorBarData.content = "";
  414. this.recordedForm.textList = [];
  415. }
  416. this.showGetTextLoading = true;
  417. let privText = e.privText;
  418. let privSpeakerId = e.privSpeakerId;
  419. let _copyPrivSpeakerId = privSpeakerId;
  420. console.log("👇转译对象👇");
  421. console.log(e);
  422. console.log("👇转译结果👇");
  423. console.log(privText);
  424. if (!privText || !privSpeakerId || privSpeakerId == "Unknown") {
  425. return;
  426. }
  427. const newItem = {
  428. value: privText,
  429. role: "",
  430. startTime: this.updateRecordedTime({
  431. duration: this.recordedForm.startTime
  432. }),
  433. endTime: this.updateRecordedTime({
  434. duration: this.recordedForm.endTime
  435. }),
  436. time: this.updateRecordedTime({
  437. duration: this.recordedForm.endTime - this.recordedForm.startTime
  438. })
  439. };
  440. this.recordedForm.textList.push(newItem);
  441. this.recordedForm.startTime = this.recordedForm.timeDuration + 1;
  442. this.transcriptionData.content +=
  443. _copyPrivSpeakerId + ":" + privText + "\n";
  444. this.onRecordAddLine(newItem);
  445. };
  446. iiframe.contentWindow.ConversationTranscriber();
  447. setTimeout(() => {
  448. navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(permissionStatus => {
  449. if (permissionStatus.state !== "granted") {
  450. // 没有开启录音权限,直接确定停止录音
  451. this.recordedForm.status = "0";
  452. let iframe = this.$refs["iiframe"];
  453. iframe.contentWindow.onSessionStopped = null;
  454. iframe.contentWindow.window.onRecognizedResult = null;
  455. this.$message.success(this.lang.ssNoPermStop);
  456. return;
  457. }
  458. })
  459. }, 10000)
  460. },
  461. async onFinishRecordWithMicrosoft() {
  462. return new Promise(resolve => {
  463. navigator.permissions && navigator.permissions.query({ name: 'microphone' }).then(async permissionStatus => {
  464. if (permissionStatus.state !== "granted") {
  465. // 没有开启录音权限,直接确定停止录音
  466. this.recordedForm.status = "0";
  467. let iframe = this.$refs["iiframe"];
  468. iframe.contentWindow.onSessionStopped = null;
  469. iframe.contentWindow.window.onRecognizedResult = null;
  470. this.$message.success(this.lang.ssNoPermStop);
  471. return;
  472. }
  473. if (this.recordedForm.status == 1) {
  474. //正在录音时
  475. let iiframe = this.$refs["iiframe"];
  476. iiframe.contentWindow.window.document
  477. .getElementById("scenarioStopButton")
  478. .click();
  479. // 录音借宿
  480. iiframe.contentWindow.onSessionStopped = async (s, e) => {
  481. this.recordedForm.status = 0;
  482. this.controlsStatus = 2;
  483. this.showGetTextLoading = false;
  484. // this.$message.success("已结束录音");
  485. console.log("结束录音👇");
  486. console.log("结束录音", e);
  487. this.recordedForm.audioBlob.push(e.preaudio);
  488. let blob = new Blob(this.recordedForm.audioBlob, {
  489. type: "audio/wav"
  490. });
  491. let file = new File([blob], "recordedFile.wav", {
  492. type: "audio/wav"
  493. });
  494. // 存储文件和文本到全局对象
  495. await this.storeRecordingData(file);
  496. // 记录结束录音时间
  497. this.recordingEndTime = await this.getServerTime()
  498. // 调用 addPPTClass 接口
  499. this.addPPTClass(file);
  500. iiframe.contentWindow.onSessionStopped = null;
  501. iiframe.contentWindow.window.onRecognizedResult = null;
  502. resolve(true)
  503. };
  504. } else if (this.recordedForm.status == 2) {
  505. //暂停录音时
  506. this.recordedForm.status = 0;
  507. this.controlsStatus = 2;
  508. this.showGetTextLoading = false;
  509. let blob = new Blob(this.recordedForm.audioBlob, {
  510. type: "audio/wav"
  511. });
  512. let file = new File([blob], "recordedFile.wav", { type: "audio/wav" });
  513. // 存储文件和文本到全局对象
  514. await this.storeRecordingData(file);
  515. // 记录结束录音时间
  516. this.recordingEndTime = await this.getServerTime()
  517. // 调用 addPPTClass 接口
  518. this.addPPTClass(file);
  519. resolve(true)
  520. }
  521. })
  522. })
  523. },
  524. storeRecordingData(file) {
  525. // 配置全局 window 对象存储录音数据
  526. return new Promise((resolve) => {
  527. if (!window.recordingData) {
  528. window.recordingData = {};
  529. }
  530. window.recordingData.file = file;
  531. window.recordingData.text = this.transcriptionData.content;
  532. window.recordingData.textList = this.recordedForm.textList;
  533. // 将录音文件转为base64并存入localStorage
  534. // const reader = new FileReader();
  535. // reader.onload = function(e) {
  536. // const base64data = e.target.result;
  537. // try {
  538. // localStorage.setItem("recordedFileBase64", base64data);
  539. // localStorage.setItem('recordedFileName', file.name);
  540. // localStorage.setItem('recordedFileType', file.type);
  541. resolve(true)
  542. // console.log("录音数据已存储到全局对象:", window.recordingData);
  543. // } catch (err) {
  544. // resolve(false)
  545. // console.error("localStorage存储base64文件失败:", err);
  546. // }
  547. // };
  548. // reader.readAsDataURL(file);
  549. })
  550. },
  551. openObserveDialog(pptid, file) {
  552. // this.observeDialogUrl = `https://observe.cocorobo.cn/#/newClassroom?userid=${this.userid}&oid=${this.oid}&org=${this.org}&pptid=${pptid}`;
  553. // this.showObserveDialog = true;
  554. const url = `https://observe.cocorobo.cn/#/newClassroom?userid=${this.userid}&oid=${this.oid}&org=${this.org}&pptid=${pptid}`;
  555. const _pageWindow = window.open(url, '_blank');
  556. // if(!_pageWindow){
  557. // alert('浏览器弹窗被拦截,请允许弹窗后重试');
  558. // return;
  559. // }
  560. const sendData = {
  561. type: 'fileData',
  562. file,
  563. }
  564. const sendMessageToVue3 = () => {
  565. _pageWindow.postMessage(
  566. sendData,
  567. '*' // targetOrigin:必须是Vue3的实际域名,不要用*(安全)
  568. );
  569. };
  570. const handleVue3Ready = (e) => {
  571. // 校验消息来源(安全:只处理Vue3域名的消息)
  572. // 校验消息类型(确认是Vue3的就绪通知)
  573. if (e.data.type === 'READY') {
  574. console.log('已就绪,开始发送数据');
  575. sendMessageToVue3();
  576. }
  577. // 校验Vue3的"接收成功"确认(可选,进一步确保送达)
  578. if (e.data.type === 'DATA_RECEIVED') {
  579. console.log('数据已被接收');
  580. // 收到确认后移除监听,避免内存泄漏
  581. window.removeEventListener('message', handleVue3Ready);
  582. }
  583. };
  584. window.addEventListener('message', handleVue3Ready);
  585. const timeoutTimer = setTimeout(() => {
  586. console.log('未收到就绪通知,主动发送数据');
  587. sendMessageToVue3();
  588. // 移除监听(兜底后清理)
  589. window.removeEventListener('message', handleVue3Ready);
  590. }, 5000);
  591. const checkWinClosed = setInterval(() => {
  592. if (_pageWindow.closed) {
  593. clearTimeout(timeoutTimer);
  594. clearInterval(checkWinClosed);
  595. window.removeEventListener('message', handleVue3Ready);
  596. }
  597. }, 1000);
  598. // 优化:仅通过轮询方式检查窗口是否加载完成并发送消息,被打开页面无需做任何处理
  599. // const sendFileData = () => {
  600. // if (_pageWindow && !_pageWindow.closed) {
  601. // _pageWindow.postMessage(
  602. // {
  603. // type: 'fileData',
  604. // file,
  605. // },
  606. // '*'
  607. // );
  608. // }
  609. // };
  610. // let checkCount = 0;
  611. // const checkLoadedInterval = setInterval(() => {
  612. // if (!_pageWindow || _pageWindow.closed) {
  613. // clearInterval(checkLoadedInterval);
  614. // return;
  615. // }
  616. // try {
  617. // if (_pageWindow.document && _pageWindow.document.readyState === 'complete') {
  618. // clearInterval(checkLoadedInterval);
  619. // sendFileData();
  620. // }
  621. // } catch (err) {
  622. // // 跨域下直接尝试发送
  623. // clearInterval(checkLoadedInterval);
  624. // sendFileData();
  625. // }
  626. // if (++checkCount > 20) {
  627. // // 最多检测2秒(20次)
  628. // clearInterval(checkLoadedInterval);
  629. // sendFileData();
  630. // }
  631. // }, 100);
  632. setTimeout(() => {
  633. window.focus()
  634. }, 100)
  635. function openPageWindow() {
  636. _pageWindow.focus()
  637. }
  638. this.$refs.messageInstructionRef.pptMessage(`${this.lang.ssStoppedRecording} <p style="color:#3AB855;text-decoration: underline;cursor: pointer;float:right;margin-left:10px" target="_blank" onClick="(${openPageWindow.toString()})()">${this.lang.ssViewRecordingResult}</p>`)
  639. },
  640. addPPTClass(file) {
  641. let params = {
  642. pptid: this.id,
  643. cid: this.tcid,
  644. st: this.recordingStartTime,
  645. et: this.recordingEndTime
  646. };
  647. this.ajax
  648. .post(this.$store.state.api + "addPPTClass", [params])
  649. .then(res => {
  650. console.log("addPPTClass", res);
  651. let id = res.data[0][0].id;
  652. this.openObserveDialog(id, file);
  653. })
  654. .catch(err => {
  655. console.error(err);
  656. this.$message.error("保存录音信息失败");
  657. });
  658. },
  659. updateRecordedTime({ duration }) {
  660. // 格式化录音时间
  661. const minutes = Math.floor(duration / 60);
  662. const seconds = Math.floor(duration % 60);
  663. return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
  664. },
  665. onRecordAddLine(item) {
  666. // 添加录音文本行
  667. console.log("添加录音文本行:", item);
  668. // 这里可以根据需要添加更多处理逻辑
  669. },
  670. getCourseDetail() {
  671. this.pageLoading = true;
  672. let params = {
  673. courseId: this.id
  674. };
  675. this.ajax
  676. .get(this.$store.state.api + "selectCourseDetail3", params)
  677. .then(res => {
  678. console.log("getCourseDetail", res);
  679. this.courseDetail = res.data[0][0];
  680. this.courseDetail.chapters = JSON.parse(this.courseDetail.chapters);
  681. getFile(this.courseDetail.chapters.pptData).then(res => {
  682. let pptdata = res
  683. // pptdata.data 是 ArrayBuffer,需要先转成字符串再解析为 JSON
  684. let jsonStr = ''
  685. if (pptdata && pptdata.data) {
  686. // 先将 ArrayBuffer 转为字符串
  687. const uint8Array = new Uint8Array(pptdata.data)
  688. jsonStr = new TextDecoder('utf-8').decode(uint8Array)
  689. try {
  690. const jsonObj = JSON.parse(jsonStr)
  691. this.pptJSON = jsonObj
  692. console.log(this.pptJSON)
  693. } catch (error) {
  694. console.error('JSON 解析错误:', error);
  695. }
  696. }
  697. })
  698. if(this.tType == '2'){
  699. this.cid = this.$route.query.cid || ''
  700. this.tcid = this.arrayToArray(
  701. this.courseDetail.juri ? this.courseDetail.juri.split(",") : [],
  702. this.cid ? this.cid.split(",") : []
  703. )[0] || "";
  704. }else {
  705. this.tcid = this.arrayToArray(
  706. this.courseDetail.juri ? this.courseDetail.juri.split(",") : [],
  707. this.tcid2 ? this.tcid2.split(",") : []
  708. )[0] || "";
  709. }
  710. console.log('tcid', this.tcid)
  711. console.log('tcid2', this.tcid2)
  712. if (this.tcid && res.data[1].length) {
  713. let _inviteA = [];
  714. for (var ik = 0; ik < res.data[1].length; ik++) {
  715. _inviteA.push({
  716. cid: res.data[1][ik].classid,
  717. ic: res.data[1][ik].code,
  718. });
  719. }
  720. for (var ik = 0; ik < _inviteA.length; ik++) {
  721. if (
  722. this.arrayToArray(
  723. _inviteA[ik].cid.split(","),
  724. this.tcid.split(",")
  725. ).length
  726. ) {
  727. this.inviteCode = _inviteA[ik].ic;
  728. break;
  729. }
  730. }
  731. }
  732. this.setPptIframe()
  733. this.classList = res.data[2]
  734. if(!this.tcid2 && this.tType == '1' && this.noLogin != 2 && this.noLogin != 3 && this.noLogin != 4){
  735. this.pptCheckDialog = true
  736. this.$refs.selectTeachingClassDialogRef.open({classList:this.classList})
  737. }
  738. this.pageLoading = false;
  739. })
  740. .catch(err => {
  741. console.log(err);
  742. this.$message.error(this.lang.ssGetCourseDataFail);
  743. this.pageLoading = false;
  744. });
  745. },
  746. setPptIframe() {
  747. this.showIframe = false;
  748. this.$nextTick(() => {
  749. let api = 'https://beta.ppt.cocorobo.cn'
  750. if (this.$region == 'beta') {
  751. api = 'https://beta.ppt.cocorobo.cn'
  752. } else if (this.$region == 'hk') {
  753. api = 'https://ppt.cocorobo.hk'
  754. } else if (this.$region == 'com') {
  755. api = 'https://ppt.cocorobo.com'
  756. } else {
  757. api = 'https://ppt.cocorobo.cn'
  758. }
  759. let _url = api + `/?mode=student&courseid=${this.id}&userid=${this.userid}&oid=${this.oid}&org=${this.org}&cid=${this.tcid}&type=${this.tType}`;
  760. this.iframeSrc = _url;
  761. this.showIframe = true;
  762. });
  763. },
  764. arrayToArray(arrayo, arrayt) {
  765. let array1 = arrayo;
  766. let array2 = arrayt;
  767. let commonElements = [];
  768. for (let i = 0; i < array1.length; i++) {
  769. for (let j = 0; j < array2.length; j++) {
  770. if (array1[i] === array2[j]) {
  771. commonElements.push(array1[i]);
  772. }
  773. }
  774. }
  775. return commonElements;
  776. },
  777. async getClassName() {
  778. let courseGrade = await this.ajax.get(this.$store.state.api + "getClassById", { id: this.tcid2 });
  779. this.className = courseGrade.data[0][0].grade;
  780. },
  781. back() {
  782. // if (this.tType != 2) {
  783. // this.goTo(
  784. // '/courseDetail?userid=' +
  785. // this.userid +
  786. // '&oid=' +
  787. // this.oid +
  788. // '&org=' +
  789. // this.org +
  790. // '&cid=' +
  791. // this.classId +
  792. // '&courseId=' +
  793. // this.id +
  794. // '&tType=' +
  795. // this.tType +
  796. // '&screenType=' +
  797. // this.screenType
  798. // )
  799. // } else {
  800. this.goTo(
  801. '/index?userid=' +
  802. this.userid +
  803. '&oid=' +
  804. this.oid +
  805. '&org=' +
  806. this.org +
  807. '&cid=' +
  808. this.classId +
  809. '&tType=' +
  810. this.tType +
  811. '&screenType=' +
  812. this.screenType
  813. )
  814. // }
  815. },
  816. gotoCourseManage(){
  817. this.doSyncClassData(2);
  818. },
  819. gotoCourseManage2(){
  820. this.doSyncClassData(3);
  821. },
  822. gotoCourseManage3(){
  823. this.doSyncClassData(4);
  824. },
  825. afterClass() {
  826. if (this.recordedForm.status == 1) {
  827. this.toggleRecording().then((flag) => {
  828. if (flag) {
  829. this.$refs.confirmInstructionRef.open({
  830. title: this.lang.ssPrompt,
  831. message: this.lang.ssEndClassConfirm,
  832. cancelText: this.lang.ssCancel,
  833. submitText: this.lang.ssConfirm,
  834. submitCallback: () => {
  835. this.isTimeOutPan = false;
  836. this.$refs.ppt.contentWindow.PPTistStudent.forceLogout();
  837. this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  838. setTimeout(() => {
  839. this.tcid2 = ""
  840. this.refreshCourse()
  841. if(this.screenType != 2){
  842. this.back()
  843. }else if(this.screenType == 2){
  844. this.gotoCourseManage()
  845. }
  846. }, 1000)
  847. },
  848. cancelCallback: () => {
  849. this.isTimeOutPan = false;
  850. console.log("取消")
  851. }
  852. })
  853. // this.$confirm(this.lang.ssEndClassConfirm, this.lang.ssPrompt, {
  854. // confirmButtonText: this.lang.ssConfirm,
  855. // cancelButtonText: this.lang.ssCancel,
  856. // type: 'warning'
  857. // }).then(() => {
  858. // this.$refs.ppt.contentWindow.PPTistStudent.forceLogout();
  859. // this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  860. // setTimeout(() => {
  861. // this.tcid2 = ""
  862. // this.refreshCourse()
  863. // }, 1000)
  864. // }).catch(() => { });
  865. }
  866. })
  867. } else {
  868. // this.$confirm(this.lang.ssEndClassConfirm, this.lang.ssPrompt, {
  869. // confirmButtonText: this.lang.ssConfirm,
  870. // cancelButtonText: this.lang.ssCancel,
  871. // type: 'warning'
  872. // }).then(() => {
  873. // this.$refs.ppt.contentWindow.PPTistStudent.forceLogout();
  874. // this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  875. // setTimeout(() => {
  876. // this.tcid2 = ""
  877. // this.refreshCourse()
  878. // }, 1000)
  879. // }).catch(() => { });
  880. this.$refs.confirmInstructionRef.open({
  881. title: this.lang.ssPrompt,
  882. message: this.lang.ssEndClassConfirm,
  883. cancelText: this.lang.ssCancel,
  884. submitText: this.lang.ssConfirm,
  885. submitCallback: () => {
  886. this.$refs.ppt.contentWindow.PPTistStudent.forceLogout();
  887. this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  888. setTimeout(() => {
  889. this.tcid2 = ""
  890. this.refreshCourse()
  891. if(this.screenType != 2){
  892. this.back()
  893. }else if(this.screenType == 2){
  894. this.gotoCourseManage()
  895. }
  896. }, 1000)
  897. },
  898. cancelCallback: () => {
  899. console.log("取消")
  900. }
  901. })
  902. }
  903. },
  904. afterClass2(){
  905. this.$refs.confirmInstructionRef.open({
  906. title: this.lang.ssPrompt,
  907. message: this.lang.ssConfirmExit,
  908. cancelText: this.lang.ssCancel,
  909. submitText: this.lang.ssConfirm,
  910. submitCallback: () => {
  911. this.$refs.ppt.contentWindow.PPTistStudent.forceLogout2();
  912. this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  913. },
  914. cancelCallback: () => {
  915. console.log("取消")
  916. }
  917. })
  918. },
  919. onFreeBrowseChange(value) {
  920. this.freeBrowse = value;
  921. console.log('自由浏览模式已切换为1:', this.freeBrowse);
  922. this.$refs.ppt.contentWindow.PPTistStudent.toggleFollowMode()
  923. },
  924. onIsCanChange(value) {
  925. this.isCan = value;
  926. for(var i = 0; i < this.isResultArray.length; i++){
  927. let item = this.isResultArray[i];
  928. if(value && item.isTool){
  929. item.can = true
  930. }else if(item.isTool){
  931. item.can = false
  932. item.like = false
  933. }
  934. }
  935. this.$refs.ppt.contentWindow.PPTistStudent.setCan(this.isResultArray)
  936. },
  937. setOperationTime() {
  938. let _this = this;
  939. if (_this.opertimer) {
  940. clearInterval(_this.opertimer);
  941. _this.opertimer = null;
  942. }
  943. _this.opertimer = setInterval(() => {
  944. _this.setoTime("600");
  945. }, 600000);
  946. },
  947. async setoTime(time) {
  948. if(this.noLogin == 4 || this.noLogin == 3){
  949. return;
  950. }
  951. this.startTime = await this.getServerTime()
  952. this.doSyncClassData();
  953. let params = [
  954. {
  955. uid: this.userid,
  956. cid: this.id + (this.tcid2 || ''),
  957. type: "2",
  958. time: time,
  959. },
  960. ];
  961. this.ajax
  962. .post(this.$store.state.api + "addOperationTimeT2", params)
  963. .then((res) => { })
  964. .catch((err) => {
  965. console.error(err);
  966. });
  967. },
  968. getAIJ() {
  969. this.ajax.get(this.$store.state.api + "getAIJ", "").then(res => {
  970. let a = res.data[4];
  971. console.log(a)
  972. let Array = [];
  973. a.forEach(i => Array.push(i.oid))
  974. this.jArray = Array;
  975. })
  976. },
  977. async doSyncClassData(type) {
  978. let userArray = ['6fbc6471-1d48-11ed-8c78-005056b86db5','333d0dfc-1cd9-11ef-bee5-005056b86db5','6fbce5ef-1d48-11ed-8c78-005056b86db5','66feffcc-ad35-11ed-b13d-005056b86db5']
  979. if( type == 3 ){
  980. parent.setCourseUrl();
  981. return;
  982. }
  983. if( type == 4 ){
  984. let endTime = await this.getServerTime()
  985. let courseTime = Math.max(1, Math.ceil((new Date(endTime) - new Date(this.startTime)) / (1000 * 60)))
  986. let params = [
  987. {
  988. uid: this.userid,
  989. cid: this.id,
  990. type: "5",
  991. time: courseTime * 60,
  992. },
  993. ];
  994. this.ajax
  995. .post(this.$store.state.api + "addOperationTimeT2", params)
  996. .then((res) => { })
  997. .catch((err) => {
  998. console.error(err);
  999. });
  1000. if (this.courseDetail.userid == this.userid && (this.org == '16ace517-b5c7-4168-a9bb-a9e0035df840' || userArray.includes(this.userid))) {
  1001. this.syncClassData2({
  1002. courseId: this.id,
  1003. title: this.courseDetail.title,
  1004. ctitle: this.courseDetail.copyTitle || this.courseDetail.title,
  1005. courseGrade: this.tcid2 ? this.tcid2 : '',
  1006. courseTime: courseTime,
  1007. startTime: this.startTime,
  1008. endTime: endTime,
  1009. }, 'selectUser', ()=>{
  1010. parent.setCourseUrl()
  1011. })
  1012. console.log('同步数据')
  1013. } else {
  1014. parent.setCourseUrl()
  1015. }
  1016. return;
  1017. }
  1018. if (this.courseDetail.userid == this.userid && (this.org == '16ace517-b5c7-4168-a9bb-a9e0035df840' || userArray.includes(this.userid))) {
  1019. let endTime = await this.getServerTime()
  1020. let courseTime = Math.max(1, Math.ceil((new Date(endTime) - new Date(this.startTime)) / (1000 * 60)))
  1021. this.syncClassData({
  1022. courseId: this.id,
  1023. title: this.courseDetail.title,
  1024. ctitle: this.courseDetail.copyTitle || this.courseDetail.title,
  1025. courseGrade: this.tcid2 ? this.tcid2 : '',
  1026. courseTime: courseTime,
  1027. startTime: this.startTime,
  1028. endTime: endTime,
  1029. }, 'selectUser', ()=>{
  1030. type == 2 ? parent.setCourseUrl() : '';
  1031. })
  1032. console.log('同步数据')
  1033. }else {
  1034. type == 2 ? parent.setCourseUrl() : '';
  1035. }
  1036. },
  1037. // 直接上传录制音频/视频
  1038. uploadVoiceBtn() {
  1039. const input = document.createElement('input');
  1040. input.type = 'file';
  1041. input.accept = '.m4a,.mp4,.mov,.mp3,.wav';
  1042. input.click();
  1043. input.onchange = (e) => {
  1044. const fileList = e.target.files;
  1045. const file = fileList[0]
  1046. this.recordingStartTime = new Date(window.recordingStartTime ? window.recordingStartTime : new Date()).toLocaleString("zh-CN", {
  1047. hour12: false,
  1048. timeZone: "Asia/Shanghai"
  1049. }).replace(/\//g, "-");
  1050. this.recordingEndTime = new Date(window.recordingEndTime ? window.recordingEndTime : new Date()).toLocaleString("zh-CN", {
  1051. hour12: false,
  1052. timeZone: "Asia/Shanghai"
  1053. }).replace(/\//g, "-");
  1054. this.addPPTClass(file)
  1055. // 判断文件类型并获取音频或视频时长
  1056. // if (file && (file.type.startsWith('audio/') || file.type.startsWith('video/'))) {
  1057. // const url = URL.createObjectURL(file);
  1058. // let media;
  1059. // if (file.type.startsWith('audio/')) {
  1060. // media = new Audio();
  1061. // } else {
  1062. // media = document.createElement('video');
  1063. // }
  1064. // media.preload = 'metadata';
  1065. // media.src = url;
  1066. // media.onloadedmetadata = () => {
  1067. // const duration = media.duration;
  1068. // console.log('文件时长(秒):', duration);
  1069. // // 这里可以赋值或者进一步处理时长 duration
  1070. // URL.revokeObjectURL(url);
  1071. // };
  1072. // media.onerror = () => {
  1073. // console.error('无法读取文件时长');
  1074. // URL.revokeObjectURL(url);
  1075. // };
  1076. // }
  1077. }
  1078. },
  1079. // 打开分享弹窗
  1080. openShareDialog() {
  1081. let code = this.userJson.oidCode || this.userJson.orgCode
  1082. this.$refs.shareDialogRef.open(code, this.inviteCode)
  1083. },
  1084. resetIdleOp(){
  1085. if(this.courseDetail.userId == this.userid){
  1086. this.isTimeOutPan = true;
  1087. this.afterClass()
  1088. setTimeout(() => {
  1089. if(this.isTimeOutPan){
  1090. this.$refs.ppt.contentWindow.PPTistStudent.forceLogout();
  1091. this.$refs.messageInstructionRef.pptMessage(this.lang.ssStudentLoggedOut)
  1092. setTimeout(() => {
  1093. this.tcid2 = ""
  1094. this.refreshCourse()
  1095. }, 1000)
  1096. }
  1097. }, 5000);
  1098. }
  1099. // console.log('resetIdleOp','重置空闲定时器')
  1100. },
  1101. openDataBoard(){
  1102. if (this.dataBoardDebounce) clearTimeout(this.dataBoardDebounce);
  1103. this.dataBoardDebounce = setTimeout(async () => {
  1104. let sec = Math.ceil((new Date(await this.getServerTime()) - new Date(this.startTime)) / (1000 * 60))
  1105. this.setoTime(sec);
  1106. this.setOperationTime()
  1107. this.$refs.dataBoardRef.open(this.tcid2)
  1108. }, 500);
  1109. }
  1110. },
  1111. destroyed() {
  1112. clearInterval(this.opertimer);
  1113. this.opertimer = null;
  1114. clearTimeout(this.timeoutPan);
  1115. this.timeoutPan = null;
  1116. clearTimeout(this.dataBoardDebounce);
  1117. this.dataBoardDebounce = null;
  1118. this.doSyncClassData();
  1119. this.stopIdleDetection(this.resetIdleOp);
  1120. },
  1121. async mounted() {
  1122. this.setoTime("1");
  1123. this.startTime = await this.getServerTime()
  1124. console.log('this.startTime', this.startTime)
  1125. this.timeoutPan = setTimeout(() => {
  1126. this.startIdleDetection(this.resetIdleOp);
  1127. }, 40 * 60 * 1000)
  1128. // this.startIdleDetection(this.resetIdleOp);
  1129. this.getClassName()
  1130. this.getAIJ();
  1131. this.getCourseDetail();
  1132. this.setOperationTime();
  1133. window.onFreeBrowseChange = (value) => {
  1134. this.freeBrowse = value;
  1135. console.log('自由浏览模式已切换为:', this.freeBrowse);
  1136. }
  1137. window.setIsResultArray = (value) => {
  1138. this.isResultArray = value;
  1139. // 判断数组中isTool为true的项的can是否都为true
  1140. const toolItems = value.filter(item => item.isTool);
  1141. if (toolItems.length > 0) {
  1142. const allCanTrue = toolItems.every(item => item.can === true);
  1143. const allCanFalse = toolItems.every(item => item.can === false);
  1144. if (allCanTrue) {
  1145. this.isCan = true;
  1146. } else if (allCanFalse) {
  1147. this.isCan = false;
  1148. }
  1149. }
  1150. }
  1151. if (!this.userJson || !this.userJson.accountNumber) {
  1152. let res = await this.ajax.get(this.$store.state.api + "selectUser2", {
  1153. userid: this.$route.query.userid
  1154. });
  1155. this.userJson = res.data[0][0]
  1156. }
  1157. setTimeout(() => {
  1158. this.doSyncClassData();
  1159. }, 1000);
  1160. }
  1161. };
  1162. </script>
  1163. <style scoped>
  1164. .pptEasyClass {
  1165. width: 100vw;
  1166. height: 100vh;
  1167. display: flex;
  1168. flex-direction: column;
  1169. overflow: hidden;
  1170. box-sizing: border-box;
  1171. background-color: #f2f2f2;
  1172. min-height: unset;
  1173. }
  1174. .pec_main {
  1175. width: 100%;
  1176. height: 100%;
  1177. background-color: #fff;
  1178. }
  1179. .pec_header {
  1180. width: 100%;
  1181. height: 60px;
  1182. background: #FCCF00;
  1183. box-sizing: border-box;
  1184. display: flex;
  1185. align-items: center;
  1186. justify-content: space-between;
  1187. position: relative;
  1188. box-shadow: 0px 4px 12px 0px #3648601F;
  1189. padding: 0 10px;
  1190. box-sizing: border-box;
  1191. }
  1192. .pec_h_left {
  1193. width: auto;
  1194. height: 100%;
  1195. display: flex;
  1196. align-items: center;
  1197. gap: 25px;
  1198. /* 保持左侧靠左 */
  1199. }
  1200. .pec_h_center {
  1201. position: absolute;
  1202. left: 50%;
  1203. top: 0;
  1204. height: 100%;
  1205. display: flex;
  1206. align-items: center;
  1207. transform: translateX(-50%);
  1208. z-index: 1;
  1209. }
  1210. .pec_h_l_title {
  1211. font-weight: bold;
  1212. font-size: 20px;
  1213. color: #0e1e33;
  1214. overflow: hidden;
  1215. white-space: nowrap;
  1216. max-width: 500px;
  1217. text-overflow: ellipsis;
  1218. }
  1219. .pec_h_right {
  1220. width: auto;
  1221. height: 100%;
  1222. display: flex;
  1223. align-items: center;
  1224. }
  1225. .pec_h_r_btnArea {
  1226. display: flex;
  1227. align-items: center;
  1228. justify-content: center;
  1229. }
  1230. .pec_h_r_btnArea>div {
  1231. width: auto;
  1232. height: auto;
  1233. display: flex;
  1234. align-items: center;
  1235. justify-content: center;
  1236. padding: 10px 20px;
  1237. background-color: #f0f4fa;
  1238. border-radius: 4px;
  1239. cursor: pointer;
  1240. font-size: 14px;
  1241. font-weight: 400;
  1242. color: #000;
  1243. border: 1px solid #cad1dc;
  1244. }
  1245. .pec_h_r_btnArea>div+div {
  1246. margin-left: 10px;
  1247. }
  1248. .pec_h_r_btnArea>div>img {
  1249. width: 15px;
  1250. height: 15px;
  1251. margin-right: 5px;
  1252. }
  1253. .pec_h_center>.pec_h_r_btn_refresh {
  1254. color: #fff;
  1255. /* background-color: #0061ff;
  1256. border-color: #0061ff; */
  1257. padding: 9px 10px;
  1258. margin-right: 15px;
  1259. border-radius: 26px;
  1260. display: flex;
  1261. align-items: center;
  1262. justify-content: center;
  1263. gap: 5px;
  1264. background: #FFF7F5;
  1265. color: #000000;
  1266. font-weight: 400;
  1267. cursor: pointer;
  1268. fill: #666666;
  1269. }
  1270. .pec_h_center>.pec_h_r_btn_refresh>svg {
  1271. width: 1rem;
  1272. height: 1rem;
  1273. }
  1274. .pec_h_center>.pec_h_r_btn_refresh.recording {
  1275. /* background-color: #F53F3F;
  1276. border-color: #F53F3F; */
  1277. background: #FFF7E8;
  1278. fill: #FF9300;
  1279. animation: pulse 1.5s infinite;
  1280. }
  1281. @keyframes pulse {
  1282. 0% {
  1283. box-shadow: 0 0 0 0 rgba(245, 63, 63, 0.4);
  1284. }
  1285. 70% {
  1286. box-shadow: 0 0 0 10px rgba(245, 63, 63, 0);
  1287. }
  1288. 100% {
  1289. box-shadow: 0 0 0 0 rgba(245, 63, 63, 0);
  1290. }
  1291. }
  1292. .pec_h_r_btnArea>.pec_h_r_btn_afterClass {
  1293. border-color: #F0E1DD;
  1294. background-color: #FFF7F5;
  1295. color: #F53F3F;
  1296. }
  1297. .pec_h_r_btnArea>.pec_h_r_btn_analyze {
  1298. border-color: #C5D4EC;
  1299. background-color: #E8F0FE;
  1300. color: #3370FF;
  1301. }
  1302. .pec_h_r_btn_uploadVoiceBtn {
  1303. border-color: #F0E1DD;
  1304. background-color: #FFF7F5;
  1305. color: #000;
  1306. }
  1307. .backBtn {
  1308. width: 15px;
  1309. height: 15px;
  1310. display: flex;
  1311. align-items: center;
  1312. justify-content: center;
  1313. cursor: pointer;
  1314. }
  1315. .backBtn img {
  1316. width: 100%;
  1317. height: 100%;
  1318. }
  1319. .shareBtn {
  1320. width: 25px;
  1321. height: 25px;
  1322. display: flex;
  1323. align-items: center;
  1324. justify-content: center;
  1325. cursor: pointer;
  1326. }
  1327. .shareBtn img {
  1328. width: 100%;
  1329. height: 100%;
  1330. }
  1331. .class-info-group {
  1332. display: flex;
  1333. align-items: center;
  1334. gap: 10px;
  1335. }
  1336. .class-label {
  1337. font-size: 18px;
  1338. font-weight: bold;
  1339. color: #222;
  1340. margin-right: 5px;
  1341. }
  1342. .class-value {
  1343. font-size: 16px;
  1344. color: #222;
  1345. background: #FFFFFF3D;
  1346. border: 1px solid #00000080;
  1347. border-radius: 5px;
  1348. padding: 5px 18px;
  1349. min-width: 60px;
  1350. text-align: center;
  1351. display: inline-block;
  1352. box-sizing: border-box;
  1353. display: flex;
  1354. align-items: center;
  1355. }
  1356. .class-value2 {
  1357. cursor: pointer;
  1358. background: #fff;
  1359. }
  1360. .class-value > svg{
  1361. width: 13px;
  1362. height: 13px;
  1363. margin-left: 8px;
  1364. }
  1365. .pec_content {
  1366. width: 100%;
  1367. height: calc(100% - 60px);
  1368. border-radius: 0 0 12px 12px;
  1369. background-color: #fff;
  1370. }
  1371. .free-browse-switch {
  1372. display: flex;
  1373. align-items: center;
  1374. padding: 9px 10px;
  1375. background: #FFF7F5;
  1376. border-radius: 26px;
  1377. margin-left: 15px;
  1378. gap: 5px;
  1379. }
  1380. .switch-label {
  1381. /* background: linear-gradient(to right, #F53F3F, #FCCF00); */
  1382. /* -webkit-background-clip: text; */
  1383. color: #000;
  1384. }
  1385. .refresh_icon {
  1386. width: 35px;
  1387. height: 35px;
  1388. display: flex;
  1389. align-items: center;
  1390. justify-content: center;
  1391. background-color: #fff7f5;
  1392. border-radius: 45%;
  1393. cursor: pointer;
  1394. margin-right: 15px;
  1395. padding: 0 3px;
  1396. }
  1397. .refresh_icon img {
  1398. width: 16px;
  1399. height: 16px;
  1400. }
  1401. .name_box {
  1402. background: unset !important;
  1403. border: none !important;
  1404. cursor: unset !important;
  1405. }
  1406. .observe-dialog>>>.el-dialog__header {
  1407. padding: 0;
  1408. }
  1409. .observe-dialog>>>.el-dialog__body {
  1410. padding: 0;
  1411. }
  1412. .observe-dialog>>>.el-dialog__headerbtn {
  1413. top: 22px;
  1414. right: 20px;
  1415. z-index: 100;
  1416. }
  1417. </style>