1- import _Vue , { VueConstructor } from 'vue' ;
1+ import { VueConstructor } from 'vue' ;
22import { Route , RawLocation } from 'vue-router' ;
33import dynamicComponent , { namespaces as dynamicComponentPath } from './ability/dynamicComponent' ;
44import dynamicComponentState from './ability/dynamicComponent/storeModule' ;
@@ -39,12 +39,12 @@ export default function install(Vue: VueConstructor) {
3939 } ) ;
4040
4141 // router
42- const routerExtend = ( router : VueRouter ) => {
42+ const routerInject = ( router : VueRouter ) => {
4343 // 解决动态路由404问题
4444 const resolveRoute = (
4545 to : Route ,
4646 from : Route ,
47- next : ( to ?: RawLocation | false | ( ( vm : _Vue ) => void ) | void ) => void ,
47+ next : ( to ?: RawLocation | false | ( ( vm : InstanceType < VueConstructor > ) => void ) | void ) => void ,
4848 ) => {
4949 const fullPath = to . redirectedFrom || to . fullPath ;
5050 const { resolved, location } = router . resolve ( fullPath ) ;
@@ -79,7 +79,7 @@ export default function install(Vue: VueConstructor) {
7979 } ;
8080
8181 // store
82- const storeExtend = ( store : Store < unknown > ) => {
82+ const storeInject = ( store : Store < unknown > ) => {
8383 store . registerModule ( dynamicComponentPath , dynamicComponentState ) ;
8484 // define $dynamicComponent
8585 Object . defineProperty ( Vue . prototype , '$dynamicComponent' , {
@@ -93,11 +93,10 @@ export default function install(Vue: VueConstructor) {
9393 // 从 Vue root option 中获取 router | store 实例
9494 // router beforeEach 需要在 beforeCreate 之前添加,才能在页面强制刷新时第一次生效
9595 if ( options . router ) {
96- routerExtend ( options . router ) ;
96+ routerInject ( options . router ) ;
9797 }
98-
9998 if ( options . store ) {
100- storeExtend ( options . store ) ;
99+ storeInject ( options . store ) ;
101100 }
102101 _init . call ( this , options ) ;
103102 } ;
@@ -109,6 +108,10 @@ export default function install(Vue: VueConstructor) {
109108 // eslint-disable-next-line @typescript-eslint/camelcase
110109 Vue . $__module_loader_installed__ = true ;
111110
111+ if ( window && ! window . Vue ) {
112+ window . Vue = Vue as any ;
113+ }
114+
112115 Vue . mixin ( {
113116 beforeCreate ( ) {
114117 const options = this . $options as any ;
0 commit comments