<template>
  <div
    id="app"
    :class="{
      appNoWidth:
        $route.path == '/data' ||
        $route.path == '/note' ||
        $route.path == '/works',
      appNoHeight: $route.path == '/liveRoom',
      GMBg:
        this.$route.query.org == 'eb2af5e9-ac3d-46b6-9fe3-3c1c364f0217' &&
        $route.path != '/courseGM' &&
        $route.path != '/course/addCourseGM' &&
        $route.path != '/dataGM',
      testBg: $route.path == '/test'
    }"
  >
    <button @click="toggleVConsole" class="openV" v-show="false"></button>
    <!-- <div class="app_head" :class="{stuWidth:$route.path == '/student'}"> -->
    <!-- <div class="logo" @click="goTo('/course')"></div>
      <span style="margin-left: 10px; color: #fff; font-weight: 600" @click="goTo('/course')"
        >PBL项目管理平台</span
      >
      <div class="user_head" v-if="this.$store.state.isLogin">
        <div class="noticeBox">
          <i class="noticeI" @click="goTo('/works')"></i>
          <span v-if="this.$store.state.nCount != 0">{{
            this.$store.state.nCount > 99 ? "99+" : this.$store.state.nCount
          }}</span>
        </div>
        <span class="user_name">{{
          this.$store.state.userInfo ? this.$store.state.userInfo.name : "用户"
        }}</span>
        <div @click="exit">
          <i class="exitI"></i>
          <el-button type="text" style="color: white" 
            >退出</el-button
          >
        </div>
    </div>-->
    <!-- </div> -->
    <div
      :class="{
        gHeight: $route.path == '/Grid',
        getOverView: $route.path == '/myReport',
      }"
      style="width: 100%; height: 100%"
      :style="{ overflow: $route.path == '/liveRoom' ? 'hidden' : '' }"
    >
      <!-- main 内容 -->
      <keep-alive>
        <!-- 这里是会被缓存的视图组件 -->
        <router-view
          v-if="$route.meta.keepAlive"
          :class="{ pb_body: isShowNav }"
        />
      </keep-alive>
      <!-- 这里是不被缓存的视图组件 -->
      <router-view
        v-if="!$route.meta.keepAlive"
        :class="{ pb_body: isShowNav }"
      />

      <!-- 底部导航 -->
      <!-- <footer-nav
				v-if="isShowNav"
				:luyou="this.$store.state.luyou"
      ></footer-nav>-->
    </div>
  </div>
</template>

