Explorar el Código

fix: pad版本定时更新的问题

chenzhen2 hace 2 años
padre
commit
e75701b1b0
Se han modificado 5 ficheros con 64 adiciones y 31 borrados
  1. 30 4
      src/App.vue
  2. 4 4
      src/apis/portrait.ts
  3. 8 6
      src/apis/user.ts
  4. 13 15
      src/views/envmonitor/components/Air/index.vue
  5. 9 2
      vue.config.js

+ 30 - 4
src/App.vue

@@ -17,7 +17,7 @@
 import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
 import Header from "@/components/header/Comheader.vue";
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
-import { getCookieMac } from "./utils/cookies";
+import axios from "axios";
 
 export default defineComponent({
   components: {
@@ -25,10 +25,30 @@ export default defineComponent({
   },
   setup() {
     const route: any = useRoute();
-    const data = reactive({
+    const proxyData = reactive({
       route: route,
       transitionName: "slide-right",
       showHeader: false,
+      getPadVersion() {
+        axios.get(`/pad_mtime`).then((res: any) => {
+          console.log("获取版本号");
+          console.log(res);
+          let data: any = res.data || {};
+          let pad_mtime: any = data.pad_mtime;
+          let oldTime: any = localStorage.getItem("pad_mtime");
+          if (oldTime && oldTime !== pad_mtime) {
+            localStorage.setItem("pad_mtime", pad_mtime);
+            window.location.reload();
+          } else {
+            localStorage.setItem("pad_mtime", pad_mtime);
+          }
+        });
+      },
+      timerPadVersion() {
+        setInterval(() => {
+          proxyData.getPadVersion();
+        }, 5000);
+      },
     });
     nextTick(() => {
       const document: any = window.document;
@@ -41,9 +61,11 @@ export default defineComponent({
         event.preventDefault();
       });
     });
-    onMounted(() => {});
+    onMounted(() => {
+      proxyData.timerPadVersion();
+    });
     return {
-      ...toRefs(data),
+      ...toRefs(proxyData),
     };
   },
 });
@@ -71,3 +93,7 @@ export default defineComponent({
   }
 }
 </style>
+
+function getVersionTime() {
+  throw new Error("Function not implemented.");
+}

+ 4 - 4
src/apis/portrait.ts

@@ -6,10 +6,10 @@ import { setQueryConfig, getUserInfo } from '@/utils'
 
 import { duoduoenvService } from '@/config'
 
-const comInfo: any = {}
-comInfo.userId = getUserInfo().userId
-comInfo.projectId = getUserInfo().projectId
-const comParams: string = ''
+// const comInfo: any = {}
+// comInfo.userId = getUserInfo().userId
+// comInfo.projectId = getUserInfo().projectId
+// const comParams: string = ''
 
 //查询 今日新增 排名
 export const queryTotalIntegral = (params: any) => {

+ 8 - 6
src/apis/user.ts

@@ -11,12 +11,6 @@ import { setupService, testApi } from '@/config'
 export const getUsersInfo = () => {
   return https().request(`/mngserver/userInfo`, Method.GET, undefined, ContentType.json)
 }
-/**
- * 获取企业用户列表
- */
-export const getCompanyUsers = () => {
-  return https().request('/api/user/companyUsers', Method.GET, undefined, ContentType.json)
-}
 
 /**
  * 
@@ -26,3 +20,11 @@ export const getCompanyUsers = () => {
 export const login = (data: any) => {
   return https().request(`/server/login`, Method.POST, data, ContentType.json)
 }
+
+/**
+ * 
+ * @returns 获取当前版本更新的时间
+ */
+export const getPadVersionTimer = () => {
+  return https().request(`/pad_mtime`, Method.GET, undefined, ContentType.json)
+}

+ 13 - 15
src/views/envmonitor/components/Air/index.vue

@@ -104,8 +104,7 @@
           />
         </div>
         <div class="dialog-text">
-          <div
-            class="air-body-item-num">
+          <div class="air-body-item-num">
             <!-- <div class="air-temp-num">{{ temperature }}</div> -->
             <!-- <div
               class="air-temp-num"
@@ -339,21 +338,20 @@ export default defineComponent({
                 proxyData.airData = resData;
                 proxyData.formateModel(proxyData.airData.mode);
                 contx.emit("updateAirTemp", proxyData.airData.tempSet);
-                if (
-                  proxyData.airData.icon &&
-                  (proxyData.airData.icon === 7 || proxyData.airData.icon === 8)
-                ) {
+                if (proxyData.airData.icon && proxyData.airData.icon === 7) {
                   proxyData.airData.isOpen = false;
                   proxyData.airData.airImg = parseImgUrl(
                     "page-officehome",
                     "air_close.png"
                   );
                 } else {
-                  proxyData.airData.isOpen = true;
-                  proxyData.airData.airImg = parseImgUrl(
-                    "page-officehome",
-                    "openair.png"
-                  );
+                  if (proxyData.airData.icon && proxyData.airData.icon !== 6) {
+                    proxyData.airData.isOpen = true;
+                    proxyData.airData.airImg = parseImgUrl(
+                      "page-officehome",
+                      "openair.png"
+                    );
+                  }
                 }
               }
             }
@@ -361,8 +359,8 @@ export default defineComponent({
             if (type === "feedback") {
               if (resData.notice) {
                 proxyData.airSetText.notice = resData.notice;
-                if(resData.remark && resData.remark.length){
-                  proxyData.airSetText.remark =resData.remark.split("*")
+                if (resData.remark && resData.remark.length) {
+                  proxyData.airSetText.remark = resData.remark.split("*");
                 }
                 if (proxyData.feedbackTimer) {
                   clearTimeout(proxyData.feedbackTimer); // 拿到反馈文案清除定时器
@@ -513,8 +511,8 @@ export default defineComponent({
               // debugger
               if (resData.notice) {
                 proxyData.airSetText.notice = resData.notice;
-                if(resData.remark && resData.remark.length){
-                  proxyData.airSetText.remark =resData.remark.split("*")
+                if (resData.remark && resData.remark.length) {
+                  proxyData.airSetText.remark = resData.remark.split("*");
                 }
               } else {
                 proxyData.getFeedbackTimer(btnType, resData.id);

+ 9 - 2
vue.config.js

@@ -56,8 +56,8 @@ module.exports = {
         plugins: [
           require('postcss-pxtorem')({ // 把px单位换算成rem单位
             rootValue: 98, // vant官方使用的是37.5
-            minPixelValue:4,
-            unitPrecision:3,
+            minPixelValue: 4,
+            unitPrecision: 3,
             // selectorBlackList: ['vant', 'mu'], // 忽略转换正则匹配项
             propList: ['*']
           })
@@ -83,6 +83,13 @@ module.exports = {
           '^/sgipad/duoduo-service': '/duoduo-service'
         }
       },
+      "/pad_mtime": {
+        target: 'http://39.106.8.246:9091/',
+        changeOrigin: true,
+        pathRewrite: {
+          '^/pad_mtime': '/pad_mtime'
+        }
+      },
       '/sgipad/server/': {
         // target: 'https://duoduoenv.sagacloud.cn',
         target: 'http://sso.sagacloud.cn',