Files
gofly-platform-services/zlt-web/yingyan/src/typings.d.ts
T
2025-12-26 19:50:46 +08:00

114 lines
2.3 KiB
TypeScript

// 全局类型声明
// umi 模块声明补充
declare module 'umi' {
export const history: {
push: (path: string, state?: any) => void;
replace: (path: string, state?: any) => void;
go: (n: number) => void;
goBack: () => void;
goForward: () => void;
location: {
pathname: string;
search: string;
hash: string;
state: any;
};
listen: (listener: (location: any, action: string) => void) => () => void;
};
export function useHistory(): typeof history;
export function request<T = any>(url: string, options?: {
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
params?: Record<string, any>;
data?: any;
headers?: Record<string, string>;
[key: string]: any;
}): Promise<T>;
export const Outlet: React.FC;
export function useLocation(): { pathname: string; search: string; hash: string; state: any };
export function useParams<T = any>(): T;
}
// CSS模块声明
declare module '*.css' {
const content: any;
export default content;
}
declare module '*.less' {
const content: any;
export default content;
}
// 图片资源声明
declare module '*.png' {
const content: string;
export default content;
}
declare module '*.jpg' {
const content: string;
export default content;
}
declare module '*.jpeg' {
const content: string;
export default content;
}
declare module '*.gif' {
const content: string;
export default content;
}
declare module '*.svg' {
const content: string;
export default content;
}
declare module '*.webp' {
const content: string;
export default content;
}
// Cesium相关声明
declare module 'cesium' {
const content: any;
export = content;
}
declare module 'cesium/Build/Cesium/Widgets/widgets.css';
// 扩展Window类型
interface Window {
AMap: any;
}
// API 相关类型
declare namespace API {
// 通用响应结构(兼容两种格式)
interface Result<T = any> {
resp_code?: number;
resp_msg?: string;
code?: number;
msg?: string;
success?: boolean;
data?: T;
datas?: T;
}
// 分页响应结构(兼容两种格式)
interface PageResult<T = any> {
resp_code?: number;
resp_msg?: string;
code?: number;
msg?: string;
success?: boolean;
data?: T[];
datas?: T[];
count?: number;
total?: number;
totalCount?: number;
}
}