Browse Source

feat(api): login 开出

gemercheung 3 năm trước cách đây
mục cha
commit
df6c8da091
4 tập tin đã thay đổi với 23 bổ sung20 xóa
  1. 1 1
      package.json
  2. 1 0
      src/api/sys/model/userModel.ts
  3. 1 1
      src/api/sys/user.ts
  4. 20 18
      src/views/sys/login/LoginForm.vue

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
   "scripts": {
     "bootstrap": "pnpm install",
     "serve": "npm run dev",
-    "dev": "vite",
+    "dev": "vite --debug",
     "build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts",
     "build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts",
     "build:no-cache": "pnpm clean:cache && npm run build",

+ 1 - 0
src/api/sys/model/userModel.ts

@@ -4,6 +4,7 @@
 export interface LoginParams {
   username: string;
   password: string;
+  captcha: string;
 }
 
 export interface RoleInfo {

+ 1 - 1
src/api/sys/user.ts

@@ -17,7 +17,7 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
   const form = new FormData();
   form.append('username', params.username);
   form.append('password', params.password);
-  form.append('captcha', '11111');
+  form.append('captcha', params.captcha);
   return defHttp.post<LoginResultModel>(
     {
       url: Api.Login,

+ 20 - 18
src/views/sys/login/LoginForm.vue

@@ -25,7 +25,7 @@
       />
     </FormItem>
 
-    <!-- <ARow class="enter-x">
+    <ARow class="enter-x">
       <ACol :span="12">
         <FormItem name="captcha">
           <Input
@@ -39,16 +39,16 @@
       <ACol :span="12" :style="{ 'text-align': 'right' }">
         <img class="captcha-img" :src="`http://192.168.0.47:8190/captcha.jpg?t=${Date.now()}`" />
       </ACol>
-    </ARow> -->
+    </ARow>
 
-    <FormItem name="drag" class="enter-x" :style="{ 'text-align': 'right' }">
+    <!-- <FormItem name="drag" class="enter-x" :style="{ 'text-align': 'right' }">
       <BasicDragVerify
         ref="el3"
         @success="handleSuccess"
         text="拖动以进行校验"
         successText="校验成功"
       />
-    </FormItem>
+    </FormItem> -->
 
     <ARow class="enter-x">
       <ACol :span="12">
@@ -120,7 +120,7 @@
   // } from '@ant-design/icons-vue';
   import LoginFormTitle from './LoginFormTitle.vue';
 
-  import { BasicDragVerify } from '/@/components/Verify/index';
+  // import { BasicDragVerify } from '/@/components/Verify/index';
 
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useMessage } from '/@/hooks/web/useMessage';
@@ -145,12 +145,13 @@
   const formRef = ref();
   const loading = ref(false);
   const rememberMe = ref(false);
-  const isDragValidate = ref(false);
+  // const isDragValidate = ref(false);
 
   const formData = reactive({
     account: '17324327132',
     // password: 'zfb123456',
     password: 'USFf52nBZiMTIzNDU2WAJ7GAofemSXnYdUok',
+    captcha: '',
   });
 
   const { validForm } = useFormValid(formRef);
@@ -159,27 +160,28 @@
 
   const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN);
 
-  function handleSuccess() {
-    // console.log('11');
-    isDragValidate.value = true;
-  }
+  // function handleSuccess() {
+  //   // console.log('11');
+  //   isDragValidate.value = true;
+  // }
 
   async function handleLogin() {
     const data = await validForm();
     if (!data) return;
-    if (!isDragValidate.value) {
-      notification.info({
-        message: t('sys.login.loginDragValidate'),
-        description: `${t('sys.login.loginAgain')}`,
-        duration: 3,
-      });
-      return;
-    }
+    // if (!isDragValidate.value) {
+    //   notification.info({
+    //     message: t('sys.login.loginDragValidate'),
+    //     description: `${t('sys.login.loginAgain')}`,
+    //     duration: 3,
+    //   });
+    //   return;
+    // }
     try {
       loading.value = true;
       const userInfo = await userStore.login({
         password: data.password,
         username: data.account,
+        captcha: data.captcha,
         mode: 'none', //不要默认的错误提示
       });