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

<script>
export default {
    mounted() {
        window.onmessage = e => {
            if (!e.data.id) return;
            sessionStorage.setItem("postMessage", e.data.id);
            if (e.data.userInfo && e.data.userInfo.id) {
                if (
                    e.data.userInfo.permissionList.some(
                        item => item.rights === "duojiSystem"
                    )
                ) {
                    let authList = this.$utils.translateDataToTree(
                        e.data.userInfo.permissionList,
                        'duojiSystem'
                    );
                    e.data.userInfo.permissionList = this.$utils.treeToArray(
                        authList
                    );
                } else {
                    e.data.userInfo.permissionList = [];
                }
                localStorage.setItem(
                    "userInfo",
                    JSON.stringify(e.data.userInfo)
                );
            } else {
                localStorage.clear();
            }
        };
    }
};
</script>
<!--<script type="text/javascript" src="./utils/jsmpeg.min.js"></script>-->
<style lang="scss">
@import "style/common/reset.css";
@import "style/common/layout";
@import "style/common/form";
</style>
