<template>
  <a-config-provider :locale="zh_CN">
    <div class="d-flex flex-row flex-nowrap" id="app">
      <btn-con />
      <router-view class="flex-1 bg pa-3"></router-view>
    </div>
  </a-config-provider>
</template>

<script>
import { mapState, mapActions, mapMutations } from 'vuex';
import zh_CN from 'ant-design-vue/lib/locale-provider/zh_CN';
import BtnCon from 'components/BtnCom/BtnCon.vue';

export default {
  name: 'app',
  components: { BtnCon },
  data() {
    return {
      zh_CN,
    };
  },

  computed: mapState(['anyringToken', 'ptProps']),

  watch: {
    ptProps(val) {
      if (val.userId) {
        const params = { userId: val.userId };
        this.getUserId(params);
        console.log('val.userId:' + val.userId);
      }
    },
  },

  created() {
    // 测试数据
    const userId = '1218763410024566784';
    const params = { userId };
    this.getUserId(params);

    const that = this;
    window.plugin = window.TallPlugin.init();
    // 调用created方法 向主窗体发送created消息，以便来接受、存储主窗体传递来的参数
    // created接受一个回调函数 created成功后调用 可选参数
    // 接受PT传过来的 插件id，项目id，角色id，任务id，userId
    window.plugin.created(function(props) {
      console.log('props: ', props);
      that.setPtProps(props);
    });
  },

  methods: {
    ...mapActions(['getUserId']),
    ...mapMutations('home', ['setPtProps']),
  },
};
</script>

<style>
html {
  overflow: hidden !important;
}

html,
body,
#app {
  height: 100%;
}

#app {
  background: transparent;
}
</style>
