App.vue 4.16 KB
<template>
  <div id="glsx-sub-system" :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="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 {
      isQiankun: window.__POWERED_BY_QIANKUN__,
      logo: require("images/logo.png"),
    };
  },
  watch: {
    $route(to, from) {
      if (this.isQiankun) {
        this.getBreadcrumb();
      }
    },
  },
  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()
    this.$onGlobalStateChange((state, prev) => {
      if (state.isCollapsed != this.isCollapse) {
        this.toggleCollapse();
      }
    });
  },
  computed: {
    ...mapGetters(["isCollapse", "isFullsize"]),
  },
  methods: {
    getBreadcrumb() {
      const {
        getters: { curBreadCrumb },
      } = this.$root.parentVuex;
      let matched = this.$route.matched.filter((item) => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
      const first = matched[0];
      const { meta, path } = first;
      const basePath = "/oEshield#";
      let breadcrumb = [];
      if (meta) {
        const { title, pushState } = meta;
        if (pushState && title) {
          breadcrumb.push({
            name: title,
            path: basePath + path,
          });
          history.state.pushState = pushState;
          history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]];
          // this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]);
        }
      }
    },
    toggle() {
      this.toggleCollapse();
    },
    ...mapActions(["toggleCollapse"]),
    navigate() {
      let routeData = this.$router.resolve({
        path: "/notice",
        query: {},
      });

      window.open(routeData.href, "_blank");
    },
  },
  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>
<style lang="scss">
.el_table {
  thead {
    th {
      background: rgba($color: #f2f2f2, $alpha: 0.5) !important;
    }
  }
}
.links_group {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 0;
  .name {
    font-size: 18px;
    font-weight: bold;
    color: #666;
  }
}
</style>