refactor(types): 更新类型定义以提高类型安全性

master
LiuJiaNan 2026-05-08 10:37:56 +08:00
parent ad7d43096a
commit 315828f90b
3 changed files with 15 additions and 15 deletions

View File

@ -13,7 +13,7 @@ export interface DeleteFileOptions {
single?: boolean;
}
export type DeleteFileFunction = (options: DeleteFileOptions) => Promise<any>;
export type DeleteFileFunction = (options: DeleteFileOptions) => Promise<void | any>;
/**
*

View File

@ -7,7 +7,7 @@ interface UseDownloadBlobOptions {
params?: Record<string, any>;
}
export type DownloadBlobFunction = (url: string, options?: UseDownloadBlobOptions) => Promise<any>;
export type DownloadBlobFunction = (url: string, options?: UseDownloadBlobOptions) => Promise<{ data: Blob }>;
/**
* Blob

26
src/utils/index.d.ts vendored
View File

@ -81,7 +81,7 @@ export function image2Base642(file: File): Promise<string>;
/**
* 访
*/
export function checkImgExists(imgUrl: string): Promise<any>;
export function checkImgExists(imgUrl: string): Promise<Event>;
/**
*
@ -135,7 +135,7 @@ export function getUrlParam(key: string): string;
*/
export function paging<T>(options: {
/** 分页的数组 */
list: any[];
list: Record<string, any>[];
/** 当前页 */
currentPage: number | string;
/** 每页条数 */
@ -184,7 +184,7 @@ export function getLabelName<T>(options: {
/** 状态 */
status: number | string;
/** 翻译的数组 */
list: any[];
list: Record<string, any>[];
/** id字段名 */
idKey?: string;
/** name字段名 */
@ -206,7 +206,7 @@ export function idCardGetDateAndGender(idCard: string): { sex: "1" | "0"; date:
*/
export function getMatchedItems<T>(options: {
/** 获取的数组 */
list: any[];
list: Record<string, any>[];
/** 获取的值 */
value: (number | string)[];
/** 获取的id字段名 */
@ -218,7 +218,7 @@ export function getMatchedItems<T>(options: {
*/
export function getUnmatchedItems<T>(options: {
/** 获取的数组 */
list: any[];
list: Record<string, any>[];
/** 获取的值 */
value: (number | string)[];
/** 获取的id字段名 */
@ -230,7 +230,7 @@ export function getUnmatchedItems<T>(options: {
*/
export function listTransTree<T>(options: {
/** 需要转换的json */
json: any[];
json: Record<string, any>[];
/** id字段 */
idKey: string;
/** 父级id字段 */
@ -289,7 +289,7 @@ export function base642File(base64: string, filename?: string): File;
export function getTreeNodePaths<T extends Record<string, any> = Record<string, any>>(
options: {
/** 树形数据 */
data: any[];
data: Record<string, any>[];
/** 目标节点ID */
targetId: string | number;
/** id字段名 */
@ -297,7 +297,7 @@ export function getTreeNodePaths<T extends Record<string, any> = Record<string,
/** 子节点字段名 */
childrenKey: string;
/** 路径数组 */
path?: any[];
path?: Record<string, any>[];
/** 是否包含自身 */
isIncludeOneself?: boolean;
},
@ -309,7 +309,7 @@ export function getTreeNodePaths<T extends Record<string, any> = Record<string,
export function processTreeDataByLevel(
options: {
/** 树形数据 */
data: any[];
data: Record<string, any>[];
/** 层级限制 */
level?: number;
/** 子节点字段名 */
@ -330,7 +330,7 @@ export function processTreeDataByLevel(
export function processTreeDataForOnlyLastLevel(
options: {
/** 树形数据 */
data: any[];
data: Record<string, any>[];
/** 子节点字段名 */
childrenKey: string;
/** 是否只允许选择最后一级 */
@ -347,21 +347,21 @@ export function processTreeDataForOnlyLastLevel(
*
*/
export function validatorEndTime(options: { startTime: string; message?: string; type?: "date" | "datetime" }): {
validator: (_: any, value: any) => Promise<void | string>;
validator: (_: any, value: any) => Promise<void | any> | void;
};
/**
*
*/
export function validatorTimeGTCurrentDay(options?: { message?: string; type?: "date" | "datetime" }): {
validator: (_: any, value: any) => Promise<void | string>;
validator: (_: any, value: any) => Promise<void | any> | void;
};
/**
*
*/
export function validatorTimeGECurrentDay(options?: { message?: string; type?: "date" | "datetime" }): {
validator: (_: any, value: any) => Promise<void | string>;
validator: (_: any, value: any) => Promise<void | any> | void;
};
/**