he wei
2024-04-15 c94f1afa786f297be86b01b49a641b2c0ad98b6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
  <div :class="classObj" class="app-wrapper">
    <!-- <div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" /> -->
    <div v-if="sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
    <sidebar class="sidebar-container" />
    <div class="main-container">
      <div class="inner">
        <div class="main-container-wrapper">
          <div class="main-container-header">
            <navbar />
            <tags-view />
          </div>
          <div class="main-container-content">
            <app-main />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
import ResizeMixin from "./mixin/ResizeHandler";
import { mapState } from "vuex";
 
import createWs from "@/assets/js/websocket/plus";
const WSMixin = createWs("loginCheck");
 
export default {
  name: "Layout",
  components: {
    AppMain,
    Navbar,
    Settings,
    Sidebar,
    TagsView,
  },
  mixins: [ResizeMixin, WSMixin],
  computed: {
    ...mapState({
      sidebar: (state) => state.app.sidebar,
      device: (state) => state.app.device,
    }),
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === "mobile",
      };
    },
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
    },
    onWSMessage1: function (res) {
      //console.log(res)
      let resData = JSON.parse(res.data);
      if (!resData.data.checkLogin.data) {
        this.$layer.msg(resData.data.checkLogin.msg);
        this.$store.dispatch("user/logout");
        setTimeout(() => {
          this.$router.push("/login");
          location.reload();
        }, 2000);
      }
    },
    onWSOpen1: function () {
      console.log("通讯成功");
    },
  },
};
</script>
 
<style lang="less" scoped>
.app-wrapper {
  display: flex;
  height: 100%;
  .drawer-bg {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 999998;
  }
  &.hideSidebar .sidebar-container {
    transform: translate(-100%, 0);
  }
  .sidebar-container {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 999999;
  }
  .main-container {
    flex: 1;
    position: relative;
    .inner {
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
    }
  }
}
 
.main-container-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
  .main-container-content {
    flex: 1;
    overflow-y: auto;
    margin: 0 10px;
    background: #122c43;
  }
}
</style>