Browse Source

全局系统通知

Michael Wang 4 years ago
parent
commit
323c080d63
2 changed files with 81 additions and 0 deletions
  1. 78 0
      src/features/Login/GlobalNotice.vue
  2. 3 0
      src/features/Login/Login.vue

+ 78 - 0
src/features/Login/GlobalNotice.vue

@@ -0,0 +1,78 @@
+<template>
+  <div></div>
+</template>
+
+<script>
+import { VUE_APP_CONFIG_FILE_SEVER_URL } from "@/constants/constants";
+export default {
+  name: "GlobalNotice",
+  data() {
+    return {
+      clicked: false,
+    };
+  },
+  watch: {
+    clicked(val) {
+      if (val) {
+        this.$Spin.hide();
+      }
+    },
+  },
+  async created() {
+    this.fetchNotice();
+    this.fetchInterval = setInterval(() => {
+      this.fetchNotice();
+    }, 60 * 1000);
+  },
+  beforeDestroy() {
+    clearInterval(this.fetchInterval);
+  },
+  methods: {
+    async fetchNotice() {
+      const url =
+        VUE_APP_CONFIG_FILE_SEVER_URL +
+        "/sys_notice/org_all.json?" +
+        Date.now() +
+        Math.random();
+      const res = await this.$http.get(url, {
+        withCredentials: false,
+      });
+
+      const notice = res.data;
+      // notice.title = "停服通知";
+      // notice.content =
+      //   "网考服务计划于 2020-09-20 22:00:00 ~ 2020-09-21 01:00:00 期间停服升级。请合理安排考试时间。";
+      if (!this.clicked && notice.enable) {
+        this.$Spin.show({
+          render: () => {
+            return (
+              <div style="width: 600px; border: 1px solid #999; border-radius: 5px; padding: 20px; color: black">
+                <div style="font-size: 28px">{notice.title}</div>
+                <div style="font-size: 18px; text-align: left">
+                  {notice.content.repeat(1)}
+                </div>
+                <div>
+                  <i-button
+                    size="large"
+                    class="qm-primary-button"
+                    style="margin-top: 30px; width: 160px"
+                    long
+                    on-click={this.clickBtn}
+                  >
+                    确定
+                  </i-button>
+                </div>
+              </div>
+            );
+          },
+        });
+      }
+    },
+    clickBtn() {
+      this.clicked = true;
+    },
+  },
+};
+</script>
+
+<style></style>

+ 3 - 0
src/features/Login/Login.vue

@@ -118,6 +118,7 @@
       </div>
       </div>
       <DevTools />
       <DevTools />
     </footer>
     </footer>
+    <GlobalNotice />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -141,6 +142,7 @@ import {
 } from "@/utils/logger";
 } from "@/utils/logger";
 import { isElectron } from "@/utils/util";
 import { isElectron } from "@/utils/util";
 import GeeTest from "./GeeTest";
 import GeeTest from "./GeeTest";
+import GlobalNotice from "./GlobalNotice";
 
 
 // 检测devtools.  仅在chrome 72+ 有效。
 // 检测devtools.  仅在chrome 72+ 有效。
 let element = new Image();
 let element = new Image();
@@ -171,6 +173,7 @@ export default {
   components: {
   components: {
     DevTools,
     DevTools,
     GeeTest,
     GeeTest,
+    GlobalNotice,
   },
   },
   data() {
   data() {
     return {
     return {