Browse Source

sis系统跳转本系统免登录及系统名称修改

baiyanting 1 year atrás
parent
commit
31e28a6b52

+ 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">

+ 2 - 9
src/pages/Login.vue

@@ -6,17 +6,10 @@
       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">
-          <!-- Equipment Hidden Hazard Awareness System -->
-          Intelligent Alarms and Early Warnings System
+          Integrated alarm system
         </div>
       </div>
       <div class="ms-login">

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

@@ -1,13 +1,15 @@
 <template>
   <div>
-    <el-upload></el-upload>
+    <!-- <el-upload></el-upload> -->
   </div>
 </template>
 
 <script>
-import { JSEncrypt } from "jsencrypt";
-import { loginRequest, getPublickey } from "/@/api/api.js";
+import { decrypt } from "@/utils/jsencrypt.js";
+import { loginRequest, Login } 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 {
@@ -17,57 +19,67 @@ export default {
     };
   },
   created() {
-    this.getKey();
+    this.checkUser();
   },
   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();
+    // },
 
-    checkUser() {
-      const userName = this.$route.query.userName;
-      const mark = this.$route.query.mark;
+    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);
       //判断传过来的username和mark是否为空值,如果是,则弹出身份验证不合法
-      if (userName == null || mark == null){
+      if (username == null || password == null) {
         ElMessage.error("身份验证不合法!");
       } else {
-        const params = {
-          publicKey: this.publickey,
-          data: this.encryptionByPublickey({
-            //   mark: "80a7916eef8f096d4d8b64f14b99c697",
-            userName,
-            mark,
-          }),
-        };
+        const {
+          data: res,
+          msg,
+          code,
+        } = await loginRequest({ username, password });
+        if (code == 0) {
+          store.commit("user/SET_TOKEN", res);
 
-        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("/");
-          }
-        });
-      }
-    },
+          Login({ userId: res.userId, token: res.accessToken }).then((res) => {
+            if (res.code == 200) {
+              ElMessage.success("登录成功");
+              router.push("/");
+            }
+          });
+        } else {
+          ElMessage.error(msg);
+        }
 
-    // 利用jsencrypt.js进行RSA加密
-    encryptionByPublickey(formData) {
-      let key = sessionStorage.getItem("publicKey");
-      var encrypt = new JSEncrypt();
-      encrypt.setPublicKey(key);
+        // const params = {
+        //   publicKey: this.publickey,
+        //   data: this.encryptionByPublickey({
+        //     //   mark: "80a7916eef8f096d4d8b64f14b99c697",
+        //     userName,
+        //     mark,
+        //   }),
+        // };
 
-      var result = encrypt.encrypt(JSON.stringify(formData));
-      return result;
+        // 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("/");
+        //   }
+        // });
+      }
     },
   },
 };
-</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"]; // 不重定向白名单
+const whiteList = ["/login", "/logout",'/check']; // 不重定向白名单
 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 = [];

+ 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);

+ 29 - 0
src/utils/jsencrypt.js

@@ -0,0 +1,29 @@
+import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
+
+// 密钥对生成 http://web.chacuo.net/netrsakeypair
+
+const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
+  'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
+
+const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
+  '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
+  'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
+  'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
+  'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
+  'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
+  'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
+  'UP8iWi1Qw0Y='
+
+// 加密
+export function encrypt(txt) {
+  const encryptor = new JSEncrypt()
+  encryptor.setPublicKey(publicKey) // 设置公钥
+  return encryptor.encrypt(txt) // 对数据进行加密
+}
+
+// 解密
+export function decrypt(txt) {
+  const encryptor = new JSEncrypt()
+  encryptor.setPrivateKey(privateKey) // 设置私钥
+  return encryptor.decrypt(txt) // 对数据进行解密
+}