Ver Fonte

config去除默认密码,修改密码加密js,更改默认登录逻辑

wdq há 3 semanas atrás
pai
commit
d73f338bf7
3 ficheiros alterados com 72 adições e 50 exclusões
  1. 1 2
      public/static/config/config.js
  2. 43 48
      src/App.vue
  3. 28 0
      src/utils/encrypt‌.js

+ 1 - 2
public/static/config/config.js

@@ -1,8 +1,7 @@
 let systemConfig = {
     /* 通用全局变量 */
     defaultAccount: {
-        userName: "user002",
-        password: "Yysz@1234002"
+        username: "user002",
     },
     touristUserId: "5",//默认游客id
     baseServicerPath: "/oneMap",

+ 43 - 48
src/App.vue

@@ -2,7 +2,8 @@
   <router-view />
 </template>
 <script>
-import api from "@/api/common";
+// import api from "@/api/common";
+import encrypt‌ from "@/utils/encrypt‌";
 export default {
   name: "App",
   data() {
@@ -23,57 +24,51 @@ export default {
     // });
     let that = this;
     // 默认登录
-    api
-      .login({
-        userName: systemConfig.defaultAccount.userName,
-        password: AesEncryptUtil.getPassword(),
-        clientId: "1",
-      })
-      .then((result) => {
-        if (result.code == 200) {
-          that.$store.commit("setUserInfo", result.content);
-          that.$store.commit("setToken", result.message);
-          that.$store.commit("setUserState", true);
-          // 登录成功之后要批量加载一下DMS的字典,后续全局可调用
-          that.$store.state.DMSTypes.forEach((item) => {
-            api
-              .getDmsTypes({
-                cName: item,
-                type: 0,
-              })
-              .then((result2) => {
-                if (result2.code == 200) {
-                  // 遍历result2.content,将每个元素的index作为key,name作为value,存储到DmsTypesMap中
-                  let dmsTypesMap = {};
-                  result2.content.forEach((element) => {
-                    dmsTypesMap[element.index] = element.name;
-                  });
-                  that.$store.commit("setDmsTypesMap", {
-                    name: item,
-                    list: dmsTypesMap,
-                  });
-                } else {
-                  that.$message({
-                    type: "error",
-                    message: result2.content,
-                  });
-                }
-              })
-              .catch((err) => {
-                console.log(err);
+    encrypt‌().then((result) => {
+      if (result.code == 200) {
+        that.$store.commit("setUserInfo", result.content);
+        that.$store.commit("setToken", result.message);
+        that.$store.commit("setUserState", true);
+        // 登录成功之后要批量加载一下DMS的字典,后续全局可调用
+        that.$store.state.DMSTypes.forEach((item) => {
+          api
+            .getDmsTypes({
+              cName: item,
+              type: 0,
+            })
+            .then((result2) => {
+              if (result2.code == 200) {
+                // 遍历result2.content,将每个元素的index作为key,name作为value,存储到DmsTypesMap中
+                let dmsTypesMap = {};
+                result2.content.forEach((element) => {
+                  dmsTypesMap[element.index] = element.name;
+                });
+                that.$store.commit("setDmsTypesMap", {
+                  name: item,
+                  list: dmsTypesMap,
+                });
+              } else {
                 that.$message({
                   type: "error",
-                  message: "服务器忙碌,请稍后重试!",
+                  message: result2.content,
                 });
+              }
+            })
+            .catch((err) => {
+              console.log(err);
+              that.$message({
+                type: "error",
+                message: "服务器忙碌,请稍后重试!",
               });
-          });
-        } else {
-          that.$message({
-            type: "error",
-            message: result.content,
-          });
-        }
-      })
+            });
+        });
+      } else {
+        that.$message({
+          type: "error",
+          message: result.content,
+        });
+      }
+    })
       .catch((err) => {
         that.$message({
           type: "error",

+ 28 - 0
src/utils/encrypt‌.js

@@ -0,0 +1,28 @@
+import api from "../api/common";
+export default function encrypt(loginObj) {
+    if (loginObj == undefined) {
+        return api
+            .login({
+                userName: systemConfig.defaultAccount.username,
+                password: AesEncryptUtil.getPassword(),
+                clientId: "1",
+            })
+    } else {
+        if (loginObj.username != undefined || loginObj.username != "" || loginObj.username != null) {
+            return new Promise((resolve, reject) => {
+                reject("用户名为空")
+            });
+        }
+        if (loginObj.password != undefined || loginObj.password != "" || loginObj.password != null) {
+            return new Promise((resolve, reject) => {
+                reject("密码为空")
+            });
+        }
+        return api
+            .login({
+                userName: loginObj.username,
+                password: AesEncryptUtil.getPassword(loginObj.password),
+                clientId: "1",
+            })
+    }
+}