zova-module-a-router 5.0.42 → 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 +2 -2
- package/src/bean/bean.router.ts +6 -2
- package/src/config/config.ts +4 -2
- package/src/monkey.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-router",
|
|
3
|
-
"version": "5.0.
|
|
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": "
|
|
43
|
+
"gitHead": "35a08c3d5f5376918c3ce38fcd51134632f829ca"
|
|
44
44
|
}
|
package/src/bean/bean.router.ts
CHANGED
|
@@ -109,10 +109,14 @@ export class BeanRouter extends BeanBase {
|
|
|
109
109
|
// donothing
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const moduleName = moduleInfo.relativeName;
|
|
113
|
+
// check if exists
|
|
114
|
+
if (!this.app.meta.module.exists(moduleName)) return '/404';
|
|
115
|
+
// check if loaded
|
|
116
|
+
const module = this.app.meta.module.get(moduleName, false);
|
|
113
117
|
if (module) return;
|
|
114
118
|
// use module
|
|
115
|
-
await this.app.meta.module.use(
|
|
119
|
+
await this.app.meta.module.use(moduleName);
|
|
116
120
|
// redirect again
|
|
117
121
|
return fullPath;
|
|
118
122
|
});
|
package/src/config/config.ts
CHANGED
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) {}
|