gaoshp
2024-06-13 fd7586c8d91473d2850af1e48b12f1a289e6b8d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
 * @Descripttion: 处理iframe持久化,涉及store(VUEX)
 * @version: 1.0
 * @Author: sakuya
 * @Date: 2021年6月30日13:20:41
 * @LastEditors:
 * @LastEditTime:
-->
 
<template>
    <div v-show="$route.meta.type=='iframe'" class="iframe-pages">
        <iframe v-for="item in iframeList" :key="item.meta.url" v-show="$route.meta.url==item.meta.url" :src="item.meta.url" frameborder='0'></iframe>
    </div>
</template>
 
<script>
    export default {
        data() {
            return {
 
            }
        },
        watch: {
            $route(e) {
                this.push(e)
            },
        },
        created() {
            this.push(this.$route);
        },
        computed:{
            iframeList(){
                return this.$store.state.iframe.iframeList
            },
            ismobile(){
                return this.$store.state.global.ismobile
            },
            layoutTags(){
                return this.$store.state.global.layoutTags
            }
        },
        mounted() {
 
        },
        methods: {
            push(route){
                if(route.meta.type == 'iframe'){
                    if(this.ismobile || !this.layoutTags){
                        this.$store.commit("setIframeList", route)
                    }else{
                        this.$store.commit("pushIframeList", route)
                    }
                }else{
                    if(this.ismobile || !this.layoutTags){
                        this.$store.commit("clearIframeList")
                    }
                }
            }
        }
    }
</script>
 
<style scoped>
    .iframe-pages {width:100%;height:100%;background: #fff;}
    iframe {border:0;width:100%;height:100%;display: block;}
</style>