Browse Source

修改密码保存问题

lex 1 year ago
parent
commit
6361f4ccdd
1 changed files with 15 additions and 8 deletions
  1. 15 8
      src/views/login/index.vue

+ 15 - 8
src/views/login/index.vue

@@ -59,7 +59,7 @@
             <n-form-item class="default-color">
               <div class="flex justify-between">
                 <div class="flex-initial">
-                  <n-checkbox v-model:checked="autoLogin">记住密码</n-checkbox>
+                  <n-checkbox v-model:checked="formInline.isCaptcha">记住密码</n-checkbox>
                 </div>
                 <!-- <div class="flex-initial order-last">
                 <a href="javascript:">忘记密码</a>
@@ -125,8 +125,14 @@ let formInline = reactive({
 })
 const formInlineHistory = storage.get('userInfo')
 if (formInlineHistory) {
-  console.log(formInlineHistory)
-  formInline = reactive({ ...JSON.parse(formInlineHistory) })
+  const tempForm = JSON.parse(formInlineHistory)
+  if (tempForm.isCaptcha) {
+    formInline.username = tempForm.username
+    formInline.password = tempForm.password
+  } else {
+    formInline.username = tempForm.username
+  }
+  // formInline = reactive({ ...JSON.parse(formInlineHistory) })
 }
 const rules = {
   username: { required: true, message: '请输入用户名', trigger: 'blur' },
@@ -161,11 +167,12 @@ const handleSubmit = (e: any) => {
         message.destroyAll()
         if (some.code == ResultEnum.SUCCESS) {
           //  判断是否勾选自动登录
-          if (autoLogin.value) {
-            storage.set('userInfo', JSON.stringify(formInline))
-          } else {
-            storage.remove('userInfo')
-          }
+          // if (autoLogin.value) {
+          //   storage.set('userInfo', JSON.stringify(formInline))
+          // } else {
+          //   storage.remove('userInfo')
+          // }
+          storage.set('userInfo', JSON.stringify(formInline))
 
           // route.query?.redirect ||
           tabsViewStore.closeAllTabs()