Commit 5902886798cc51e7f32ca878d74efe4da2194ebb

Authored by miofly
Committed by GitHub
1 parent 7a1b6e74

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

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

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

* fix(type): 修复几个 ts 报错,和文件引用位置
src/router/constant.ts
@@ -4,7 +4,7 @@ export const PARENT_LAYOUT_NAME = 'ParentLayout'; @@ -4,7 +4,7 @@ export const PARENT_LAYOUT_NAME = 'ParentLayout';
4 4
5 export const PAGE_NOT_FOUND_NAME = 'PageNotFound'; 5 export const PAGE_NOT_FOUND_NAME = 'PageNotFound';
6 6
7 -export const EXCEPTION_COMPONENT = () => import('../views/sys/exception/Exception.vue'); 7 +export const EXCEPTION_COMPONENT = () => import('/@/views/sys/exception/Exception.vue');
8 8
9 /** 9 /**
10 * @description: default layout 10 * @description: default layout
src/utils/http/axios/Axios.ts
1 import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios'; 1 import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
2 -import type { RequestOptions, Result, UploadFileParams } from '../../../../types/axios'; 2 +import type { RequestOptions, Result, UploadFileParams } from '/#/axios';
3 import type { CreateAxiosOptions } from './axiosTransform'; 3 import type { CreateAxiosOptions } from './axiosTransform';
4 import axios from 'axios'; 4 import axios from 'axios';
5 import qs from 'qs'; 5 import qs from 'qs';
src/utils/http/axios/index.ts
@@ -140,7 +140,7 @@ const transform: AxiosTransform = { @@ -140,7 +140,7 @@ const transform: AxiosTransform = {
140 const token = getToken(); 140 const token = getToken();
141 if (token && (config as Recordable)?.requestOptions?.withToken !== false) { 141 if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
142 // jwt token 142 // jwt token
143 - config.headers.Authorization = options.authenticationScheme 143 + (config as Recordable).headers.Authorization = options.authenticationScheme
144 ? `${options.authenticationScheme} ${token}` 144 ? `${options.authenticationScheme} ${token}`
145 : token; 145 : token;
146 } 146 }
@@ -184,7 +184,7 @@ const transform: AxiosTransform = { @@ -184,7 +184,7 @@ const transform: AxiosTransform = {
184 return Promise.reject(error); 184 return Promise.reject(error);
185 } 185 }
186 } catch (error) { 186 } catch (error) {
187 - throw new Error(error); 187 + throw new Error(error as unknown as string);
188 } 188 }
189 189
190 checkStatus(error?.response?.status, msg, errorMessageMode); 190 checkStatus(error?.response?.status, msg, errorMessageMode);
src/views/sys/login/LoginForm.vue
@@ -82,7 +82,7 @@ @@ -82,7 +82,7 @@
82 </Form> 82 </Form>
83 </template> 83 </template>
84 <script lang="ts" setup> 84 <script lang="ts" setup>
85 - import { reactive, ref, toRaw, unref, computed } from 'vue'; 85 + import { reactive, ref, unref, computed } from 'vue';
86 86
87 import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue'; 87 import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
88 import { 88 import {
@@ -134,13 +134,11 @@ @@ -134,13 +134,11 @@
134 if (!data) return; 134 if (!data) return;
135 try { 135 try {
136 loading.value = true; 136 loading.value = true;
137 - const userInfo = await userStore.login(  
138 - {  
139 - password: data.password,  
140 - username: data.account,  
141 - mode: 'none', //不要默认的错误提示  
142 - },  
143 - ); 137 + const userInfo = await userStore.login({
  138 + password: data.password,
  139 + username: data.account,
  140 + mode: 'none', //不要默认的错误提示
  141 + });
144 if (userInfo) { 142 if (userInfo) {
145 notification.success({ 143 notification.success({
146 message: t('sys.login.loginSuccessTitle'), 144 message: t('sys.login.loginSuccessTitle'),
@@ -151,7 +149,7 @@ @@ -151,7 +149,7 @@
151 } catch (error) { 149 } catch (error) {
152 createErrorModal({ 150 createErrorModal({
153 title: t('sys.api.errorTip'), 151 title: t('sys.api.errorTip'),
154 - content: error.message || t('sys.api.networkExceptionMsg'), 152 + content: (error as unknown as Error).message || t('sys.api.networkExceptionMsg'),
155 getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body, 153 getContainer: () => document.body.querySelector(`.${prefixCls}`) || document.body,
156 }); 154 });
157 } finally { 155 } finally {