| | |
| | | </template> |
| | | |
| | | <script> |
| | | import html2canvas from 'html2canvas'; |
| | | import Desktop from './components/Desktop'; |
| | | import NotificationCenter from './components/NotificationCenter'; |
| | | import NoticeTip from './components/NoticeTip'; |
| | |
| | | }, |
| | | addWeather: function (weather) { |
| | | this.$store.commit('desktop/addWeather', weather); |
| | | }, |
| | | screenShot(dock){ |
| | | //找到当前的iframe |
| | | let curIframe = Array.from(document.querySelectorAll('iframe')).find(iframe => iframe.src.indexOf(dock.url) >= 0); |
| | | //保存当前应用快照 |
| | | html2canvas(curIframe.contentWindow.document.body, { |
| | | dpi: window.devicePixelRatio * 4, |
| | | logging: true, //查看html2canvas内部执行流程 |
| | | removeContainer: true, |
| | | imageTimeout: 0, |
| | | useCORS: true, //开启跨域配置 |
| | | //allowTaint: true |
| | | }).then(canvas => { |
| | | let shotSrc = canvas.toDataURL(); |
| | | // this.$store.commit('desktop/addMinDock', { |
| | | // id: dock.id, |
| | | // src: dock.icon, |
| | | // alt: dock.title, |
| | | // type: "3", |
| | | // screenshot: shotSrc |
| | | // }); |
| | | this.$store.commit('desktop/shotscreen', {id:dock.id, src:shotSrc}); |
| | | |
| | | }).catch(e => { |
| | | this.$store.commit('desktop/shotscreen', {id:dock.id, src:''}); |
| | | }); |
| | | } |
| | | } |
| | | } |