| | |
| | | </div> |
| | | </div> |
| | | <div class="tools-middle"> |
| | | <div v-for="dock in $store.state.desktop.minDocks" :key="dock.id" class="dock-item-wrap" :class="{'actived':dock.highlight}"> |
| | | <div v-for="dock in $store.state.desktop.minDocks" :key="dock.id" class="dock-item-wrap" :class="{'actived':dock.highlight}" @mouseover="screenShot(dock)"> |
| | | <a @click="dockClick(dock)"> |
| | | <img class="dock-item" :src="dock.src" :alt="dock.alt" /> |
| | | <img class="dock-shot" :src="dock.screenshot" v-if="dock.screenshot"/> |
| | | |
| | | <!-- <iframe class="dock-shot" :src="dock.url" ></iframe> --> |
| | | </a> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import html2canvas from 'html2canvas'; |
| | | import {logout} from "@/api/login"; |
| | | export default { |
| | | name: "Tools", |
| | |
| | | this.$store.commit("desktop/refreshFrame", dock); |
| | | } |
| | | }, |
| | | screenShot(dock){ |
| | | debugger |
| | | //找到当前的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:''}); |
| | | }); |
| | | }, |
| | | toLogout(){ |
| | | this.$confirm("提示:确定退出吗?", { |
| | | center: true, |
| | |
| | | float: left; |
| | | position: relative; |
| | | } |
| | | |
| | | .tools .tools-middle::before { |
| | | width: 1px; |
| | | height: 20px; |
| | |
| | | } |
| | | .dock-item-wrap .dock-shot { |
| | | visibility: hidden; |
| | | /* transform: scale(0.5); */ |
| | | width: 100px; |
| | | height: 46px; |
| | | position: absolute; |