/** * global.d.ts —— UMD 全局变量 + vite define 裸标识符的 TypeScript 声明(移动端混合机制类型侧配套)。 * * 背景(移动端混合方案,README §1.x): * - **Vue 系走 UMD 全局**:Vue / VueDemi / VueRouter / Pinia / axios 由 index.html 按序引入 * (vendor/ 自托管,同 PC 端纪律),业务代码不 import 这些框架模块; * - **Vant 走 npm 编译**:Vant 4 官方无 UMD 构建(仅 es/lib),只能 `import Vant from 'vant'` * 编译进 bundle,由 vant 包自带 TS 类型覆盖——故本文件**不声明 Vant 全局**(与 PC 端 ElementPlus * 走 UMD 全局 + 此文件声明的差异点)。 * * 落点:本文件放**仓库根**(monorepo 唯一类型检查入口 tsconfig.json 的 include 覆盖它 + shims/ + * packages/shared/src + apps/{端}/src)。 * 做两件事: * ① 声明 5 个 UMD 全局(Vue/VueDemi/VueRouter/Pinia/axios,typeof 引自同版本 dev 依赖); * ② 声明 vite define 注入的组合式 API 裸标识符(ref / computed / onMounted …), * 使业务代码"裸写 ref()"既过类型检查、又运行时命中 Vue 全局。 * * 版本纪律:dev 依赖版本必须与 index.html 头部"vendor 版本表"一致(升级走框架升级流程)。 */ import type { AxiosStatic } from 'axios'; import type * as PiniaNS from 'pinia'; import type * as VueNS from 'vue'; import type * as VueRouterNS from 'vue-router'; declare global { // —— UMD 全局常量(index.html 按序注入;vendor/ 自托管)—— 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; /** 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 {};