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

<script>
import ThemePicker from "@/components/ThemePicker";
import {createChatSSE, createSSE} from "./utils/SSE";

export default {
  name: "App",
  components: { ThemePicker },
  metaInfo() {
    return {
      title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
      titleTemplate: title => {
        return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
      }
    }
  },
  mounted() {
    this.$watch(
      function () {
        //可自定义监听变量
        let row = {
          // 用于连接的userId
          userId : this.$store.state.user.userInfo.userId,
          // 用于判断是否有相关消息页面的权限
          // deviceMessageMenu:  this.$store.state.user.deviceMessageMenu,
          // medicineMessageMenu:this.$store.state.user.medicineMessageMenu,
          // materialMessageMenu:this.$store.state.user.materialMessageMenu,
        }
        return row
      },
      function (newVal, oldVal) {
        //可自定义 处理创建sse连接的逻辑
        if(newVal && newVal.userId!==oldVal.userId){
          // 如果有其中任意一个消息管理的权限,都创建连接
          // if((newVal.deviceMessageMenu && newVal.deviceMessageMenu.length!=0)
          //   ||(newVal.medicineMessageMenu && newVal.medicineMessageMenu.length!=0)
          //   ||(newVal.materialMessageMenu && newVal.materialMessageMenu.length!=0)){
          //   //下行代码一定要有！！！
          //   createSSE(this);
          // }

          //下行代码一定要有！！！
          createSSE(this);

          createChatSSE(this);
        }
      },
      {
        immediate: false,
        deep: true,
      }
    );


  }
};
</script>
<style scoped>
#app .theme-picker {
  display: none;
}
.notica.el-badge__content.is-fixed{
  top:6px !important
}

.el-menu-item{
  color: #ffffff  !important;
}

</style>

<style lang="scss" scoped>
  ::v-deep .el-button.el-button--default.el-button--mini.is-plain{
    /*background: unset !important;*/
    /*border-radius: 4px !important;*/
    border: 1px solid #D31017 !important;
    color: #D31017 !important;
    /*height: 30px;*/
  }
  ::v-deep .el-button.el-button--mini.is-plain{
    border: 1px solid #D31017 !important;
    color: #D31017 !important;
  }
</style>
<style >
.customNotifyClass{
  width: 300px !important;
  word-break: break-all;
}
.el-textarea__inner{
  font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
}

</style>
