declare interface ImportMetaEnv {
  VITE_PROXY: ProxyList | undefined
  readonly VITE_APP_TITLE: string
  readonly VITE_NODE_ENV: 'development' | 'production'
  readonly VITE_ROUTER_MODE: 'hash' | 'history'
  readonly VITE_PORT: number
  readonly VITE_OPEN: boolean
  readonly VITE_USE_MOCK: boolean
  readonly VITE_API_PREFIX_PATH: string
  readonly VITE_MOCK_API_PREFIX_PATH: string
}

declare type Recordable<T = any> = Record<string, T>
declare type LayoutType = 'classic' | 'transverse'
declare interface AxiosConfig {
  params?: any
  data?: any
  url?: string
  method?: AxiosMethod
  headers?: RawAxiosRequestHeaders
  responseType?: AxiosResponseType
}

// 请求响应参数（包含data）
declare interface ResultData<T = any> extends Result {
  data: T
}

// 请求响应参数（不包含data）
declare interface Result {
  code: string | number
  msg: string
}

// BaseEntity
declare interface BaseEntity {
  /** 乐观锁 */
  version?: number
  createBy?: string
  createTime?: string
  updateBy?: string
  updateTime?: any
}

// 分页请求参数
declare interface PageQuery {
  pageNum: number
  pageSize: number
}

// 分页响应参数
declare interface ResPage<T> {
  list: T[]
  pageNum: number
  pageSize: number
  total: number
}

declare type Nullable<T> = T | null

declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>

declare interface Fn<T = any> {
  (...arg: T[]): T
}
type ObjToKeyValArray<T> = {
  [K in keyof T]: [K, T[K]]
}[keyof T]

declare type keyOnPrefix<T> = {
  [K in keyof T as `on${Capitalize<K>}`]: T[K] extends readonly any[] ? (...t: T[K]) => void : never
}

declare namespace Menu {
  interface MenuOptions {
    id: string
    pid: string
    path: string
    name: string
    sort: number
    menuTypeCd: string
    component?: string | (() => Promise<unknown>)
    redirect?: string
    permissions?: string
    meta: MetaProps
    children?: MenuOptions[]
  }

  interface MetaProps {
    icon: string
    title: string
    isLink?: string
    isHidden: string
    isFull: string
    isAffix: string
    isKeepAlive: string
    useDataScope: string
  }
}
