Browse Source

冲突处理

wangb 1 year ago
parent
commit
949ecb1129

+ 2 - 2
src/api/api.js

@@ -1,6 +1,6 @@
 import request from "./axios.js";
-export const baseURL = "http://10.81.3.154:6015/";
-// export const baseURL = "http://192.168.1.109:6015/";
+// export const baseURL = "http://10.81.3.154:6015/";
+export const baseURL = "http://192.168.1.109:6015/";
 import JSONBIG from "json-bigint";
 
 // 获取场站数据

+ 1 - 1
src/components/Header.vue

@@ -5,7 +5,7 @@
       <i v-if="!collapse" class="el-icon-s-fold"></i>
       <i v-else class="el-icon-s-unfold"></i>
     </div>
-    <div class="logo">综合报警系统</div>
+    <div class="logo">智能报警及预警系统</div>
     <div class="header-right">
       <div class="header-user-con">
         <el-dropdown class="user-name" trigger="click" @command="handleCommand">

+ 9 - 2
src/pages/Login.vue

@@ -6,10 +6,17 @@
       draggable="false"
     /> -->
     <div class="login-content">
+      <!-- <div class="ms-title">
+        <div style="margin-bottom: 20px">智能预警系统</div>
+        <div style="padding-bottom: 40px; font-size: 30px">
+          Intelligent Early Warning
+        </div>
+      </div> -->
       <div class="ms-title">
-        <div style="margin-bottom: 20px">综合报警系统</div>
+        <div style="margin-bottom: 20px">智能报警及预警系统</div>
         <div style="padding-bottom: 40px; font-size: 24px">
-          Integrated alarm system
+          <!-- Equipment Hidden Hazard Awareness System -->
+          Intelligent Alarms and Early Warnings System
         </div>
       </div>
       <div class="ms-login">

+ 44 - 56
src/pages/check/check.vue

@@ -1,15 +1,13 @@
 <template>
   <div>
-    <!-- <el-upload></el-upload> -->
+    <el-upload></el-upload>
   </div>
 </template>
 
 <script>
-import { decrypt } from "@/utils/jsencrypt.js";
-import { loginRequest, Login } from "/@/api/api.js";
+import { JSEncrypt } from "jsencrypt";
+import { loginRequest, getPublickey } from "/@/api/api.js";
 import { ElMessage } from "element-plus";
