Explorar el Código

fix(type): 修复几个 ts 报错,和文件引用位置 (#1283)

* fix(type): 删除多余的类型定义

* fix(login): 删除登录时的 toRaw 包裹参数

* fix(type): 修复几个 ts 报错,和文件引用位置
miofly hace 3 años
padre
commit
5902886798

+ 1 - 1
src/router/constant.ts

@@ -4,7 +4,7 @@ export const PARENT_LAYOUT_NAME = 'ParentLayout';
 
 export const PAGE_NOT_FOUND_NAME = 'PageNotFound';
 
-export const EXCEPTION_COMPONENT = () => import('../views/sys/exception/Exception.vue');
+export const EXCEPTION_COMPONENT = () => import('/@/views/sys/exception/Exception.vue');
 
 /**
  * @description: default layout

+ 1 - 1
src/utils/http/axios/Axios.ts

@@ -1,5 +1,5 @@
 import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
-import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios';
+import type { RequestOptions, Result, UploadFileParams } from '/#/axios';
 import type { CreateAxiosOptions } from './axiosTransform';
 import axios from 'axios';
 import qs from 'qs';

+ 2 - 2
src/utils/http/axios/index.ts

@@ -140,7 +140,7 @@ const transform: AxiosTransform = {
     const token = getToken();
     if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
       // jwt token
-      config.headers.Authorization = options.authenticationScheme
+      (config as Recordable).headers.Authorization = options.authenticationScheme
         ? `${options.authenticationScheme} ${token}`
         : token;
     }
@@ -184,7 +184,7 @@ const transform: AxiosTransform = {
         return Promise.reject(error);
       }
     } catch (error) {
-      throw new Error(error);
+      throw new Error(error as unknown as string);
     }
 
     checkStatus(error?.response?.status, msg, errorMessageMode);

+ 7 - 9
src/views/sys/login/LoginForm.vue

@@ -82,7 +82,7 @@
   </Form>
 </template>
 <script lang="ts" setup>
-  import { reactive, ref, toRaw, unref, computed } from 'vue';
+  import { reactive, ref, unref, computed } from 'vue';
 
   import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
   import {
@@ -134,13 +134,11 @@
     if (!data) return;
     try {
       loading.value = true;
-      const userInfo = await userStore.login(
-        {
-          password: data.password,
-          username: data.account,
-          mode: 'none', //不要默认的错误提示
-        },
-      );
+      const userInfo = await userStore.login({
+        password: data.password,
+        username: data.account,
+        mode: 'none', //不要默认的错误提示
+      });
       if (userInfo) {
         notification.success({
           message: t('sys.login.loginSuccessTitle'),
@@ -151,7 +149,7 @@
     } catch (error) {
       createErrorModal({
         title: t('sys.api.errorTip'),
-        content: error.message || t('sys.api.networkExceptionMsg'),
+        content: (error as unknown as Error).message || t('sys.api.networkExceptionMsg'),
         getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
       });
     } finally {