<script>
export default {
    data() {
        return {
            isRouterAlive: true
        };
    },
    methods: {
        //   inject: ['reload'],   在页面中注入此方法，  使用this.reload() 达到F5的效果
        reload() {
            this.isRouterAlive = false;
            this.$nextTick(function () {
                this.isRouterAlive = true;
            });
        }
    },
    provide() {
        return {
            reload: this.reload
        };
    },
    mounted() {
        const screenWidth = window.innerWidth
        let bodyStyle = document.body.style
        let appStyle = document.getElementById('app').style;
        if (document.documentElement.clientWidth / document.documentElement.clientHeight < 4224 / 1152) {
            appStyle.width = `2048px`
            bodyStyle.transform = `scale(${screenWidth / 2048})`
        } else {
            appStyle.width = `4224px`
            bodyStyle.transform = `scale(${screenWidth / 4224})`
        }
        window.addEventListener('resize', () => {
            const screenWidth = window.innerWidth
            let bodyStyle = document.body.style
            let appStyle = document.getElementById('app').style;
            if (document.documentElement.clientWidth / document.documentElement.clientHeight < 4224 / 1152) {
                appStyle.width = `2048px`
                bodyStyle.transform = `scale(${screenWidth / 2048})`
            } else {
                appStyle.width = `4224px`
                bodyStyle.transform = `scale(${screenWidth / 4224})`
            }
        })

    },
    beforeMount() {

    }
};
</script>

<template>
    <div id="app">
        <router-view v-if="isRouterAlive"></router-view>
    </div>
</template>

<style lang="less">

.amap-logo {
    display: none !important;
}

* {
    margin: 0;
    padding: 0;
}

body {
    // width: 4224px;
    height: 1152px;
    position: fixed;
    left: 0;
    top: 0;
    overflow: hidden;
    background-color: rgb(27, 28, 30);
    transform-origin: left top;
}

#app {
    width: 100%;
    height: 100%;
}
</style>