pptPresent.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. <template>
  2. <div class="present-page-wrap page-wrap" style="width:100%;height:100%;" :style="{overflow:isScreen?'hidden':'auto'}">
  3. <template v-if="!isScreen">
  4. <div class="index-list">
  5. <!-- 样式需要 -->
  6. <div style="display:none"></div>
  7. <!-- 封面 -->
  8. <div class="line"></div>
  9. <index-item
  10. v-if="currentItem"
  11. :pageIndex="0"
  12. :pageItem="coverInfo.index"
  13. :currentItem="currentItem"
  14. :showCloseBtn="false"
  15. @click.native="changeCurrentItem(coverInfo.index)"
  16. ></index-item>
  17. <index-item
  18. v-for="(item,index) in pageList" :key="index+1"
  19. :pageItem="item"
  20. :pageIndex="index+1"
  21. :currentItem="currentItem"
  22. :showCloseBtn="false"
  23. @click.native="changeCurrentItem(item)"
  24. />
  25. <!-- 封底 -->
  26. <index-item
  27. v-if="currentItem&&isShowBack"
  28. :pageIndex="pageList.length+1"
  29. :pageItem="backInfo.index"
  30. :currentItem="currentItem"
  31. :showCloseBtn="false"
  32. @click.native="changeCurrentItem(backInfo.index)"
  33. ></index-item>
  34. <!-- 样式需要 -->
  35. <div></div>
  36. </div>
  37. <div class="show-wrap flex-column">
  38. <div id="fullscreen" class="fullscreen flex-center" ref="pptWrap">
  39. <!-- <div class="image-move" v-if="dragShow" @mousedown.stop="handleMoveStart" ></div> -->
  40. <div class="ppt-wrap" @wheel.stop="normalMouseWheel">
  41. <!-- 封面 -->
  42. <div class="ppt-item" id="cover" v-if="currentIndex===0" style="background-size:20%;">
  43. <!-- <Cover :pageInfo="coverInfo.page" v-show="coverInfo.page"></Cover> -->
  44. <CustomCover :pageInfo="coverInfo.page" :CoverContent="pptCoverContent" v-show="coverInfo.page"></CustomCover>
  45. </div>
  46. <!-- 封底 -->
  47. <div class="ppt-item" id="back" v-else-if="currentIndex===pageList.length+1" style="background-size:20%;">
  48. <img :src="coverInfo.page.BackCoverImg" class="pptbg" style="width:100%;height:100%;object-fit: fill !important;"/>
  49. </div>
  50. <!-- PPT内容 -->
  51. <div class="ppt-item" v-else>
  52. <!-- 自定义标题 -->
  53. <div class="custom-title-wrap editor-content"
  54. :style="currentItem.titleDetail?{
  55. left:(currentItem.titleDetail.baseLeft||90)*contentScale+'px',
  56. top:(currentItem.titleDetail.baseTop||40.9)*contentScale+'px',
  57. width:(currentItem.titleDetail.baseWidth||612)+'px',
  58. height:(currentItem.titleDetail.baseHeight||30.9)+'px',
  59. }:{
  60. left:90*contentScale+'px',top:40.9*contentScale+'px',width:'612px',height:'30.9px'
  61. }">
  62. <div class="title" v-html="currentItem.title"
  63. :style="currentItem.titleDetail?{
  64. color:currentItem.titleDetail.color||'#333',
  65. fontSize:(currentItem.titleDetail.fontSize||22)+'px',
  66. fontFamily:currentItem.titleDetail.fontFamily||'helvetica'
  67. }:{ color:'#333',fontSize:'22px',fontFamily:'helvetica' }"></div>
  68. </div>
  69. <component
  70. :ref="`pptPage_${currentIndex-1}`"
  71. :is="componentName"
  72. :key="currentKey"
  73. type="show"
  74. :pageIndex="currentIndex-1"
  75. :pageItem="currentItem">
  76. </component>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="other">
  81. <div class="page-info">
  82. <span>{{pptSlidePages}}</span>
  83. </div>
  84. <div class="btn-list">
  85. <el-button @click="(e)=>{FullScreen(e,'live')}" type="primary" class="btn"> {{$t('Slides.portrait_mode_playback')}} </el-button>
  86. <el-dropdown split-button type="primary" @command="handleLayoutCommand" class="btn">
  87. {{layoutStr}}
  88. <el-dropdown-menu slot="dropdown">
  89. <el-dropdown-item :command="1">10:7</el-dropdown-item>
  90. <el-dropdown-item :command="2">16:9</el-dropdown-item>
  91. <el-dropdown-item :command="3">4:3</el-dropdown-item>
  92. </el-dropdown-menu>
  93. </el-dropdown>
  94. <el-dropdown split-button type="primary" @click="FullScreen" @command="handleCommand">
  95. {{$t('Slides.play_from_current_slide')}}
  96. <el-dropdown-menu slot="dropdown">
  97. <el-dropdown-item> {{$t('Slides.play_for_the_first_slide')}}</el-dropdown-item>
  98. </el-dropdown-menu>
  99. </el-dropdown>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <template v-else>
  105. <div class="ppt-screen fullscreen" :class="fullScreenType==='live'?'live':''" ref="pptFullScreen"
  106. @mousedown.stop="(e)=>{handleMouse('down',e)}" @mouseup="(e)=>{handleMouse('up',e)}" @wheel.stop="normalMouseWheel" @contextmenu="handleContextMenu" >
  107. <div class="ppt-wrap">
  108. <!-- 封面 -->
  109. <div class="ppt-item" id="cover" v-if="currentIndex===0" style="background-size:20%;">
  110. <!-- <Cover :pageInfo="coverInfo.page" v-show="coverInfo.page"></Cover> -->
  111. <CustomCover :pageInfo="coverInfo.page" :CoverContent="pptCoverContent" v-show="coverInfo.page"></CustomCover>
  112. </div>
  113. <!-- 封底 -->
  114. <div class="ppt-item" id="back" v-else-if="currentIndex===pageList.length+1" style="background-size:20%;">
  115. <img :src="coverInfo.page.BackCoverImg" class="pptbg" style="width:100%;height:100%;object-fit: fill !important;"/>
  116. </div>
  117. <!-- PPT内容 -->
  118. <div class="ppt-item" v-else>
  119. <!-- 自定义标题 -->
  120. <div class="custom-title-wrap editor-content"
  121. :style="currentItem.titleDetail?{
  122. left:(currentItem.titleDetail.baseLeft||90)*contentScale+'px',
  123. top:(currentItem.titleDetail.baseTop||40.9)*contentScale+'px',
  124. width:(currentItem.titleDetail.baseWidth||612)+'px',
  125. height:(currentItem.titleDetail.baseHeight||30.9)+'px',
  126. }:{
  127. left:90*contentScale+'px',top:40.9*contentScale+'px',width:'612px',height:'30.9px'
  128. }">
  129. <div class="title" v-html="currentItem.title"
  130. :style="currentItem.titleDetail?{
  131. color:currentItem.titleDetail.color||'#333',
  132. fontSize:(currentItem.titleDetail.fontSize||22)+'px',
  133. fontFamily:currentItem.titleDetail.fontFamily||'helvetica'
  134. }:{ color:'#333',fontSize:'22px',fontFamily:'helvetica' }"></div>
  135. </div>
  136. <component
  137. :ref="`pptPage_${currentIndex-1}`"
  138. :is="componentName"
  139. :key="currentKey"
  140. type="show"
  141. :pageIndex="currentIndex-1"
  142. :pageItem="currentItem">
  143. </component>
  144. </div>
  145. <!-- 页标 -->
  146. <div class="page-hint" v-show="isScreen">
  147. {{currentIndex+1}}/{{pageList.length+2}}
  148. </div>
  149. </div>
  150. <!-- 自定义右键菜单 -->
  151. <context-menu
  152. :modelName="screenModel"
  153. @cancel="hideContextMenu"
  154. @prev="prevPPT"
  155. @next="nextPPT"
  156. @exit="ExitFullScreen"
  157. @paint="changeModel"
  158. />
  159. <!-- 提示语 -->
  160. <transition name="fade">
  161. <div class="hint flex-center" v-show="hintText">
  162. <div class="hint-icon-wrap">
  163. <img src="~@/assets/img/ppt_m/hint-icon.png"/>
  164. </div>
  165. {{hintText}}
  166. </div>
  167. </transition>
  168. <!-- 画板 -->
  169. <drawing-board-tool
  170. :model="screenModel"
  171. ref="drawBoard"
  172. @close="changeModel"
  173. @cancel="hideContextMenu"
  174. @prev="prevPPT"
  175. @next="nextPPT"
  176. @exit="ExitFullScreen"
  177. @paint="changeModel"
  178. @salfClear="cleanPaintBoard('page')"
  179. />
  180. </div>
  181. </template>
  182. </div>
  183. </template>
  184. <script>
  185. import Cover from './components/Cover.vue';
  186. import CustomCover from './components/CustomCover.vue';
  187. import IndexItem from './components/IndexItem.vue';
  188. import {countComponentName,setFullscreen,isFullscreen,exitFullscreen,calcScale,countStrSize} from './utils/untils';
  189. import pptmixin from '../mixins/pptMixins';
  190. import mixins from '../mixins/mixins';
  191. import ContextMenu from './components/ContextMenu.vue';
  192. import Highcharts from "highcharts/highstock";
  193. import HighchartszhCN from '@/utils/highcahrts-zh_CN'
  194. import DrawingBoardTool from './components/DrawingBoardTool.vue';
  195. HighchartszhCN(Highcharts)
  196. const reloadPPTWid = ()=>{
  197. const resizeEvent = new Event('resize')
  198. window.dispatchEvent(resizeEvent)
  199. }
  200. export default {
  201. components: { IndexItem, Cover ,ContextMenu, DrawingBoardTool, CustomCover},
  202. mixins:[pptmixin,mixins],
  203. data() {
  204. return {
  205. coverInfo:{
  206. index:{
  207. id:0,
  208. title:'封面',
  209. },
  210. },//封面信息
  211. backInfo:{
  212. index:{
  213. id:-1,
  214. title:this.$t('Slides.back_cover_info')
  215. }
  216. },//封底信息
  217. pageList:[],//ppt数组
  218. currentItem:null,//当前活跃的page
  219. currentIndex:0,//当前活跃的pageIndex
  220. componentName: "formatOne", //当前活跃页的版式名
  221. isScreened:false,//Resize时,是否全屏过
  222. hintText:null,//全屏提示语
  223. isContextMenuShow:false,
  224. currentKey:0,
  225. layoutStr:`10.7${this.$t('Slides.default_size')}`,
  226. LayoutType:1,//ppt比例,1:默认比例10:7,2:16:9,3:4:3
  227. coefficient:0.7,//宽高系数
  228. contentScale:1,//文本区域的缩放系数,基准:编辑页的ppt-item宽高
  229. isScreen:false,//当前是否是全屏状态
  230. fullScreenType:'normal',//全屏模式,normal和live;为live时样式改变
  231. screenHeight:0,//屏幕高
  232. screenWidth:0,//屏幕宽
  233. screenModel:'mouse',//画笔模式(paint)还是鼠标模式(mouse)
  234. canvasPage:[],//画布页
  235. timer:null,//长按标识
  236. };
  237. },
  238. watch:{
  239. LayoutType(newval){
  240. let coefficient = newval===1?0.7:newval===2?0.5625:0.75
  241. this.coefficient = coefficient
  242. }
  243. },
  244. computed:{
  245. dragShow(){
  246. return this.isScreen&&this.fullScreenType==='live'
  247. },
  248. lineClamp(){
  249. return this.LayoutType===2?2:3
  250. },
  251. isShowBack(){
  252. return Boolean(this.coverInfo.page.BackCoverImg)
  253. },
  254. pptSlidePages(){
  255. let str = this.$i18n.locale == 'zh'?
  256. `第${this.currentIndex+1}页PPT,共${this.isShowBack?(this.pageList.length+2):(this.pageList.length+1)}页`
  257. : `Slide${this.currentIndex+1} of ${this.isShowBack?(this.pageList.length+2):(this.pageList.length+1)}`
  258. return str
  259. },
  260. //语言版本
  261. },
  262. methods: {
  263. //切换当前显示的页面
  264. async changeCurrentItem(item){
  265. if(this.currentKey>0) this.currentKey++
  266. const {id} = item
  267. if(Highcharts.charts){
  268. Highcharts.charts.length=0;
  269. }
  270. if(id===0||id===-1){
  271. this.currentItem = item
  272. this.currentIndex = id===0?0:this.pageList.length+1
  273. return
  274. }
  275. this.pageList.map((item,index)=>{
  276. if(item.id===id){
  277. this.currentItem = item
  278. this.currentIndex = index+1
  279. }
  280. })
  281. this.componentName = countComponentName(this.currentItem.modelId);
  282. await this.initPageElements(this.currentItem,'show',true)
  283. this.$nextTick(()=>{
  284. if($('#content')[0]){
  285. $('#content').css('transform',`scale(${this.contentScale})`)
  286. }
  287. if($('.editor-content')[0]){
  288. $('.editor-content').css('transform',`scale(${this.contentScale})`)
  289. }
  290. this.changeLayersSize()
  291. $('.ppt-item').css('background-image',`url(${this.coverInfo.page.CurrentBackgroundImg})`);
  292. })
  293. },
  294. async init(){
  295. this.dataLoading = this.$loading({
  296. lock: true,
  297. text: `${this.$t('Slides.loading_urgently')}...`,
  298. spinner: 'el-icon-loading',
  299. customClass:'loading',
  300. background: 'rgba(255, 255, 255, 0.8)'
  301. });
  302. await this.getpptData();
  303. //加载每一项
  304. //加载每一项图表的数据
  305. for(let i=0;i<this.pageList.length;i++){
  306. this.canvasPage[i] = null
  307. const chartElements = this.pageList[i].elements.filter((item) => {
  308. return item.type === "chart";
  309. });
  310. const sheetElements = this.pageList[i].elements.filter((item)=>{
  311. return item.type === 'sheet'
  312. })
  313. if(this.pageList[i].titleDetail){
  314. this.pageList[i].titleDetail = {
  315. ...this.pageList[i].titleDetail,
  316. ...this.getBasePosition(this.pageList[i].titleDetail)
  317. }
  318. }
  319. this.listHandle(chartElements,'present');
  320. this.sheetListHandle(sheetElements);
  321. }
  322. this.currentKey = 1
  323. this.coverInfo.page.CurrentBackgroundImg&&$('.ppt-item').css('background-image',`url(${this.coverInfo.page.CurrentBackgroundImg})`);
  324. this.dataLoading.close();
  325. },
  326. //根据id获取ppt数据
  327. async getpptData(){
  328. const {id} = this.$route.query
  329. if(id){
  330. await this.getpptDataById(id)
  331. const {status} = this.result
  332. if(status===200){
  333. const {content,FirstPage} = this.result
  334. this.pageList = content
  335. this.coverInfo.index.title = FirstPage.Title
  336. this.coverInfo.page = FirstPage
  337. this.coverInfo.page.imgLocalUrl = this.bgList[FirstPage.TemplateType-1]
  338. this.currentItem = this.coverInfo.index
  339. this.currentIndex=0
  340. }else{
  341. this.$message.error(this.$t('Slides.error_ppt_data_msg') );
  342. this.dataLoading.close();
  343. window.close()
  344. }
  345. }else{
  346. this.$message.error(this.$t('Slides.no_corresponding_ppt_msg') )
  347. window.close()
  348. }
  349. },
  350. //设置全屏
  351. FullScreen(_,type='normal'){
  352. this.fullScreenType = type
  353. this.isScreened = true
  354. this.isScreen = true
  355. setFullscreen(document.documentElement);
  356. },
  357. //点击右键菜单,退出全屏
  358. ExitFullScreen(){
  359. exitFullscreen();
  360. this.hideContextMenu()
  361. this.removeEventListener()
  362. },
  363. handleCommand(){
  364. this.changeCurrentItem(this.coverInfo.index)
  365. this.FullScreen()
  366. },
  367. //是否展示自定义右键菜单
  368. handleContextMenu(e){
  369. if(!isFullscreen()) return
  370. e.preventDefault();
  371. $("#menu").css({ "left": document.body.scrollLeft + e.clientX, "top":
  372. document.body.scrollTop + e.clientY}).show();
  373. this.isContextMenuShow = true
  374. },
  375. //(非全屏模式下)隐藏右键菜单
  376. hideContextMenu(){
  377. $('#menu').hide();
  378. this.isContextMenuShow = false
  379. },
  380. //handle全屏事件监听
  381. addEventListener(){
  382. const dom =document;
  383. dom.addEventListener('keydown',this.handleKeyDown)
  384. //dom.addEventListener('click',this.handleClick)
  385. dom.addEventListener('mousewheel',this.handleMouseWheel,{ passive: false })
  386. },
  387. //handle移除全屏事件监听
  388. removeEventListener(){
  389. const dom =document;
  390. dom.removeEventListener('keydown',this.handleKeyDown)
  391. //dom.removeEventListener('click',this.handleClick)
  392. dom.removeEventListener('mousewheel',this.handleMouseWheel,{ passive: false })
  393. },
  394. //按键:↑↓
  395. handleKeyDown(e){
  396. if(this.isContextMenuShow){
  397. this.hideContextMenu()
  398. return
  399. }
  400. //console.log('test',e.key)
  401. if(e&&e.key==='ArrowUp'){
  402. this.prevPPT()
  403. }
  404. if(e&&e.key==='ArrowDown'){
  405. this.nextPPT()
  406. }
  407. },
  408. //鼠标左键:相当于按键↓
  409. handleClick(e){
  410. if(e.target._prevClass==='image-move'){
  411. return
  412. }
  413. if(this.isContextMenuShow){
  414. this.hideContextMenu()
  415. return
  416. }
  417. this.nextPPT()
  418. },
  419. //全屏滚轮事件:向上滚:↑;向下滚:↓
  420. handleMouseWheel:_.throttle(function(e){
  421. if(this.isContextMenuShow){
  422. this.hideContextMenu()
  423. return
  424. }
  425. if(!isFullscreen()) return
  426. e.preventDefault();
  427. if (e.deltaY > 0) this.nextPPT()
  428. else if (e.deltaY < 0) this.prevPPT()
  429. },300),
  430. //ppt-wrap 滚轮事件
  431. normalMouseWheel:_.throttle(function(e){
  432. if(this.isContextMenuShow){
  433. this.hideContextMenu()
  434. return
  435. }
  436. //if(isFullscreen()) return
  437. e.preventDefault()
  438. if (e.deltaY > 0) this.nextPPT()
  439. else if (e.deltaY < 0) this.prevPPT()
  440. },300),
  441. //全屏处理事件
  442. windowResizeListener(){
  443. //退出全屏
  444. if(!isFullscreen()&&this.isScreen){
  445. console.log('exit fullScreen')
  446. this.hideContextMenu()
  447. this.removeEventListener()
  448. this.isScreened = false
  449. this.isScreen = false
  450. if(this.hintText) this.hintText=null
  451. this.setScreen(false)
  452. }
  453. //进入全屏
  454. if(isFullscreen()){
  455. console.log('fullscreen')
  456. this.isScreen = true
  457. this.setScreen(true)
  458. this.addEventListener();
  459. }
  460. //this.changeCurrentItem(this.currentItem)
  461. },
  462. //ppt上一页
  463. prevPPT(){
  464. if(this.currentIndex===0){
  465. //this.$message.warning('已经是第一页')
  466. !this.hintText&&this.showHint('prev')
  467. return
  468. }else{
  469. let item =null
  470. //isFullscreen()&&this.saveCanvasPage()
  471. isFullscreen()&&this.$refs.drawBoard.clearCanvas()
  472. //说明切换后是封面页
  473. if(this.currentIndex===1){
  474. item = this.coverInfo.index
  475. }
  476. this.changeCurrentItem(item?item:this.pageList[this.currentIndex-2])
  477. //isFullscreen()&&this.reDrawCanvasPage()
  478. }
  479. if(this.isContextMenuShow){
  480. this.hideContextMenu()
  481. }
  482. },
  483. //ppt下一页
  484. nextPPT(){
  485. const maxLength = this.isShowBack?(this.pageList.length+1):this.pageList.length
  486. if(this.currentIndex===maxLength){
  487. //this.$message.warning('已经是最后一页')
  488. !this.hintText&&this.showHint('next')
  489. }else{
  490. let item =null
  491. //isFullscreen()&&this.saveCanvasPage()
  492. isFullscreen()&&this.$refs.drawBoard.clearCanvas()
  493. //说明切换后是封底页
  494. if(this.currentIndex===this.pageList.length){
  495. item = this.backInfo.index
  496. }
  497. this.changeCurrentItem(item?item:this.pageList[this.currentIndex])
  498. //isFullscreen()&&this.reDrawCanvasPage()
  499. }
  500. if(this.isContextMenuShow){
  501. this.hideContextMenu()
  502. }
  503. },
  504. //全屏的message提示
  505. showHint(type){
  506. if(type==='prev'){
  507. this.hintText= this.$t('Slides.this_one_ppt_msg')
  508. }else{
  509. this.hintText= this.$t('Slides.this_last_ppt_msg')
  510. }
  511. setTimeout(()=>{
  512. this.hintText = null
  513. },1200)
  514. },
  515. //改变ppt的宽高比
  516. async handleLayoutCommand(command){
  517. this.LayoutType = command
  518. this.layoutStr = ['',`10.7${this.$t('Slides.default_size')}`,'16:9 ','4:3 '][this.LayoutType]
  519. this.$nextTick(()=>{
  520. reloadPPTWid()
  521. $('.ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  522. this.contentScale = $('.ppt-item').width()/900
  523. this.changeLayersSize()
  524. })
  525. },
  526. //currentItem内图层元素自适应
  527. changeLayersSize(){
  528. if(this.currentItem&&this.currentItem.layers){
  529. this.currentItem.layers.map(shape=>{
  530. const scale = calcScale({w:906,h:906*0.7},{w:$('.ppt-item').width(),h:$('.ppt-item').width()*this.coefficient})
  531. $('.shape').css('transform',`scale(${scale.x},${scale.y})`)
  532. if(shape.type==='text'){
  533. //text元素的shape不需要scale
  534. $('.shape-text').css('transform',`scale(1)`)
  535. }
  536. })
  537. }
  538. },
  539. //路演模式时,拖动调节ppt的大小
  540. handleMoveStart(e){
  541. this.isMouseDown = true
  542. const moveLeft = $('.image-move').offset().left
  543. const pptWidth = $('.fullscreen:fullscreen .ppt-wrap').width()
  544. const scaleHeight = $('.fullscreen:fullscreen').height()
  545. document.onmousemove=(move)=>{
  546. const moveX = move.clientX - e.clientX
  547. const width = pptWidth-moveX
  548. this.$nextTick(()=>{
  549. $('.fullscreen:fullscreen .ppt-wrap').css('width',width)
  550. $('.fullscreen:fullscreen .ppt-wrap .ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  551. $('.image-move').css('left',moveLeft+moveX)
  552. const scale = calcScale({w:width,h:width*this.coefficient},{w:width,h:scaleHeight})
  553. $('.ppt-item').css('transform',`scale(${scale.x},${scale.y})`)
  554. })
  555. }
  556. document.onmouseup=()=>{
  557. this.isMouseDown = false
  558. document.onmousemove = null
  559. document.onmouseup = null
  560. }
  561. },
  562. //全屏/非全屏设置
  563. async setScreen(isScreen){
  564. if(!isScreen){
  565. this.$nextTick(()=>{
  566. $('.fullscreen .ppt-wrap').css('width','1100px')
  567. $('.ppt-item').css('transform',`scale(1)`)
  568. this.changeCurrentItem(this.currentItem)
  569. $('.ppt-item').css('background-image',`url(${this.coverInfo.page.CurrentBackgroundImg})`);
  570. })
  571. }else{
  572. this.$nextTick(()=>{
  573. this.fullScreenSet()
  574. })
  575. }
  576. },
  577. fullScreenSet(){
  578. $('.fullscreen .ppt-wrap').css('height',this.screenHeight)
  579. //全屏模式
  580. if(this.fullScreenType==='normal'){
  581. //console.log('normal')
  582. $('.fullscreen .ppt-wrap').css('width',this.screenHeight/this.coefficient)
  583. //修正ppt-item的高
  584. $('.ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  585. }else{
  586. //线上路演模式
  587. //console.log('live')
  588. //算出当前屏幕72%的宽是多少
  589. const liveWidth = this.screenWidth*0.72
  590. $('.fullscreen .ppt-wrap').css('width',liveWidth)
  591. const oldPPTWidth = $('.ppt-item').width()
  592. //修正ppt-item的高
  593. $('.ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  594. const scale = calcScale({w:oldPPTWidth,h:oldPPTWidth*this.coefficient},{w:liveWidth,h:this.screenHeight})
  595. $('.ppt-item').css('transform',`scale(${scale.x},${scale.y})`)
  596. }
  597. this.changeCurrentItem(this.currentItem)
  598. },
  599. //检查页面是否处于全屏状态
  600. handleCheckScreen(){
  601. if(isFullscreen()){
  602. console.log('进入全屏')
  603. this.isScreen = true
  604. this.setScreen(true)
  605. this.addEventListener();
  606. }else{
  607. console.log('退出全屏')
  608. this.hideContextMenu()
  609. this.removeEventListener()
  610. this.cleanPaintBoard('all')
  611. this.screenModel = 'mouse'
  612. this.isScreened = false
  613. this.isScreen = false
  614. if(this.hintText) this.hintText=null
  615. this.setScreen(false)
  616. }
  617. //console.log('触发',document.fullscreenElement)
  618. },
  619. //切换演示时,页面模式
  620. changeModel(){
  621. const modelName = this.screenModel==='paint'?'mouse':'paint'
  622. this.screenModel = modelName
  623. if(this.isContextMenuShow){
  624. this.hideContextMenu()
  625. }
  626. $("#menuboard").hide()
  627. },
  628. //清空一页/全部笔迹
  629. cleanPaintBoard(type){
  630. if(type==='page'){
  631. this.canvasPage[this.currentIndex] = null
  632. }
  633. else{
  634. this.canvasPage.forEach((_,index)=>{
  635. this.canvasPage[index] = null
  636. })
  637. }
  638. },
  639. //保存当前页的画布
  640. saveCanvasPage(){
  641. const hasPainted = this.$refs.drawBoard.hasPainted
  642. if(hasPainted){
  643. let imgData = this.$refs.drawBoard.saveCanvas()
  644. this.canvasPage[this.currentIndex] = imgData
  645. //清空画布
  646. this.$refs.drawBoard.clearCanvas()
  647. }
  648. },
  649. //显示切换后的画布
  650. reDrawCanvasPage(){
  651. if(this.canvasPage[this.currentIndex]){
  652. this.$refs.drawBoard.reDrawCanvas(this.canvasPage[this.currentIndex])
  653. this.$refs.drawBoard.hasPainted = true
  654. }else{
  655. this.$refs.drawBoard.hasPainted = false
  656. }
  657. },
  658. //鼠标长按,抬起
  659. handleMouse(type,e){
  660. /* console.log('test',type)
  661. console.log('鼠标哪个键',e.which) */
  662. //鼠标左键长按:进入画笔模式
  663. if(type==='down'&&e.which==1){
  664. this.timer = setTimeout(()=>{
  665. this.changeModel()
  666. this.$refs.drawBoard.startDraw(e)
  667. },500)
  668. }
  669. //鼠标左键抬起:如果当前在画笔模式,则退出画笔模式
  670. if(type==='up'&&e.which==1){
  671. if(this.screenModel==='paint'){
  672. this.changeModel()
  673. }
  674. this.timer&&clearTimeout(this.timer)
  675. }
  676. },
  677. //计算title的字节数
  678. getStrCount(title){
  679. return countStrSize(title)
  680. }
  681. },
  682. mounted(){
  683. this.init()
  684. //window.addEventListener('resize', this.windowResizeListener)
  685. document.addEventListener('fullscreenchange', this.handleCheckScreen)
  686. document.addEventListener('webkitfullscreenchange', this.handleCheckScreen)
  687. document.addEventListener('mozfullscreenchange', this.handleCheckScreen)
  688. this.screenHeight = window.screen.height
  689. this.screenWidth = window.screen.width
  690. },
  691. updated(){
  692. $('.ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  693. this.contentScale = $('.ppt-item').width()/900
  694. this.changeLayersSize()
  695. if($('.editor-content')[0]){
  696. $('.editor-content').css('transform',`scale(${this.contentScale})`)
  697. }
  698. if($('.title-wrap')[0]){
  699. $('.title-wrap').css('font-size',this.contentScale*24*0.9+'px')
  700. }
  701. window.onresize = ()=>{
  702. $('.ppt-item').css('height',$('.ppt-item').width()*this.coefficient);
  703. this.contentScale = $('.ppt-item').width()/900
  704. this.$nextTick(()=>{
  705. if($('#content')[0]){
  706. $('#content').css('transform',`scale(${this.contentScale})`)
  707. }
  708. this.changeLayersSize()
  709. if($('.editor-content')[0]){
  710. $('.editor-content').css('transform',`scale(${this.contentScale})`)
  711. }
  712. if($('.title-wrap')[0]){
  713. $('.title-wrap').css('font-size',this.contentScale*24*0.9+'px')
  714. }
  715. })
  716. }
  717. },
  718. destroyed() {
  719. //window.removeEventListener('resize', this.windowResizeListener)
  720. document.removeEventListener('fullscreenchange',this.handleCheckScreen)
  721. document.removeEventListener('webkitfullscreenchange',this.handleCheckScreen)
  722. document.removeEventListener('mozfullscreenchange',this.handleCheckScreen)
  723. window.onresize=null
  724. }
  725. };
  726. </script>
  727. <style lang="scss">
  728. @import './css/common.scss';
  729. @import './css/format.scss';
  730. .ppt-wrap{
  731. .pptbg{
  732. width:100%;
  733. }
  734. }
  735. .present-page-wrap{
  736. .fullscreen{
  737. position: relative;
  738. .hint{
  739. position: fixed;
  740. top:20px;
  741. left:50%;
  742. margin-left:-154px;
  743. width:308px;
  744. height: 52px;
  745. background-color:#FFF2E2;
  746. border-radius: 4px;
  747. color: #FDB863;
  748. justify-content: start;
  749. .hint-icon-wrap{
  750. width: 20px;
  751. height: 20px;
  752. background-color:#FFF2E2;
  753. margin: 0 10px 0 20px;
  754. img{
  755. width: 100%;
  756. }
  757. }
  758. }
  759. .image-move{
  760. width:15px;
  761. height: 100%;
  762. cursor: ew-resize;
  763. position: absolute;
  764. left: 515px;
  765. &:hover{
  766. background: rgba(0, 0, 0, 0.5);
  767. }
  768. }
  769. }
  770. }
  771. </style>
  772. <style scoped lang="scss">
  773. $titleHeight:7%;
  774. $titleColor:#333333;
  775. .present-page-wrap{
  776. background-color: #F5F7F9;
  777. display: flex;
  778. .index-list{
  779. min-width:360px;
  780. width: 410px;
  781. height:100vh;
  782. background-color: #fff;
  783. margin-right: 30px;
  784. padding:10px;
  785. overflow-y: scroll;
  786. &::-webkit-scrollbar-track{
  787. display: none;
  788. }
  789. .line{
  790. width:100%;
  791. height:1px;
  792. background-color:#EBEBEB ;
  793. }
  794. }
  795. .show-wrap{
  796. flex: 1;
  797. background-color: #fff;
  798. padding:30px 50px;
  799. height: 100vh;
  800. overflow-y: scroll;
  801. min-width: 876px;
  802. &::-webkit-scrollbar-track{
  803. display: none;
  804. }
  805. .other{
  806. margin-top: 15px;
  807. height: 100px;
  808. display: flex;
  809. justify-content: space-between;
  810. align-items: center;
  811. .page-info,.btn-list{
  812. display: flex;
  813. align-items: center;
  814. }
  815. .page-info{
  816. justify-content: flex-start;
  817. }
  818. .btn-list{
  819. justify-content: flex-end;
  820. }
  821. }
  822. }
  823. .ppt-screen{
  824. width:100%;
  825. height:100%;
  826. background-color: black;
  827. display: flex;
  828. justify-content: center;
  829. &.live{
  830. background-color: #D9D9D9;
  831. justify-content: flex-end;
  832. .ppt-wrap{
  833. /* overflow: visible !important;; */
  834. .ppt-item{
  835. transform-origin: 0 0;
  836. /* border: none !important; */
  837. border: 1px solid transparent;
  838. &#cover,&#back{
  839. width: 100% !important;
  840. }
  841. }
  842. }
  843. }
  844. .ppt-item{
  845. user-select: none;
  846. -webkit-user-select: none;
  847. &#cover,&#back{
  848. border: 1px solid transparent !important;
  849. background-size: 90%;
  850. }
  851. }
  852. }
  853. .ppt-wrap{
  854. width: 1100px;
  855. align-self: center;
  856. overflow: hidden;
  857. position: relative;
  858. .cover{
  859. position: relative;
  860. }
  861. .ppt-item{
  862. width: 100%;
  863. height: 100%;
  864. background: transparent;
  865. background-size: 100% 100%;
  866. position:relative;
  867. border: 4px solid transparent;
  868. overflow: hidden;
  869. .title-wrap{
  870. width: 68%;
  871. height: $titleHeight;
  872. position: absolute;
  873. top: 5.5%;
  874. left: 10%;
  875. z-index: 100;
  876. display: flex;
  877. font-size: 24px;
  878. color:$titleColor;
  879. align-items: center;
  880. transform-origin: 0 0;
  881. word-break: break-all;
  882. }
  883. &#cover,&#back{
  884. //background:none;
  885. width: calc(100% - 8px);
  886. border: none;
  887. }
  888. }
  889. .page-hint{
  890. user-select: none;
  891. position:absolute;
  892. right:5%;
  893. bottom: 2%;
  894. width:7%;
  895. height:40px;
  896. background-color: rgba(0, 0, 0,0.4);
  897. color: #fff;
  898. font-size: 24px;
  899. font-weight: bold;
  900. text-align: center;
  901. line-height: 40px;
  902. border-radius: 8px;
  903. }
  904. }
  905. }
  906. </style>