zova-module-a-router 5.0.38 → 5.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-router",
3
- "version": "5.0.38",
3
+ "version": "5.0.40",
4
4
  "title": "a-router",
5
5
  "zovaModule": {
6
6
  "capabilities": {
@@ -37,5 +37,5 @@
37
37
  "dependencies": {
38
38
  "vue-router": "^4.3.2"
39
39
  },
40
- "gitHead": "90bb78df182aa8db862d6b44e86d23aa33b195fa"
40
+ "gitHead": "8816955c45f2fc3911d5eebf5b09764f54777123"
41
41
  }
@@ -5,9 +5,9 @@ import { IModuleRoute, IModuleRouteComponent } from '../types.js';
5
5
 
6
6
  const SymbolRouter = Symbol('SymbolRouter');
7
7
 
8
- export type BeanRouterLike = BeanRouter & Router;
8
+ export interface BeanRouter extends Router {}
9
9
 
10
- @Bean({ scene: 'bean', name: 'router', containerScope: 'ctx' })
10
+ @Bean()
11
11
  export class BeanRouter extends BeanBase {
12
12
  [SymbolRouter]: Router;
13
13
  eventRouterGuards: TypeEventOff;
@@ -27,7 +27,8 @@ export class BeanRouter extends BeanBase {
27
27
  if (!router) {
28
28
  throw new Error('Should provide router');
29
29
  }
30
- this.bean.provide('a-router:router', Cast<BeanRouterLike>(this));
30
+ this.app.vue.provide('a-router:router', this);
31
+ this.bean.provide('a-router:router', this);
31
32
  // event
32
33
  this.eventRouterGuards = this.app.meta.event.on('a-router:routerGuards', async (context, next) => {
33
34
  this._routerGuards(context.data);
@@ -98,7 +99,7 @@ export class BeanRouter extends BeanBase {
98
99
  return `${fullPath}${join}${query2str}`;
99
100
  }
100
101
 
101
- private _routerGuards(router: BeanRouterLike) {
102
+ private _routerGuards(router: BeanRouter) {
102
103
  router.beforeEach(async to => {
103
104
  // fullPath
104
105
  const fullPath = to.fullPath;
@@ -1,5 +1,5 @@
1
1
  import { BeanBase, TypeEventOff, Virtual } from 'zova';
2
- import { BeanRouterLike } from './bean.router.js';
2
+ import { BeanRouter } from './bean.router.js';
3
3
 
4
4
  @Virtual()
5
5
  export class BeanRouterBase<TScopeModule = unknown> extends BeanBase<TScopeModule> {
@@ -18,5 +18,5 @@ export class BeanRouterBase<TScopeModule = unknown> extends BeanBase<TScopeModul
18
18
  }
19
19
  }
20
20
 
21
- protected onRouterGuards(_router: BeanRouterLike) {}
21
+ protected onRouterGuards(_router: BeanRouter) {}
22
22
  }
package/src/monkey.ts CHANGED
@@ -13,10 +13,10 @@ import {
13
13
  } from 'zova';
14
14
  import * as ModuleInfo from '@cabloy/module-info';
15
15
  import { useRoute } from 'vue-router';
16
- import { BeanRouterLike } from './bean/bean.router.js';
16
+ import { BeanRouter } from './bean/bean.router.js';
17
17
 
18
18
  export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule, IMonkeyController {
19
- private _beanRouter: BeanRouterLike;
19
+ private _beanRouter: BeanRouter;
20
20
  private _moduleSelf: IModule;
21
21
 
22
22
  constructor(moduleSelf: IModule) {
@@ -26,15 +26,15 @@ export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule,
26
26
 
27
27
  async getBeanRouter() {
28
28
  if (!this._beanRouter) {
29
- this._beanRouter = (await this.bean._getBean('a-router.bean.router', false)) as BeanRouterLike;
29
+ this._beanRouter = (await this.bean._getBean('a-router.bean.router', false)) as BeanRouter;
30
30
  }
31
31
  return this._beanRouter;
32
32
  }
33
33
 
34
34
  async appInitialize(_bean: BeanContainerLike) {}
35
- async appInitialized(_bean: BeanContainerLike) {
35
+ async appInitialized(bean: BeanContainerLike) {
36
36
  // emit event
37
- const router = this.bean.inject('a-router:router');
37
+ const router = bean.inject('a-router:router');
38
38
  await this.app.meta.event.emit('a-router:routerGuards', router);
39
39
  }
40
40
  async beanInit(bean: BeanContainerLike, beanInstance: BeanBase) {
@@ -1,9 +1,9 @@
1
- import { BeanRouterLike } from './beans.js';
1
+ import { BeanRouter } from './beans.js';
2
2
 
3
3
  import 'zova';
4
4
  declare module 'zova' {
5
5
  export interface IEventRecord {
6
- 'a-router:routerGuards': BeanRouterLike;
6
+ 'a-router:routerGuards': BeanRouter;
7
7
  }
8
8
 
9
9
  export interface IEventResultRecord {
@@ -1,10 +1,10 @@
1
1
  import { Router } from 'vue-router';
2
- import { BeanRouterLike } from '../bean/bean.router.js';
2
+ import { BeanRouter } from '../bean/bean.router.js';
3
3
 
4
4
  import 'zova';
5
5
  declare module 'zova' {
6
6
  export interface IInjectRecord {
7
7
  'a-router:appRouter': Router;
8
- 'a-router:router': BeanRouterLike;
8
+ 'a-router:router': BeanRouter;
9
9
  }
10
10
  }
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IComponentLayoutRecord, TypePageSchemas } from 'zova';
2
2
  import { RouteComponent, RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router';
3
- import { BeanRouterLike } from './bean/bean.router.js';
3
+ import { BeanRouter } from './bean/bean.router.js';
4
4
 
5
5
  export type Lazy<T> = () => Promise<T>;
6
6
  export type IModuleRouteComponent = RouteComponent | Lazy<RouteComponent>;
@@ -17,7 +17,7 @@ declare module 'vue-router' {
17
17
 
18
18
  declare module 'zova' {
19
19
  export interface BeanBase {
20
- $router: BeanRouterLike;
20
+ $router: BeanRouter;
21
21
  }
22
22
 
23
23
  export interface IModuleResource {