¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <basic-container> |
| | | <iframe :src="src" |
| | | class="iframe" |
| | | ref="iframe"></iframe> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import {mapGetters} from "vuex"; |
| | | import NProgress from "nprogress"; // progress bar |
| | | import "nprogress/nprogress.css"; // progress bar style |
| | | export default { |
| | | name: "AvueIframe", |
| | | data() { |
| | | return { |
| | | urlPath: this.getUrlPath() //iframe src è·¯å¾ |
| | | }; |
| | | }, |
| | | created() { |
| | | NProgress.configure({showSpinner: false}); |
| | | }, |
| | | mounted() { |
| | | this.load(); |
| | | this.resize(); |
| | | }, |
| | | props: ["routerPath"], |
| | | watch: { |
| | | $route: function () { |
| | | this.load(); |
| | | }, |
| | | routerPath: function () { |
| | | // çå¬routerPathååï¼æ¹åsrcè·¯å¾ |
| | | this.urlPath = this.getUrlPath(); |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["screen"]), |
| | | src() { |
| | | return this.$route.query.src |
| | | ? this.$route.query.src.replace("$", "#") |
| | | : this.urlPath; |
| | | } |
| | | }, |
| | | methods: { |
| | | // æ¾ç¤ºçå¾
æ¡ |
| | | show() { |
| | | NProgress.start(); |
| | | }, |
| | | // éèçå¾
ç |
| | | hide() { |
| | | NProgress.done(); |
| | | }, |
| | | // å è½½æµè§å¨çªå£ååèªéåº |
| | | resize() { |
| | | window.onresize = () => { |
| | | this.iframeInit(); |
| | | }; |
| | | }, |
| | | // å è½½ç»ä»¶ |
| | | load() { |
| | | this.show(); |
| | | var flag = true; //URLæ¯å¦å
å«é®å· |
| | | if (this.$route.query.src !== undefined && this.$route.query.src.indexOf("?") === -1) { |
| | | flag = false; |
| | | } |
| | | var list = []; |
| | | for (var key in this.$route.query) { |
| | | if (key !== "src" && key !== "name" && key !== "i18n") { |
| | | list.push(`${key}= this.$route.query[key]`); |
| | | } |
| | | } |
| | | list = list.join("&").toString(); |
| | | if (flag) { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `&list` : "" |
| | | }`; |
| | | } else { |
| | | this.$route.query.src = `${this.$route.query.src}${ |
| | | list.length > 0 ? `?list` : "" |
| | | }`; |
| | | } |
| | | //è¶
æ¶3sèªå¨éèçå¾
çï¼å å¼ºç¨æ·ä½éª |
| | | let time = 3; |
| | | const timeFunc = setInterval(() => { |
| | | time--; |
| | | if (time === 0) { |
| | | this.hide(); |
| | | clearInterval(timeFunc); |
| | | } |
| | | }, 1000); |
| | | this.iframeInit(); |
| | | }, |
| | | //iframeçªå£åå§å |
| | | iframeInit() { |
| | | const iframe = this.$refs.iframe; |
| | | const clientHeight = |
| | | document.documentElement.clientHeight - (screen > 1 ? 200 : 130); |
| | | if (!iframe) return; |
| | | iframe.style.height = `${clientHeight}px`; |
| | | if (iframe.attachEvent) { |
| | | iframe.attachEvent("onload", () => { |
| | | this.hide(); |
| | | }); |
| | | } else { |
| | | iframe.onload = () => { |
| | | this.hide(); |
| | | }; |
| | | } |
| | | }, |
| | | getUrlPath: function () { |
| | | //è·å iframe src è·¯å¾ |
| | | let url = window.location.href; |
| | | url = url.replace("/myiframe", ""); |
| | | return url; |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | .iframe { |
| | | width: 100%; |
| | | height: 100%; |
| | | border: 0; |
| | | overflow: hidden; |
| | | box-sizing: border-box; |
| | | } |
| | | </style> |