Commit 884180c615921d2a2a26544c212990fa2e3b1616

Authored by 黄 x
1 parent da5f4340

fix(front): 修改Promise.reject返回response.data,并去掉axios的属性catchFirst

... ... @@ -145,11 +145,8 @@ const transform: AxiosTransform = {
145 145 } catch (error: any) {
146 146 throw new Error(error);
147 147 }
148   -
149   - if (!config?.requestOptions?.catchFirst) {
150   - checkStatus(error?.response?.status, msg, errorMessageMode);
151   - }
152   - return Promise.reject(error);
  148 + checkStatus(error?.response?.status, msg, errorMessageMode);
  149 + return Promise.reject(response.data);
153 150 },
154 151 };
155 152
... ...
... ... @@ -60,16 +60,10 @@
60 60 </ACol>
61 61 </ARow>
62 62 </Form>
63   - <Modal v-model:visible="visible" :footer="null" centered>
64   - <template #title>
65   - <CloseCircleFilled class="modal-icon-error" /><span class="ml-2">错误提示</span>
66   - </template>
67   - <span class="ml-2" style="color: red">用户名或密码不正确</span>
68   - </Modal>
69 63 </template>
70 64 <script lang="ts" setup>
71 65 import { reactive, ref, unref, computed } from 'vue';
72   - import { Checkbox, Form, Input, Row, Col, Button, Modal } from 'ant-design-vue';
  66 + import { Checkbox, Form, Input, Row, Col, Button } from 'ant-design-vue';
73 67 import LoginFormTitle from './LoginFormTitle.vue';
74 68
75 69 import { useI18n } from '/@/hooks/web/useI18n';
... ... @@ -78,16 +72,15 @@
78 72 import { useUserStore } from '/@/store/modules/user';
79 73 import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin';
80 74 import { useDesign } from '/@/hooks/web/useDesign';
81   - import { getPlatForm } from '/@/api/oem/index';
82   - import { createLocalStorage } from '/@/utils/cache/index';
83   - import { CloseCircleFilled } from '@ant-design/icons-vue';
  75 + import { getPlatForm } from '/@/api/oem';
  76 + import { createLocalStorage } from '/@/utils/cache';
84 77
85 78 const ACol = Col;
86 79 const ARow = Row;
87 80 const FormItem = Form.Item;
88 81 const InputPassword = Input.Password;
89 82 const { t } = useI18n();
90   - const { notification, createErrorModal } = useMessage();
  83 + const { notification, createMessage } = useMessage();
91 84 const { prefixCls } = useDesign('login');
92 85 const userStore = useUserStore();
93 86
... ... @@ -116,34 +109,33 @@
116 109 } else {
117 110 storage.set('userInfo', null);
118 111 }
119   - try {
120   - loading.value = true;
121   - const userInfo = await userStore.login({
  112 + loading.value = true;
  113 + const userInfo = await userStore
  114 + .login({
122 115 password: data.password,
123 116 username: data.account,
124 117 mode: 'modal', //不要默认的错误提示
  118 + })
  119 + .catch((data) => {
  120 + createMessage.error(data.message);
125 121 });
126   - if (userInfo) {
127   - notification.success({
128   - message: t('sys.login.loginSuccessTitle'),
129   - description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realName}`,
130   - duration: 3,
131   - });
132   - const res = await getPlatForm();
133   - storage.set('platformInfo', res);
134   - userStore.setPlatInfo(res);
135   - // 设置icon
136   - let link = (document.querySelector("link[rel*='icon']") ||
137   - document.createElement('link')) as HTMLLinkElement;
138   - link.type = 'image/x-icon';
139   - link.rel = 'shortcut icon';
140   - link.href = res.icon ?? '/favicon.ico';
141   - document.getElementsByTagName('head')[0].appendChild(link);
142   - }
143   - } catch (error: any) {
144   - visible.value = true;
145   - } finally {
146   - loading.value = false;
  122 + if (userInfo) {
  123 + notification.success({
  124 + message: t('sys.login.loginSuccessTitle'),
  125 + description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realName}`,
  126 + duration: 3,
  127 + });
  128 + const res = await getPlatForm();
  129 + storage.set('platformInfo', res);
  130 + userStore.setPlatInfo(res);
  131 + // 设置icon
  132 + let link = (document.querySelector("link[rel*='icon']") ||
  133 + document.createElement('link')) as HTMLLinkElement;
  134 + link.type = 'image/x-icon';
  135 + link.rel = 'shortcut icon';
  136 + link.href = res.icon ?? '/favicon.ico';
  137 + document.getElementsByTagName('head')[0].appendChild(link);
147 138 }
  139 + loading.value = false;
148 140 }
149 141 </script>
... ...
... ... @@ -21,7 +21,6 @@ export interface RequestOptions {
21 21 ignoreCancelToken?: boolean;
22 22 // Whether to send token in header
23 23 withToken?: boolean;
24   - catchFirst?: boolean;
25 24 }
26 25
27 26 export interface Result<T = any> {
... ...