Showing
2 changed files
with
16 additions
and
3 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-05-18 22:56:08 | 2 | * @Date: 2022-05-18 22:56:08 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-07-27 07:44:07 | 4 | + * @LastEditTime: 2024-08-12 11:52:47 |
| 5 | * @FilePath: /data-table/src/api/fn.js | 5 | * @FilePath: /data-table/src/api/fn.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -21,7 +21,7 @@ export const fn = (api) => { | ... | @@ -21,7 +21,7 @@ export const fn = (api) => { |
| 21 | return res.data || true; | 21 | return res.data || true; |
| 22 | } else { | 22 | } else { |
| 23 | // tslint:disable-next-line: no-console | 23 | // tslint:disable-next-line: no-console |
| 24 | - // if (!res.data.show) return false; | 24 | + if (!res.data.show) return false; |
| 25 | showFailToast({ | 25 | showFailToast({ |
| 26 | message: res.data.msg, | 26 | message: res.data.msg, |
| 27 | duration: 5000, | 27 | duration: 5000, | ... | ... |
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-28 10:17:40 | 3 | * @Date: 2022-05-28 10:17:40 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2022-12-01 16:33:51 | 5 | + * @LastEditTime: 2024-08-12 12:37:11 |
| 6 | * @FilePath: /data-table/src/utils/axios.js | 6 | * @FilePath: /data-table/src/utils/axios.js |
| 7 | * @Description: | 7 | * @Description: |
| 8 | */ | 8 | */ |
| ... | @@ -11,6 +11,7 @@ import router from '@/router'; | ... | @@ -11,6 +11,7 @@ import router from '@/router'; |
| 11 | import qs from 'Qs' | 11 | import qs from 'Qs' |
| 12 | import { strExist } from '@/utils/tools' | 12 | import { strExist } from '@/utils/tools' |
| 13 | // import { parseQueryString } from '@/utils/tools' | 13 | // import { parseQueryString } from '@/utils/tools' |
| 14 | +import { showToast } from 'vant'; | ||
| 14 | 15 | ||
| 15 | axios.defaults.params = { | 16 | axios.defaults.params = { |
| 16 | f: 'custom_form', | 17 | f: 'custom_form', |
| ... | @@ -43,6 +44,18 @@ axios.interceptors.request.use( | ... | @@ -43,6 +44,18 @@ axios.interceptors.request.use( |
| 43 | */ | 44 | */ |
| 44 | axios.interceptors.response.use( | 45 | axios.interceptors.response.use( |
| 45 | response => { | 46 | response => { |
| 47 | + if (response.data.code === 402) { // 未授权状态 | ||
| 48 | + // 特殊标识-带此标识报错不显示 | ||
| 49 | + response.data.show = false; | ||
| 50 | + // | ||
| 51 | + showToast({ | ||
| 52 | + message: '登录失效!将跳转到登录页面', | ||
| 53 | + duration: 1500, | ||
| 54 | + onClose: () => { | ||
| 55 | + window.location.href = location.origin + '/admin/'; | ||
| 56 | + } | ||
| 57 | + }) | ||
| 58 | + } | ||
| 46 | return response; | 59 | return response; |
| 47 | }, | 60 | }, |
| 48 | error => { | 61 | error => { | ... | ... |
-
Please register or login to post a comment