| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /**
- * globals.d.ts —— UMD 全局变量的 TypeScript 声明(README §3.3-1「禁 import 框架」的类型侧配套)。
- *
- * 背景:框架运行时全部走 index.html 引入的 UMD 全局(Vue / VueRouter / Pinia / ElementPlus / axios),
- * 业务代码不 import 框架模块。
- * 落点说明:本文件放**仓库根**(而非 src/types)——shims/ 目录在 src 之外,
- * 若声明放 src 内则 shims 文件不生效(全局声明只对 include 范围生效)。
- * 本文件做两件事:
- * ① 声明 5 个 UMD 全局常量(typeof 引自已安装的同版本 dev 依赖,类型与运行时一一对应);
- * ② 声明 vite define 注入的组合式 API 裸标识符(ref / computed / onMounted …),
- * 使业务代码里"裸写 ref()"既能通过类型检查、又能在运行时命中 Vue 全局。
- *
- * 版本纪律:dev 依赖版本必须与 index.html 头部"vendor 版本表"保持一致(升级走 README §1.5 五步流程)。
- */
- import type { AxiosStatic } from 'axios';
- import type { Language } from 'element-plus';
- import type * as PiniaNS from 'pinia';
- import type * as VueNS from 'vue';
- import type * as VueRouterNS from 'vue-router';
- declare global {
- // —— UMD 全局常量(index.html 按序注入)——
- const Vue: typeof VueNS;
- /**
- * vue-demi 桥接全局(vendor/vue-demi@0.14.10 注入):读 globalThis.Vue 后把 Vue API
- * 镜像到本全局。纯 Vue3 下等价于 re-export Vue;业务代码不直接引用,
- * 仅供 pinia IIFE 构建内部取用(pinia 官方构建硬依赖 VueDemi 全局)。声明仅为全局清单完整。
- */
- var VueDemi: typeof VueNS;
- const VueRouter: typeof VueRouterNS;
- const Pinia: typeof PiniaNS;
- /** var 声明(而非 const):允许 globalThis.ElementPlus 属性式访问(http.ts 拦截器内)+ 模板回退解析 */
- var ElementPlus: typeof import('element-plus');
- /** Element Plus 简体中文 locale(vendor/element-plus@2.14.7/locale/zh-cn.min.js 注入) */
- var ElementPlusLocaleZhCn: Language;
- /** UMD 全局 axios 是**实例**(root.axios = 默认实例,含 post/get/create),类型 = AxiosStatic */
- var axios: AxiosStatic;
- // —— vite define 注入的组合式 API 裸标识符(vite.config.ts VUE_APIS 清单与之一一对应)——
- const ref: typeof VueNS.ref;
- const shallowRef: typeof VueNS.shallowRef;
- const reactive: typeof VueNS.reactive;
- const shallowReactive: typeof VueNS.shallowReactive;
- const readonly: typeof VueNS.readonly;
- const shallowReadonly: typeof VueNS.shallowReadonly;
- const computed: typeof VueNS.computed;
- const watch: typeof VueNS.watch;
- const watchEffect: typeof VueNS.watchEffect;
- const watchPostEffect: typeof VueNS.watchPostEffect;
- const watchSyncEffect: typeof VueNS.watchSyncEffect;
- const effectScope: typeof VueNS.effectScope;
- const customRef: typeof VueNS.customRef;
- const triggerRef: typeof VueNS.triggerRef;
- const toRef: typeof VueNS.toRef;
- const toRefs: typeof VueNS.toRefs;
- const toRaw: typeof VueNS.toRaw;
- const toValue: typeof VueNS.toValue;
- const markRaw: typeof VueNS.markRaw;
- const isRef: typeof VueNS.isRef;
- const isReactive: typeof VueNS.isReactive;
- const isReadonly: typeof VueNS.isReadonly;
- const isVNode: typeof VueNS.isVNode;
- const unref: typeof VueNS.unref;
- const onMounted: typeof VueNS.onMounted;
- const onBeforeMount: typeof VueNS.onBeforeMount;
- const onUnmounted: typeof VueNS.onUnmounted;
- const onBeforeUnmount: typeof VueNS.onBeforeUnmount;
- const onUpdated: typeof VueNS.onUpdated;
- const onBeforeUpdate: typeof VueNS.onBeforeUpdate;
- const onActivated: typeof VueNS.onActivated;
- const onDeactivated: typeof VueNS.onDeactivated;
- const onErrorCaptured: typeof VueNS.onErrorCaptured;
- const onRenderTracked: typeof VueNS.onRenderTracked;
- const onRenderTriggered: typeof VueNS.onRenderTriggered;
- const onScopeDispose: typeof VueNS.onScopeDispose;
- const nextTick: typeof VueNS.nextTick;
- const createApp: typeof VueNS.createApp;
- const inject: typeof VueNS.inject;
- const provide: typeof VueNS.provide;
- const h: typeof VueNS.h;
- // —— Vue Router(define 注入为 VueRouter.*)——
- const createRouter: typeof VueRouterNS.createRouter;
- const createWebHashHistory: typeof VueRouterNS.createWebHashHistory;
- const createWebHistory: typeof VueRouterNS.createWebHistory;
- const useRoute: typeof VueRouterNS.useRoute;
- const useRouter: typeof VueRouterNS.useRouter;
- // —— Pinia(define 注入为 Pinia.*)——
- const defineStore: typeof PiniaNS.defineStore;
- const createPinia: typeof PiniaNS.createPinia;
- const storeToRefs: typeof PiniaNS.storeToRefs;
- }
- export {};
|