longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
124
125
126
127
128
<template>
  <div id="app" class="el-science-blue" :class="getClass">
    <router-view ref="routerView"></router-view>
  </div>
</template>
 
<script>
import { Timeout } from "@/assets/js/tools";
 
let link;
export default {
  name: "App",
  data() {
    return {
      fullScreen: false,
      timer: new Timeout(),
    };
  },
  watch: {
    "$store.state.ukey.connect"(isConnet) {
      this.$store.dispatch("ukey/checkIsIn", isConnet);
    },
    "$store.state.ukey.isIn"(isIn) {
      this.$store.dispatch("ukey/changeId", isIn);
    },
    "$store.state.theme.activeSkin"(val) {
      if (val == "science-blue") {
        link.href = "./theme/science-blue.css";
      } else if (val == "science-green") {
        link.href = "./theme/science-green.css";
      } else if (val == "science-black") {
        link.href = "./theme/science-black.css";
      } else if (val == "science-purple") {
        link.href = "./theme/science-purple.css";
      } else if (val == "science-skyBlue") {
        link.href = "./theme/science-skyBlue.css";
      } else if (val == "science-ziluolan") {
        link.href = "./theme/science-ziluolan.css";
      }
      if (window.parent) {
        window.parent.document.getElementsByClassName("theme")[0].href =
          link.href;
      }
      let iframes = this.$refs.routerView.$el.getElementsByTagName("iframe");
      for (let i = 0; i < iframes.length; i++) {
        iframes[i].contentDocument.getElementById("theme").href = link.href;
      }
    },
  },
  mounted() {
    this.startGetServerTime();
    // 启动ukey监控
    this.$store.dispatch("ukey/load", true);
    require("./assets/css/m-elementui.css");
    this.appenCss();
    require("./assets/css/basic.css");
    require("./assets/css/common.css");
  },
  methods: {
    appenCss() {
      link = document.createElement("link");
      link.type = "text/css";
      link.id = "theme";
      link.setAttribute("class", "theme");
      link.rel = "stylesheet";
      if (this.$store.state.theme.activeSkin == "science-blue") {
        link.href = "./theme/science-blue.css";
      } else if (this.$store.state.theme.activeSkin == "science-green") {
        link.href = "./theme/science-green.css";
      } else if (this.$store.state.theme.activeSkin == "science-black") {
        link.href = "./theme/science-black.css";
      } else if (this.$store.state.theme.activeSkin == "science-purple") {
        link.href = "./theme/science-purple.css";
      } else if (this.$store.state.theme.activeSkin == "science-skyBlue") {
        link.href = "./theme/science-skyBlue.css";
      } else if (this.$store.state.theme.activeSkin == "science-ziluolan") {
        link.href = "./theme/science-ziluolan.css";
      }
      document.getElementsByTagName("head")[0].appendChild(link);
    },
    startGetServerTime() {
      this.timer.start(() => {
        this.$axios
          .all([this.getServerTime()])
          .then(() => {
            this.timer.open();
          })
          .catch(() => {
            this.timer.open();
          });
      }, 10 * 1000);
    },
    getServerTime() {
      this.$apis.login
        .getServerTime()
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            sessionStorage.setItem("serverStamp", rs.data);
          } else {
            sessionStorage.setItem("serverStamp", new Date().getTime());
          }
        })
        .catch((error) => {
          sessionStorage.setItem("serverStamp", new Date().getTime());
          console.log(error);
        });
    },
  },
  computed: {
    getClass() {
      return {
        "no-bg": this.$route.path == "/home" ? false : true,
      };
    },
  },
};
</script>
 
<style>
#app {
  box-sizing: border-box;
  height: 100vh;
}
#app.no-bg {
  background-image: none;
}
</style>