Explorar el Código

安全设置调整

zhangjie hace 2 años
padre
commit
baa9fd5065

+ 13 - 3
src/App.vue

@@ -35,6 +35,8 @@
 import timeMixin from "./mixins/timeMixin";
 import { QUESTION_API } from "@/constants/constants";
 import { questionSecurityCheckApi } from "./modules/question/api";
+import { USER_SIGNIN } from "./modules/portal/store/user";
+import { mapActions } from "vuex";
 
 export default {
   name: "App",
@@ -57,8 +59,8 @@ export default {
     };
   },
   computed: {
-    safeEnable() {
-      return this.$store.state.user.safeEnable;
+    user() {
+      return this.$store.state.user;
     },
   },
   watch: {
@@ -80,7 +82,12 @@ export default {
         this.onlineSignal();
 
         const safeRoutes = ["QuestionManage"];
-        if (this.safeEnable && val.name && safeRoutes.includes(val.name)) {
+        if (
+          this.user.safeEnable &&
+          !this.user.questionUnlock &&
+          val.name &&
+          safeRoutes.includes(val.name)
+        ) {
           this.modalIsShow = true;
         }
       },
@@ -90,6 +97,7 @@ export default {
     this.clearSetTs();
   },
   methods: {
+    ...mapActions([USER_SIGNIN]),
     async onlineSignal() {
       if (this.signalWaiting) return;
 
@@ -122,6 +130,8 @@ export default {
       ).catch(() => {});
       this.isSubmit = false;
       if (!res) return;
+
+      this.USER_SIGNIN(Object.assign({}, this.user, { questionUnlock: true }));
       this.modalForm.safePassword = "";
       this.modalIsShow = false;
     },

+ 1 - 0
src/modules/portal/views/Login.vue

@@ -155,6 +155,7 @@ export default {
         .post(url, this.loginInfo)
         .then((response) => {
           var user = response.data;
+          user.questionUnlock = false;
           this.USER_SIGNIN(user);
           this.$router.replace({ path: "/questions/tips" });
           this.$notify({

+ 1 - 78
src/modules/question/components/QuestionSafetySetDialog.vue

@@ -10,37 +10,11 @@
     append-to-body
     @open="visibleChange"
   >
-    <el-form ref="modalFormComp" :model="modalForm" :rules="rules">
+    <el-form ref="modalFormComp">
       <el-form-item label="加密“题库”,“卷库”">
         <el-switch v-model="modalForm.safeEnable"></el-switch>
         <p class="tips-info">开启后,进入题库、卷库模块,需要进行密码验证!</p>
       </el-form-item>
-      <el-form-item
-        v-if="modalForm.safeEnable"
-        label="设置密码"
-        prop="safePassword"
-      >
-        <el-input
-          v-model="modalForm.safePassword"
-          type="password"
-          class="dialog-input-width"
-          auto-complete="off"
-          placeholder="请输入6位以上数字和字母组合"
-        />
-      </el-form-item>
-      <el-form-item
-        v-if="modalForm.safeEnable"
-        label="确认密码"
-        prop="checkSafePassword"
-      >
-        <el-input
-          v-model="modalForm.checkSafePassword"
-          type="password"
-          class="dialog-input-width"
-          auto-complete="off"
-          placeholder="请输入6位以上数字和字母组合"
-        />
-      </el-form-item>
     </el-form>
 
     <div slot="footer">
@@ -60,55 +34,11 @@ import { USER_SIGNIN } from "../../../modules/portal/store/user";
 export default {
   name: "QuestionSafetySetDialog",
   data() {
-    var validatePassWeakPass = (rule, value, callback) => {
-      if (this.modalForm.checkSafePassword !== "") {
-        this.$refs.modalFormComp.validateField("checkSafePassword");
-      }
-      callback();
-    };
-    var validatePassWeakPass2 = (rule, value, callback) => {
-      if (value !== this.modalForm.safePassword) {
-        callback(new Error("两次输入密码不一致!"));
-      } else {
-        callback();
-      }
-    };
-    const pwdRule = [
-      {
-        validator: (rule, value, callback) => {
-          if (value && value.match(/[0-9]+/) && value.match(/[a-zA-Z]+/)) {
-            callback();
-          } else {
-            callback(new Error("请输入数字和字母组合"));
-          }
-        },
-        trigger: "change",
-      },
-      {
-        required: true,
-        min: 6,
-        max: 16,
-        message: "密码只能6-16个字符",
-        trigger: "change",
-      },
-    ];
     return {
       modalIsShow: false,
       isSubmit: false,
       modalForm: {
         safeEnable: false,
-        safePassword: "",
-        checkSafePassword: "",
-      },
-      rules: {
-        safePassword: [
-          { validator: validatePassWeakPass, trigger: "blur" },
-          ...pwdRule,
-        ],
-        checkSafePassword: [
-          { validator: validatePassWeakPass2, trigger: "blur" },
-          ...pwdRule,
-        ],
       },
     };
   },
@@ -117,8 +47,6 @@ export default {
     visibleChange() {
       this.modalForm = {
         safeEnable: this.$store.state.user.safeEnable,
-        safePassword: "",
-        checkSafePassword: "",
       };
     },
     cancel() {
@@ -128,11 +56,6 @@ export default {
       this.modalIsShow = true;
     },
     async confirm() {
-      if (this.modalForm.safeEnable) {
-        const valid = await this.$refs.modalFormComp.validate().catch(() => {});
-        if (!valid) return;
-      }
-
       if (this.isSubmit) return;
       this.isSubmit = true;
       const data = await questionSecuritySettingsApi(this.modalForm).catch(