<script>
// import leftBar from "./components/tools/leftBar";
import { Message } from "element-ui";
import VConsole from 'vconsole';
export default {
  name: "App",
  data() {
    return {
      isShowNav: true, // 是否显示导航 Tab
      navTabs: [
        "/class",
        "/course",
        "/courseGM",
        "/data",
        "/dataGM",
        "/notice",
        "/student",
        "/works",
        "/worksGM",
        "/worksDetail",
        "/course/courseDetail",
        "/library",
        "/libraryGM",
        "/classRoom",
        "/liveRoom",
        "/addPPt",
        "/studyLibrary",
        "/GridList",
        "/wordList",
        "/Ttype",
        "/banner",
        "/studentCourse",
        "/scourse",
        "/studentCheckCourse",
        "/tcData",
        "/studioCourse",
        "/teacherSource",
        "/grade",
        "/test",
        "/testStudent",
        "/checkToTest"
        // "/eventCenter",
        // "/addRace",
        // "/anliDetail",
        // "/course/addCourse",
        // "/ask",
        // "/ask/askList",
      ], // 导航
      vConsoleEnabled: false,
      vConsoleInstance: null,
    };
  },
  // components: {
  //   "footer-nav": leftBar,
  // },
  created: function () {
    this.routerP();
    // this.getnCount();
    setInterval(() => {
      // this.getnCount();
    }, 60000);
  },
  methods: {
    toggleVConsole() {
      if (this.vConsoleEnabled) {
        // 关闭 vConsole
        this.vConsoleInstance.destroy();
        this.vConsoleInstance = null;
      } else {
        // 开启 vConsole
        this.vConsoleInstance = new VConsole();
      }
      this.vConsoleEnabled = !this.vConsoleEnabled;
    },
    isLogin() {
      const loading = this.$loading.service({
        background: "rgba(255, 255, 255)",
        target: document.querySelector("body"),
      });
      var _isLogin = this.$cookies.get("tlogin");
      var userInfo = this.$cookies.get("teacherInfo");
      // if (_isLogin == "1" && userInfo) {
      loading.close();
      this.$store.commit("update", ["isLogin", true]);
      // var info = JSON.parse(window.sessionStorage.getItem("userInfo"));
      this.$store.commit("update", ["userInfo", userInfo]);
      let router_path = this.$route.path;
      if (router_path == "/") {
        this.$router.push("/course");
      }
      // } else {
      //   this.$store.commit("update", ["isLogin", false]);
      //   Message({
      //     message: "未登录，请登录",
      //     type: "warning",
      //   });
      //   setTimeout(() => {
      //     loading.close();
      //     this.$router.push("/login");
      //   }, 2000);
      // }
    },
    getnCount() {
      let params = {
        bid: this.$store.state.userInfo.userid,
      };
      this.ajax
        .get(this.$store.state.api + "getNcount", params)
        .then((res) => {
          console.log(res);
          if (res.data[0].length > 0) {
            this.$store.commit("update", ["nCount", res.data[0][0].num]);
          } else {
            this.$store.commit("update", ["nCount", 0]);
          }
        })
        .catch((err) => {
          console.error(err);
        });
    },
    routerP() {
      const { navTabs } = this.$data;
      let router_path = this.$route.path;
      console.log(router_path);
      if (router_path != "/login") {
        this.isLogin();
      }
      var a = 0;
      for (var i = 0; i < navTabs.length; i++) {
        if (router_path == navTabs[i]) {
          this.isShowNav = true;
          a = 1;
          break;
        }
      }
      if (a == 0) {
        this.isShowNav = false;
      }
    },
    exit() {
      sessionStorage.clear();
      this.$cookies.remove("tlogin");
      this.$cookies.remove("teacherInfo");
      this.$store.commit("update", ["isLogin", false]);
      this.$store.commit("update", ["userInfo", {}]);
      Message({
        message: "退出成功",
        type: "success",
      });
      this.$router.push("/login");
    },
    goTo(path) {
      this.$router.push(path);
    },
  },
  watch: {
    $route(to, from) {
      const { navTabs } = this.$data;
      const toPath = to.path;
      const fromName = from.name;
      var a = 0;
      for (var i = 0; i < navTabs.length; i++) {
        if (toPath == navTabs[i]) {
          this.isShowNav = true;
          a = 1;
          break;
        }
      }
      if (a == 0) {
        this.isShowNav = false;
      }
    },
  },
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}
/* body {
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
} */
#app {
  height: 100%;
  width: 100%;
  background: #e6eaf0;
  /* min-width: 1380px; */
  /* min-width: 1250px; */
}

.appNoWidth {
  min-width: unset !important;
  display: inline-block !important;
  min-width: 550px;
}

.appNoHeight {
  min-height: 750px;
}

.app_head {
  height: 67.5px;
  width: 100%;
  background-color: rgb(61, 103, 188);
  display: flex;
  align-items: center;
  min-width: 1000px;
}
.logo {
  height: 48px;
  width: 73px;
  background: url("./assets/logo.png");
  background-size: 100% 100%;
  margin-left: 20px;
}
.pb_body {
  /* padding: 20px; */
  /* width: 98%; */
  /* min-width: 745px;*/
  /* display: inline-block; */
  /* height: 95%; */
  /* min-height: 750px; */
  background: #fff;
  border-radius: 5px;
  /* position: absolute; */
}
.pb_head {
  font-size: 26px;
  /* font-weight: 600; */
  width: 95%;
  margin: 10px auto;
  padding: 10px 5px;
  border-bottom: 1px solid #eee;
}
.pb_content {
  /* height: 100%; */
}
.pb_content_body {
  width: 94%;
  margin: 10px auto;
  /* overflow: auto;
	  height: calc(100% - 120px); */
}
.user_head {
  display: flex;
  align-items: center;
  margin-left: auto;
  margin-right: 20px;
  font-size: 18px;
  font-weight: 600;
}
.user_head .user_name {
  color: #fff;
  margin-right: 10px;
}
.user_head div {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.user_head .exitI {
  background-image: url("./assets/exit.png");
  width: 25px;
  height: 25px;
  background-size: 100% 100%;
  margin-top: 1px;
  line-height: 25px;
  vertical-align: text-top;
  background-repeat: no-repeat;
}
.noticeBox {
  position: relative;
  margin-right: 10px;
}

.user_head .noticeI {
  background-image: url("./assets/icon/noticeA.png");
  width: 25px;
  height: 25px;
  background-size: 100% 100%;
  margin-top: 1px;
  line-height: 25px;
  vertical-align: text-top;
  background-repeat: no-repeat;
  cursor: pointer;
}
.noticeBox span {
  position: absolute;
  background: red;
  width: 15px;
  height: 15px;
  border-radius: 30px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  top: -3px;
  right: -3px;
}
.stuWidth {
  min-width: 1180px;
}
.gHeight {
  height: 100%;
}
html::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 6px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 6px;
}

