<template>
  <div style="max-width: 1200px;" :style="{margin:width==1200+'px'?'10px auto':'10px 0 '}" id="app">
    <!-- <router-view v-slot="{ Component }">
      <keep-alive :includes="['Applyfor']">
        <component :is="Component" />
      </keep-alive>
    </router-view> -->

    <!-- <keep-alive :includes="['Applyfor']">
      <router-view></router-view>
    </keep-alive> -->

    <keep-alive :include="catchRoutes">
      <router-view :key="$route.fullPath" />
    </keep-alive>

    <!-- <nav-bar v-show="!isShowtabbar"></nav-bar> -->
    <tab-bar v-show="isShowtabbar"></tab-bar>
  </div>
</template>

<script>
import TabBar from '@/components/TabBar'
// import store from './store';
// import NavBar from '@/components/NavBar'

import { platform } from '@/utils/dingtalk.js'
import { mapState } from 'vuex'

export default {
  components: {
    TabBar,
  },
  data() {
    return {
      allowPath: ['/', '/approve', '/my'],
      tabbarList: [
        {
          title: '首页',
          to: '/',
          icon: require("@/assets/icons-index.png"),
          iconSel: require("@/assets/icons-index-sel.png"),
        },
        {
          title: '审批',
          to: '/about',
          icon: require("@/assets/icons-approve.png"),
          iconSel: require("@/assets/icons-approve-sel.png"),
        },
        {
          title: '我的',
          to: '/my',
          icon: require("@/assets/icons-my.png"),
          iconSel: require("@/assets/icons-my-sel.png"),
        },
      ],
      tabbarActive: 0,
    };
  },
  computed: {
    ...mapState('app', [
      'catchRoutes'
    ]),
    isShowtabbar() {
      const { path } = this.$route
      return this.allowPath.includes(path)
    }
  },
  async created() {
    try {
      // NOTE: 获取各种类型枚举
      let list = this.$store.state.enum.evectionTypeList

      if (!list.length) {
        this.$store.dispatch('enum/getTypeList')
      }

      console.log('%c Current Environment >>>', 'background: blue; color: #fff', platform);

      // NOTE: 只有钉钉环境下才能获取静态Code
      if (platform !== 'notInDingTalk') {
        // NOTE: 静默获取用户Token
        console.log(111);
        await this.$store.dispatch('user/login')

        // 获取授权
        this.$store.dispatch('ddtalk/postWaitAuthentication')
      }
    } catch (e) { } /* eslint-disable-line */

  }
}
</script>
