zova-module-a-router 5.0.43 → 5.0.44

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.43",
3
+ "version": "5.0.44",
4
4
  "title": "a-router",
5
5
  "zovaModule": {
6
6
  "capabilities": {
@@ -40,5 +40,5 @@
40
40
  "dependencies": {
41
41
  "vue-router": "^4.3.2"
42
42
  },
43
- "gitHead": "94b350996751d74cce48ecabbb0b9026d8c26e83"
43
+ "gitHead": "35a08c3d5f5376918c3ce38fcd51134632f829ca"
44
44
  }
@@ -1,5 +1,7 @@
1
- import { ZovaApplication } from 'zova';
1
+ import { IBeanScopeRecord, ZovaApplication } from 'zova';
2
2
 
3
3
  export const config = (_app: ZovaApplication) => {
4
- return {};
4
+ return {
5
+ defaultComponent: 'home-component' as keyof IBeanScopeRecord,
6
+ };
5
7
  };
package/src/monkey.ts CHANGED
@@ -14,10 +14,13 @@ import {
14
14
  import * as ModuleInfo from '@cabloy/module-info';
15
15
  import { useRoute } from 'vue-router';
16
16
  import { BeanRouter } from './bean/bean.router.js';
17
+ import { ScopeModule, __ThisModule__ } from './resource/this.js';
18
+ import { markRaw } from 'vue';
17
19
 
18
20
  export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule, IMonkeyController {
19
- private _beanRouter: BeanRouter;
20
21
  private _moduleSelf: IModule;
22
+ private _beanRouter: BeanRouter;
23
+ private _beanComponentDefault: any;
21
24
 
22
25
  constructor(moduleSelf: IModule) {
23
26
  super();
@@ -33,11 +36,15 @@ export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule,
33
36
 
34
37
  async appInitialize(_bean: BeanContainer) {}
35
38
  async appInitialized(bean: BeanContainer) {
39
+ // component default
40
+ const scope: ScopeModule = await bean.getScope(__ThisModule__);
41
+ this._beanComponentDefault = await bean.getScope(scope.config.defaultComponent);
36
42
  // emit event
37
43
  const router = bean.inject('a-router:router');
38
44
  await this.app.meta.event.emit('a-router:routerGuards', router);
39
45
  }
40
46
  async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
47
+ const self = this;
41
48
  bean.defineProperty(beanInstance, '$router', {
42
49
  enumerable: false,
43
50
  configurable: true,
@@ -45,6 +52,13 @@ export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule,
45
52
  return bean.inject('a-router:router');
46
53
  },
47
54
  });
55
+ bean.defineProperty(beanInstance, '$component', {
56
+ enumerable: false,
57
+ configurable: true,
58
+ get() {
59
+ return markRaw(self._beanComponentDefault.component);
60
+ },
61
+ });
48
62
  }
49
63
  async beanInited(_bean: BeanContainer, _beanInstance: BeanBase) {}
50
64
  beanDispose(_bean: BeanContainer, _beanInstance: BeanBase) {}