mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-10-31 22:57:15 +08:00 
			
		
		
		
	refactor: 更换 ESLint 配置为 @antfu/eslint-config
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| import { ref } from 'vue' | ||||
| import { listDeptTree } from '@/apis' | ||||
| import type { TreeNodeData } from '@arco-design/web-vue' | ||||
| import { listDeptTree } from '@/apis' | ||||
|  | ||||
| /** 部门模块 */ | ||||
| export function useDept(options?: { onSuccess?: () => void }) { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import { reactive, computed, ref, type Ref } from 'vue' | ||||
| import { type Ref, computed, reactive, ref } from 'vue' | ||||
| import { useRoute, useRouter } from 'vue-router' | ||||
| import { Modal, Message, type FormInstance } from '@arco-design/web-vue' | ||||
| import { type FormInstance, Message, Modal } from '@arco-design/web-vue' | ||||
| import { isEqual } from 'lodash-es' | ||||
|  | ||||
| type Option<T> = { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import { ref } from 'vue' | ||||
| import { listMenuTree } from '@/apis' | ||||
| import type { TreeNodeData } from '@arco-design/web-vue' | ||||
| import { listMenuTree } from '@/apis' | ||||
|  | ||||
| /** 菜单模块 */ | ||||
| export function useMenu(options?: { onSuccess?: () => void }) { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { computed, type ComputedRef } from 'vue' | ||||
| import { type ComputedRef, computed } from 'vue' | ||||
| import { useBreakpoints } from '@vueuse/core' | ||||
| import type { ColProps } from '@arco-design/web-vue' | ||||
|  | ||||
|   | ||||
| @@ -16,7 +16,7 @@ export function useBreakpointIndex(callback: (v: number) => void, breakpointObj? | ||||
|     () => breakpoint.value, | ||||
|     (v) => { | ||||
|       const def = { xs: 0, sm: 0, md: 0, lg: 1, xl: 1, xxl: 2 } | ||||
|       const obj = breakpointObj ? breakpointObj : def | ||||
|       const obj = breakpointObj || def | ||||
|       callback(obj[v as keyof typeof obj]) | ||||
|     }, | ||||
|     { immediate: true } | ||||
|   | ||||
| @@ -2,13 +2,13 @@ import { Message, Notification } from '@arco-design/web-vue' | ||||
| /** | ||||
|  * @description 接收数据流生成 blob,创建链接,下载文件 | ||||
|  * @param {Function} api 导出表格的api方法 (必传) | ||||
|  * @param {String} tempName 导出的文件名 (必传) | ||||
|  * @param {Object} params 导出的参数 (默认{}) | ||||
|  * @param {Boolean} isNotify 是否有导出消息提示 (默认为 true) | ||||
|  * @param {String} fileType 导出的文件格式 (默认为.xlsx) | ||||
|  * */ | ||||
|  * @param {string} tempName 导出的文件名 (必传) | ||||
|  * @param {object} params 导出的参数 (默认{}) | ||||
|  * @param {boolean} isNotify 是否有导出消息提示 (默认为 true) | ||||
|  * @param {string} fileType 导出的文件格式 (默认为.xlsx) | ||||
|  */ | ||||
| interface NavigatorWithMsSaveOrOpenBlob extends Navigator { | ||||
|   msSaveOrOpenBlob(blob: Blob, fileName: string): void | ||||
|   msSaveOrOpenBlob: (blob: Blob, fileName: string) => void | ||||
| } | ||||
| export const useDownload = async (api: () => Promise<any>, isNotify = true, tempName = '', fileType = '.xlsx') => { | ||||
|   try { | ||||
| @@ -16,7 +16,7 @@ export const useDownload = async (api: () => Promise<any>, isNotify = true, temp | ||||
|     if (res.headers['content-disposition']) { | ||||
|       tempName = decodeURI(res.headers['content-disposition'].split(';')[1].split('=')[1]) | ||||
|     } else { | ||||
|       tempName = tempName ? tempName : new Date().getTime() + fileType | ||||
|       tempName = tempName || new Date().getTime() + fileType | ||||
|     } | ||||
|     if (isNotify && !res?.code) { | ||||
|       Notification.warning({ | ||||
| @@ -24,7 +24,7 @@ export const useDownload = async (api: () => Promise<any>, isNotify = true, temp | ||||
|         content: '如果数据庞大会导致下载缓慢哦,请您耐心等待!' | ||||
|       }) | ||||
|     } | ||||
|     if (res.status !== 200 || res.data === null || !(res.data instanceof Blob)) { | ||||
|     if (res.status !== 200 || res.data == null || !(res.data instanceof Blob)) { | ||||
|       Message.error('导出失败,请稍后再试!') | ||||
|       return | ||||
|     } | ||||
| @@ -44,6 +44,6 @@ export const useDownload = async (api: () => Promise<any>, isNotify = true, temp | ||||
|     document.body.removeChild(exportFile) | ||||
|     window.URL.revokeObjectURL(blobUrl) | ||||
|   } catch (error) { | ||||
|     console.log(error) | ||||
|     // console.log(error) | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { ref, type UnwrapRef } from 'vue' | ||||
| import { type UnwrapRef, ref } from 'vue' | ||||
| import type { AxiosResponse } from 'axios' | ||||
| import { useLoading } from '@/hooks' | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import type { TableInstance, TableData } from '@arco-design/web-vue' | ||||
| import { Modal, Message } from '@arco-design/web-vue' | ||||
| import type { TableData, TableInstance } from '@arco-design/web-vue' | ||||
| import { Message, Modal } from '@arco-design/web-vue' | ||||
| import { usePagination } from '@/hooks' | ||||
|  | ||||
| interface Options<T> { | ||||
| @@ -9,11 +9,12 @@ interface Options<T> { | ||||
|   rowKey?: keyof T | ||||
| } | ||||
|  | ||||
| type PaginationParams = { page: number; size: number } | ||||
| type PaginationParams = { page: number, size: number } | ||||
| type Api<T> = (params: PaginationParams) => Promise<ApiRes<PageRes<T[]>>> | ||||
|  | ||||
| export function useTable<T>(api: Api<T>, options?: Options<T>) { | ||||
|   const { formatResult, onSuccess, immediate, rowKey } = options || {} | ||||
|   // eslint-disable-next-line ts/no-use-before-define | ||||
|   const { pagination, setTotal } = usePagination(() => getTableData()) | ||||
|   const loading = ref(false) | ||||
|   const tableData = ref<T[]>([]) | ||||
| @@ -34,12 +35,6 @@ export function useTable<T>(api: Api<T>, options?: Options<T>) { | ||||
|   const isImmediate = immediate ?? true | ||||
|   isImmediate && getTableData() | ||||
|  | ||||
|   // 查询 | ||||
|   const search = () => { | ||||
|     selectedKeys.value = [] | ||||
|     pagination.onChange(1) | ||||
|   } | ||||
|  | ||||
|   // 多选 | ||||
|   const selectedKeys = ref<(string | number)[]>([]) | ||||
|   const select: TableInstance['onSelect'] = (rowKeys) => { | ||||
| @@ -53,10 +48,16 @@ export function useTable<T>(api: Api<T>, options?: Options<T>) { | ||||
|     selectedKeys.value = checked ? arr.map((i) => i[key as string]) : [] | ||||
|   } | ||||
|  | ||||
|   // 查询 | ||||
|   const search = () => { | ||||
|     selectedKeys.value = [] | ||||
|     pagination.onChange(1) | ||||
|   } | ||||
|  | ||||
|   // 删除 | ||||
|   const handleDelete = async <T>( | ||||
|     deleteApi: () => Promise<ApiRes<T>>, | ||||
|     options?: { title?: string; content?: string; successTip?: string; showModal?: boolean } | ||||
|     options?: { title?: string, content?: string, successTip?: string, showModal?: boolean } | ||||
|   ): Promise<boolean | undefined> => { | ||||
|     const onDelete = async () => { | ||||
|       try { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user