import type { PropType as VuePropType } from 'vue'; import type { ECharts } from 'echarts'; // import type { ResponsiveStorage } from './index'; /** * 全局类型声明,无需引入直接在 `.vue` 、`.ts` 、`.tsx` 文件使用即可获得类型提示 */ // GlobalComponents for Volar declare module '@utogether/components'; import type { VxeColumnProps, VxeFormItemProps, VxeToolbarProps } from 'vxe-table'; declare global { /** * 平台的名称、版本、依赖、最后构建时间的类型提示 */ const __APP_INFO__: { pkg: { version: string; }; lastBuildTime: string; }; /** * Window 的类型提示 */ interface Window { // Global vue app __HISTORY_PATH__: string; __APP__: App; $i18n: () => void; webkitCancelAnimationFrame: (handle: number) => void; mozCancelAnimationFrame: (handle: number) => void; oCancelAnimationFrame: (handle: number) => void; msCancelAnimationFrame: (handle: number) => void; webkitRequestAnimationFrame: (callback: FrameRequestCallback) => number; mozRequestAnimationFrame: (callback: FrameRequestCallback) => number; oRequestAnimationFrame: (callback: FrameRequestCallback) => number; msRequestAnimationFrame: (callback: FrameRequestCallback) => number; } // vue type PropType = VuePropType; type Writable = { -readonly [P in keyof T]: T[P]; }; type Nullable = T | null; type NonNullable = T extends null | undefined ? never : T; type Recordable = Record; type ReadonlyRecordable = { readonly [key: string]: T; }; type Indexable = { [key: string]: T; }; type DeepPartial = { [P in keyof T]?: DeepPartial; }; type TimeoutHandle = ReturnType; type IntervalHandle = ReturnType; interface ChangeEvent extends Event { target: HTMLInputElement; } interface WheelEvent { path?: EventTarget[]; } interface ImportMetaEnv extends ViteEnv { __: unknown; } type ViteCompression = 'none' | 'gzip' | 'brotli' | 'both' | 'gzip-clear' | 'brotli-clear' | 'both-clear'; interface ViteEnv { VITE_PORT: number; VITE_PUBLIC_PATH: string; VITE_BASE_URL: string; VITE_ROUTER_HISTORY: string; VITE_TITLE: string; } /** * 对应 `public/serverConfig.json` 文件的类型声明 */ interface ServerConfigs { Version?: string; Title?: string; FixedHeader?: boolean; HiddenSideBar?: boolean; MultiTagsCache?: boolean; KeepAlive?: boolean; Locale?: string; Layout?: string; Theme?: string; DarkMode?: boolean; OverallStyle?: string; Grey?: boolean; Weak?: boolean; HideTabs?: boolean; SidebarStatus?: boolean; EpThemeColor?: string; ShowLogo?: boolean; ShowModel?: string; MenuArrowIconNoTransition?: boolean; CachingAsyncRoutes?: boolean; ResponsiveStorageNameSpace?: string; MapConfigure?: { amapKey?: string; options: { resizeEnable?: boolean; center?: number[]; zoom?: number; }; }; } interface ISystemEnv { VITE_BASE_URL?: string; VITE_PUBLIC_PATH?: string; VITE_ROUTER_HISTORY?: string; VITE_BUINESS_SERVICE?: string; MODE?: string; } /** * 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明 */ interface StorageConfigs { version?: string; title?: string; fixedHeader?: boolean; hiddenSideBar?: boolean; multiTagsCache?: boolean; keepAlive?: boolean; locale?: string; layout?: string; theme?: string; darkMode?: boolean; overallStyle?: string; grey?: boolean; weak?: boolean; hideTabs?: boolean; sidebarStatus?: boolean; epThemeColor?: string; showLogo?: boolean; showModel?: string; mapConfigure?: { amapKey?: string; options: { resizeEnable?: boolean; center?: number[]; zoom?: number; }; }; username?: string; } /** * `responsive-storage` 本地响应式 `storage` 的类型声明 */ interface ResponsiveStorage { locale: { locale?: string; }; layout: { layout?: string; theme?: string; darkMode?: boolean; sidebarStatus?: boolean; epThemeColor?: string; overallStyle?: string; }; configure: { grey?: boolean; weak?: boolean; hideTabs?: boolean; showLogo?: boolean; showModel?: string; multiTagsCache?: boolean; }; tags?: Array; } declare interface IRecord { [ele: string]: any; } declare interface IServiceData { code: string; data: any; msg: tring; } // axios 返回数据结构 declare interface IResponseData { list: [IRecord]; total: number; data: object | sting; } declare interface IProps { type?: string; required?: boolean; isHidden?: boolean; } declare interface IFormItemProps extends VxeFormItemProps, IProps { [x: string]: any; fromField?: string; toField?: string; disabled?: boolean; } declare interface ITableColProps extends VxeColumnProps, IProps { [x: string]: any; } declare interface IButtonProps extends VxeToolbarProps.buttons { auth: string | Array; code: string; } /** * 平台里所有组件实例都能访问到的全局属性对象的类型声明 */ interface GlobalPropertiesApi { $echarts: ECharts; $storage: ResponsiveStorage; $config: ServerConfigs; } }