Commit 54f99a8b489e87a790f9653d4fbd0d41ed3ace36
1 parent
0831d929
ts类型补充
Showing
8 changed files
with
25 additions
and
19 deletions
src/@type/module/basic.d.ts
0 → 100644
src/@type/vue-router/index.d.ts renamed to src/@type/module/index.d.ts
src/api/request.ts
| ... | ... | @@ -26,7 +26,6 @@ instance.interceptors.request.use( |
| 26 | 26 | ) |
| 27 | 27 | |
| 28 | 28 | instance.interceptors.response.use( |
| 29 | - // @ts-ignore | |
| 30 | 29 | response => { |
| 31 | 30 | if (response) { |
| 32 | 31 | if (response?.data?.errorCode === 0) { |
| ... | ... | @@ -49,6 +48,9 @@ instance.interceptors.response.use( |
| 49 | 48 | ElMessage.error(response?.data?.errorMessage || '操作失败'); |
| 50 | 49 | break |
| 51 | 50 | } |
| 51 | + // TIP declare axios 的 module reject就不报ts类型错误 | |
| 52 | + // declare位置 src/@type/module/index.d.ts | |
| 53 | + // 原因还没研究明白呢 | |
| 52 | 54 | return Promise.reject() |
| 53 | 55 | } |
| 54 | 56 | } | ... | ... |
src/utils/tool.ts
| 1 | +import type { EnumArrayItem } from "@/@type/module/basic" | |
| 2 | + | |
| 1 | 3 | /** |
| 2 | 4 | * 页面回退 |
| 3 | 5 | */ |
| ... | ... | @@ -143,11 +145,7 @@ export function formatTime(time, option) { |
| 143 | 145 | * @param {Array.EnumData} groupData |
| 144 | 146 | * @returns {string} |
| 145 | 147 | */ |
| 146 | -interface EnumData { | |
| 147 | - value: number | string, | |
| 148 | - label: string | |
| 149 | -} | |
| 150 | -export function globalFilters (value: number, groupData: EnumData[]) { | |
| 148 | +export function globalFilters (value: number, groupData: EnumArrayItem[]) { | |
| 151 | 149 | if(groupData.length && (~~value === 0 || !!value)) { |
| 152 | 150 | return groupData.find(item => ~~item.value === ~~value)['label'] |
| 153 | 151 | } else { | ... | ... |
src/views/column/config.ts
src/views/column/index.vue
| ... | ... | @@ -4,7 +4,7 @@ import { columnList, columnStatus, columnSort } from "@/api/property/column"; |
| 4 | 4 | import Pagination from "@/components/Pagination/index.vue"; |
| 5 | 5 | import { ElMessageBox } from "element-plus"; |
| 6 | 6 | import { types } from "./config"; |
| 7 | -import { globalFilters } from "@/utils/tool"; | |
| 7 | +import { globalFilters, enumArray } from "@/utils/tool"; | |
| 8 | 8 | interface Form { |
| 9 | 9 | page: number; |
| 10 | 10 | pageSize: number; |
| ... | ... | @@ -32,6 +32,8 @@ let data: Data = reactive({ |
| 32 | 32 | }, |
| 33 | 33 | }, |
| 34 | 34 | }); |
| 35 | +// let testData = new enumArray() | |
| 36 | +// console.log(testData) | |
| 35 | 37 | /** |
| 36 | 38 | * 列表 |
| 37 | 39 | */ | ... | ... |
src/views/event/category/index.vue
src/views/repair/config.ts