-import store from "@/store/index.js";
-import router from "@/router/index.js";
 export default {
   data() {
     return {
@@ -19,67 +17,57 @@ export default {
     };
   },
   created() {
-    this.checkUser();
+    this.getKey();
   },
   methods: {
     //先获取密钥,再去认证username和mark
-    // async getKey() {
-    //   this.publickey = await getPublickey();
-    //   sessionStorage.setItem("publicKey", this.publickey);
-    //   this.checkUser();
-    // },
+    async getKey() {
+      this.publickey = await getPublickey();
+      sessionStorage.setItem("publicKey", this.publickey);
+      this.checkUser();
+    },
 
-    async checkUser() {
-      const username = this.$route.query.username;
-      const a = decodeURIComponent(this.$route.query.jiami).replace(/\s/g, "+");
-      //   console.log(a);
-      const password = decrypt(a);
+    checkUser() {
+      const userName = this.$route.query.userName;
+      const mark = this.$route.query.mark;
       //判断传过来的username和mark是否为空值,如果是,则弹出身份验证不合法
-      if (username == null || password == null) {
+      if (userName == null || mark == null){
         ElMessage.error("身份验证不合法!");
       } else {
-        const {
-          data: res,
-          msg,
-          code,
-        } = await loginRequest({ username, password });
-        if (code == 0) {
-          store.commit("user/SET_TOKEN", res);
+        const params = {
+          publicKey: this.publickey,
+          data: this.encryptionByPublickey({
+            //   mark: "80a7916eef8f096d4d8b64f14b99c697",
+            userName,
+            mark,
+          }),
+        };
 
-          Login({ userId: res.userId, token: res.accessToken }).then((res) => {
-            if (res.code == 200) {
-              ElMessage.success("登录成功");
-              router.push("/");
-            }
-          });
-        } else {
-          ElMessage.error(msg);
-        }
+        loginRequest(params).then((res) => {
+          if (res.status !== 20000) {
+            ElMessage.error("单点登录错误:" + res.msg);
+          } else {
+            ElMessage.success("登录成功");
+            sessionStorage.setItem("ms_username", res.data.userName);
+            sessionStorage.setItem("ms_chinesename", res.data.chineseName);
+            sessionStorage.setItem("ms_id", res.data.id);
+            sessionStorage.setItem("token", res.token);
+            sessionStorage.setItem("identity", res.data.identity);
+            this.$router.replace("/");
+          }
+        });
+      }
+    },
 
-        // const params = {
-        //   publicKey: this.publickey,
-        //   data: this.encryptionByPublickey({
-        //     //   mark: "80a7916eef8f096d4d8b64f14b99c697",
-        //     userName,
-        //     mark,
-        //   }),
-        // };
+    // 利用jsencrypt.js进行RSA加密
+    encryptionByPublickey(formData) {
+      let key = sessionStorage.getItem("publicKey");
+      var encrypt = new JSEncrypt();
+      encrypt.setPublicKey(key);
 
-        // loginRequest(params).then((res) => {
-        //   if (res.status !== 20000) {
-        //     ElMessage.error("单点登录错误:" + res.msg);
-        //   } else {
-        //     ElMessage.success("登录成功");
-        //     sessionStorage.setItem("ms_username", res.data.userName);
-        //     sessionStorage.setItem("ms_chinesename", res.data.chineseName);
-        //     sessionStorage.setItem("ms_id", res.data.id);
-        //     sessionStorage.setItem("token", res.token);
-        //     sessionStorage.setItem("identity", res.data.identity);
-        //     this.$router.replace("/");
-        //   }
-        // });
-      }
+      var result = encrypt.encrypt(JSON.stringify(formData));
+      return result;
     },
   },
 };
-</script>
+</script> 

+ 1 - 1
src/permission.js

@@ -1,6 +1,6 @@
 import router from "./router";
 import { getCookie } from "@/utils/auth"; // getToken from cookie
-const whiteList = ["/login", "/logout",'/check']; // 不重定向白名单
+const whiteList = ["/login", "/logout"]; // 不重定向白名单
 import store from "@/store";
 // router.beforeEach((to, from, next) => {
 //   if (getCookie("authToken")) {

+ 2 - 2
src/router/index.js

@@ -378,13 +378,13 @@ const routes = [
     {
         icon: "iconfont iconxitongcaidan",
         path: "/check",
-        // isshow: "admin",
+        isshow: "admin",
         name: "check",
         meta: {
             title: "单点登录",
         },
         component: () =>
-            import ("@/pages/check/check.vue"),
+            import ("../pages/check/check.vue"),
     },
 ];
 const constantRoutes = [];

+ 15 - 4
src/store/index.js

@@ -71,10 +71,21 @@ export default createStore({
         },
 
         removeWarning(state, data) {
-            for (let i = 0; i < state.warningList.length; i++) {
-                if (`${state.warningList[i].id}${state.warningList[i].ts}` === `${data.id}${data.ts}`) {
-                    state.warningList.splice(i, 1);
-                    break;
+            if (Array.isArray(data)) {
+                data.forEach(ele => {
+                    for (let i = 0; i < state.warningList.length; i++) {
+                        if (`${ele.id}${ele.ts}` === `${data.id}${data.ts}`) {
+                            state.warningList.splice(i, 1);
+                            break;
+                        }
+                    }
+                })
+            } else {
+                for (let i = 0; i < state.warningList.length; i++) {
+                    if (`${state.warningList[i].id}${state.warningList[i].ts}` === `${data.id}${data.ts}`) {
+                        state.warningList.splice(i, 1);
+                        break;
+                    }
                 }
             }
         },

+ 1 - 1
src/store/modules/user.js

@@ -11,7 +11,7 @@ import {
 import { Login, loginRequest, getUserinfo, logout } from "@/api/api";
 const state = {
   authToken: getCookie("accessToken") || "", //
-  username: getCookie("userName") || "",
+  username: getCookie("username") || "",
   userId: getCookie("userId") || "",
   roles: [],
   permissions: [],

+ 1 - 1
src/utils/auth.js

@@ -4,7 +4,7 @@ const timeKey = "hrsaas-timestamp-key";
 // 设置时间戳的存储变量
 const TokenKey = "accessToken";
 const UserIdKey = "userId";
-const Username = "userName";
+const Username = "username";
 
 export function getCookie(name) {
   return Cookies.get(name);