env.d.ts 1.44 KB
// / <reference types="vite/client" />

declare module "*.vue" {
	import type { DefineComponent } from "vue";

	const component: DefineComponent<object, object, any>;
	export default component;
}

// vue-router 类型声明(模板开发时使用,避免类型错误)
declare module "vue-router" {
	export interface RouteMeta {
		[key: string]: unknown;
		title?: string;
	}

	export interface RouteLocationNormalized {
		[key: string]: unknown;
		meta: RouteMeta;
		name?: null | string | symbol;
		path: string;
	}

	export type NavigationGuardNext = (to?: false | string) => void;

	export interface RouteRecordRaw {
		[key: string]: unknown;
		component?: unknown;
		meta?: RouteMeta;
		name?: string | symbol;
		path: string;
	}

	export interface Router {
		[key: string]: unknown;
		afterEach(guard: (to: RouteLocationNormalized, from: RouteLocationNormalized) => void): () => void;
		beforeEach(
			guard: (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => void,
		): () => void;
	}

	export function createRouter(options: { history: unknown; routes: RouteRecordRaw[] }): Router;

	export function createWebHistory(base?: string): unknown;

	// 导出所有需要的类型
	export type { NavigationGuardNext, RouteLocationNormalized, Router, RouteRecordRaw };
}

// qiankun 相关类型
declare global {
	interface Window {
		__INJECTED_PUBLIC_PATH_BY_QIANKUN__?: string;
		__POWERED_BY_QIANKUN__?: boolean;
	}
}

export {};