/*定义滚动条轨道 内阴影+圆角*/
html::-webkit-scrollbar {
  border-radius: 10px;
  background-color: #eee;
}

/*定义滑块 内阴影+圆角*/
html::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  background-color: rgba(0, 0, 0, 0.1);
}

.btnClassGM {
  background: #8681b7 !important;
  border-color: #8681b7 !important;
}

.btnClassGM:focus,
.btnClassGM:hover {
  background: #8681b7 !important;
  border-color: #8681b7 !important;
}

.GMBg {
  background: rgb(184, 181, 202) !important;
}

.testBg{
  background: #f0f2f5;
}

.cancelbtnGM:focus,
.cancelbtnGM:hover {
  color: rgb(92, 84, 159) !important;
  border-color: #5c549f !important;
  background-color: #dbd7ff !important;
}

.text_tooltip {
  max-width: 350px !important;
}

.text_tooltip2 {
  max-width: 400px !important;
}

.getOverView{
  overflow-x: auto;
}

.showtip{
  z-index: 999999999 !important;
}
.el-message-box{
  padding-bottom: 20px !important;
}
.el-message-box__header{
  font-weight: 700 !important;
}
.el-message-box__content{
  padding: 10px 15px 25px !important;
}
.el-icon-warning:before{
  content: '' !important;
  width: 20px !important;
  height: 20px !important;
  display: block !important;
  background-image: url("./assets/icon/new/tips.png") !important;
  background-size: 100% 100% !important;
}
.el-message-box__status+.el-message-box__message{
  padding-left: 30px !important;
}
.el-message-box__btns{
  text-align: center !important;
}

.el-message-box__btns > .el-button--small{
  border: 1px solid #CAD1DC !important;
  background: #E7EBF1 !important;
  color: #060E17 !important;
}

.el-message-box__btns > .el-button--small:hover{
  background: #CAD1DC !important;
  color: #060E17 !important;
}

.el-message-box__btns > .el-button--primary{
  border: 1px solid #EE3E3E !important;
  background: #EE3E3E !important;
  color: #fff !important;
}

.el-message-box__btns > .el-button--primary:hover{
  border: 1px solid #cd3434 !important;
  background: #cd3434 !important;
  color: #fff !important;
}

.el-checkbox:hover .el-checkbox__label{
  color:#409EFF;
}
.el-checkbox .el-checkbox__label{
  color: #0E1E33;
}
.el-checkbox:hover .el-checkbox__inner{
  border-color: #409EFF;
}
.el-checkbox .el-checkbox, .el-checkbox .el-checkbox__input{
  display: flex;
  align-items: center;
}
.el-cascader-node__label{
  max-width: 150px;
}

.el-pagination.is-background .el-pager li:not(.disabled).active{
  background-color: #0061FF !important;
  color: #FFF !important;
}

.el-pagination.is-background .el-pager li:not(.disabled):hover {
    color: #0061FF !important;
}

.el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #0061FF !important;
    color: #FFF !important;
}

.tooltip {
  position: absolute; /* 确保tooltip处于正确的定位 */
  top: 0;
}

.el-table-filter__checkbox-group label.el-checkbox {
  display: flex !important;
}

.el-table-filter__bottom{
  display: flex;
  justify-content: flex-end;
}

.custom-confirm-box{
  width: 450px;
}

.openV {
  position: absolute;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  z-index: 99999;
}

.orange_number {
  color: #FF9400;
  font-weight: bold;
}

.count-node {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  height: 24px;
  padding: 0 8px;
  line-height: 22px;
  margin-left: 6px;
  background-color: #f4f4f5;
  border: 1px solid #e9e9eb;
  border-radius: 4px;
  color: #909399;
  font-size: 12px;
  box-sizing: border-box;
}

.tagOption.selected{
  color: #ef9e28 !important;
}

.filter-item-option.selected{
  color: #ff9300;
}

.loadingColor .el-loading-spinner .path {
  stroke: #FF9500 !important;  /* 橙色加载动画 */
}

.loadingColor .el-loading-spinner .el-loading-text {
  color: #FF9500 !important;  /* 橙色文字 */
}
</style>
