Pārlūkot izejas kodu

修复页面黑屏问题

baiyanting 1 gadu atpakaļ
vecāks
revīzija
83ebbc2744
3 mainītis faili ar 14 papildinājumiem un 6 dzēšanām
  1. 8 2
      src/App.vue
  2. 5 4
      src/store/index.js
  3. 1 0
      src/views/layout/Header.vue

+ 8 - 2
src/App.vue

@@ -138,7 +138,9 @@ export default {
       return this.$store.state?.menuData?.length;
     },
   },
-  created() {},
+  created() {
+ 
+  },
   mounted() {
     let that = this;
     that.setScale();
@@ -199,7 +201,11 @@ export default {
     // 获取全部场站(不分风电光伏)
     async getAllStation() {
       const { data: datas } = await getAllStation();
-      this.$store.commit("changeStationAll", datas);
+      if (datas) {
+        this.$store.commit("changeStationAll", datas);
+      } else {
+        this.$store.commit("changeStationAll", []);
+      }
     },
     login() {
       this.$store.commit("user/SET_LOGINSTATE", true);

+ 5 - 4
src/store/index.js

@@ -4,7 +4,8 @@ import user from "./modules/user";
 import routes from "./modules/router";
 import getters from "./getters";
 const debug = process.env.NODE_ENV !== "production";
-
+import { getCookie, setCookie } from "@/utills/auth"; // getToken from cookie
+import { get } from "jquery";
 // 默认状态
 const state = {
   websocketTimeSec: 1000,
@@ -20,8 +21,8 @@ const state = {
   cftList: localStorage.getItem("cftList")
     ? JSON.parse(localStorage.getItem("cftList"))
     : [],
-  stationListAll: localStorage.getItem("stationListAll")
-    ? JSON.parse(localStorage.getItem("stationListAll"))
+  stationListAll: getCookie("stationListAll")
+    ? JSON.parse(getCookie("stationListAll"))
     : [],
   boosterAlarm: JSON.parse(localStorage.getItem("boosterAlarm")) || 0,
   drawer: JSON.parse(localStorage.getItem("drawer")) || false,
@@ -60,7 +61,7 @@ const mutations = {
   },
   changeStationAll(state, data) {
     state.stationListAll = data;
-    localStorage.setItem("stationListAll", JSON.stringify(data));
+    setCookie("stationListAll", JSON.stringify(data));
   },
   changeBoosterAlarm(state, data) {
     state.boosterAlarm = data;

+ 1 - 0
src/views/layout/Header.vue

@@ -234,6 +234,7 @@ export default {
           userId: getCookie("userId"),
         }).then((res) => {
           this.$store.commit("user/REMOVE_TOKEN");
+           this.$store.commit("changeStationAll", []);
           this.$router.push("/login");
         });
       }