index.vue 2.86 KB
<template>
  <div :class="isFullsize?'full-size':''">
    <div id="wrap" class="wrap" :class="isCollapse?'full-width':''">
      <!-- 主体 -->
      <main>
        <el-row class="topbar">
          <el-button type="primary" size="small" @click="toggle" class="toggle-btn"><i class="fa fa-bars"></i></el-button>
          <img :src="logo" class="logo">

          <a class="pull-right right-link" href="javascript:void(0)" @click="logout">
            <i class="fa fa-sign-out"></i> 登 出
          </a>
          <a class="pull-right right-link" href="javascript(0)" @click.prevent="navigate">
            <i class="fa fa-bell-o"></i> 系统公告
          </a>
        </el-row>
        <router-view></router-view>
      </main>
      <!-- 主体 /-->
      <!-- 左边导航栏 -->
      <v-side-bar class="sidebar"></v-side-bar>
      <!-- 左边导航栏 /-->
    </div>
  </div>
</template>

<script>
import store from "@/vuex/store.js";
import { mapGetters, mapActions } from "vuex";
import vSideBar from "@/components/SideBar.vue";

export default {
  name: "app",
  data() {
    return {
      logo: require("@/assets/images/logo.png"),
    };
  },
  mounted() {
    //store.dispatch("getDeviceResources");
    // store.dispatch("getLoginUser").then((res) => {
    //   if (store.state.common.username === "gqgdcx") {
    //     this.$router.push({ path: "business/gqOrder" });
    //   }
    //   if (store.state.common.isCheckbook) {
    //     // console.log(this.$route)
    //     // this.$router.push({path:"accounts/accountsList"})
    //   }
    // });
    window.onresize = () => {
      const w = window,
        d = document,
        e = d.documentElement,
        g = d.getElementsByTagName("body")[0],
        x = w.innerWidth || e.clientWidth || g.clientWidth,
        y = w.innerHeight || e.clientHeight || g.clientHeight;

      d.getElementsByTagName("main")[0].style["minHeight"] = y + "px";
    };
    window.onresize();
  },
  computed: {
    ...mapGetters(["isCollapse", "isFullsize"]),
  },
  methods: {
    toggle() {
      this.toggleCollapse();
    },
    ...mapActions(["toggleCollapse"]),
    navigate() {
      let routeData = this.$router.resolve({
        path: "/notice",
        query: {},
      });

      window.open(routeData.href, "_blank");
    },

    // 退出登录
    logout(){
      sessionStorage.removeItem('token')
      sessionStorage.removeItem('user')
      this.$store.dispatch('logout')
      this.$router.push({path:'/'})
    }

  },
  components: {
    vSideBar,
  },
  store,
};
</script>

<style scoped>
.topbar {
  min-height: 50px;
  padding: 15px 10px;
}
.toggle-btn,
.logo {
  vertical-align: middle;
}
.logo {
  margin-left: 10px;
}
a.right-link {
  color: #999;
  font-size: 14px;
  margin-right: 20px;
  line-height: 30px;
  text-decoration: none;
}
.full-size main {
  margin: 0;
}
.full-size .sidebar,
.full-size .topbar {
  display: none;
}
</style>