<template>
  <div class="winseaview-contail" :class="{'winseaview--collapse':isCollapse}">
    <!-- <screenshot></screenshot> -->
    <div class="winseaview-header">
      <!-- 顶部导航栏 -->
      <top />
      <div> <sy-Click :titles="openRoute" @removeElseTag='removeElseTag'></sy-Click></div>
    </div>

    <div class="winseaview-layout">
      <div class="winseaview-left">
        <!-- 左侧导航栏 -->
        <sidebar />
      </div>
      <div class="winseaview-main">
        <!-- 顶部标签卡 -->
        <tags />
        <!-- 主体视图层 -->
        <BaseContainer id="layout_body">
          <keep-alive>
            <router-view class="winseaview-view" v-if="$route.meta.keepAlive" />
          </keep-alive>
          <router-view class="winseaview-view" v-if="!$route.meta.keepAlive" />
        </BaseContainer>
        <!-- <div class="bottom">
          <div class="row1">
          Copyright www.eliangeyun.com All Right Reserved @淘粮（海南）科技发展有限公司  </div>
          <div class="">
          <a href="https://beian.miit.gov.cn">琼ICP备2021004821号-2</a>
          </div>
        </div> -->
      </div>
    </div>
    <div class="winseaview-shade" @click="showCollapse"></div>
  </div>
</template>

<script>
  import {
    mapActions,
    mapGetters
  } from 'vuex';
  import screenshot from './screenshot';
  import syClick from '@/components/syClick'
  import tags from './tags';
  import top from './top/';
  import sidebar from './sidebar/';
  import {
    getScreen
  } from '@/utils/assist';
  // import { validatenull } from "@/utils/validate";
  // import { getStore } from "@/utils/store.js";
  export default {
    components: {
      top,
      tags,
      sidebar,
      screenshot,
      syClick,
    },
    name: 'index',
    data() {
      return {
        //刷新token锁
        refreshLock: false,
        //刷新token的时间
        refreshTime: '',
        
         // 标签页
      };
    },
    created() {
      //实时检测刷新token
      this.refreshToken();
    },
    mounted() {
      this.init();
    },
    computed: mapGetters(['isLock', 'isCollapse', 'website','openRoute']),
    props: [],
    methods: {
      ...mapActions(['setScreen']),
      removeAll(){

      },
      removeTab(){

      },
      changeTag(){

      },
      removeElseTag(){
        var arr=[this.openRoute.find((item)=>{return item.showClick==true})]
        console.log(arr)
        this.$store.commit('user/SET_OPEN_ROUTE',arr);
        
      },
      showCollapse() {
        this.$store.commit('SET_COLLAPSE');
      },
      // 屏幕检测
      init() {
        this.setScreen(getScreen());
        window.onresize = () => {
          setTimeout(() => {
            this.setScreen(getScreen());
          }, 0);
        };
      },
      // 10分钟检测一次token
      refreshToken() {
        /*this.refreshTime = setInterval(() => {
          const token = getStore({
            name: "token",
            debug: true
          });
          const date = calcDate(token.datetime, new Date().getTime());
          if (validatenull(date)) return;
          if (!(date.seconds >= this.website.tokenTime) && !this.refreshLock) {
            this.refreshLock = true;
            this.$store
              .dispatch("RefeshToken")
              .then(() => {
                this.refreshLock = false;
              })
              .catch(() => {
                this.refreshLock = false;
              });
          }
        }, 10000);*/
      }
    }
  };
</script>
<style>
.bottom{
  text-align:center;
  margin-top:10px;
}

</style>
