zova-module-a-router 5.0.56 → 5.0.60
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 +3 -3
- package/src/.metadata/index.ts +36 -0
- package/src/.metadata/this.ts +2 -0
- package/src/bean/bean.router.ts +6 -4
- package/src/bean/local.router.ts +2 -2
- package/src/index.ts +1 -6
- package/src/monkey.ts +10 -1
- package/src/types.ts +8 -0
- package/src/api/index.ts +0 -2
- package/src/api/interface/index.ts +0 -1
- package/src/api/service/index.ts +0 -1
- package/src/component/.gitkeep +0 -0
- package/src/config/constants.ts +0 -1
- package/src/config/errors.ts +0 -1
- package/src/config/index.ts +0 -4
- package/src/config/locale/en-us.ts +0 -1
- package/src/config/locale/zh-cn.ts +0 -1
- package/src/config/locales.ts +0 -7
- package/src/page/.gitkeep +0 -0
- package/src/resource/beans.ts +0 -9
- package/src/resource/components.ts +0 -1
- package/src/resource/events.ts +0 -12
- package/src/resource/index.ts +0 -4
- package/src/resource/scope.ts +0 -32
- package/src/resource/this.ts +0 -4
- package/src/routes.ts +0 -3
- package/src/typings.ts +0 -1
- /package/src/bean/{virtual.router.ts → bean.routerBase.ts} +0 -0
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.60",
|
|
4
4
|
"title": "a-router",
|
|
5
5
|
"zovaModule": {
|
|
6
6
|
"capabilities": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"clean": "tsc -b --clean",
|
|
37
37
|
"tsc:publish": "npm run clean && tsc -b",
|
|
38
|
-
"
|
|
38
|
+
"_prepublishOnly": "npm run tsc:publish"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"vue-router": "^4.3.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "b87bdd8540395b181993a617d33cad57b3c4d446"
|
|
44
44
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** beans: begin */
|
|
2
|
+
export * from '../bean/bean.router.js';
|
|
3
|
+
export * from '../bean/bean.routerBase.js';
|
|
4
|
+
import { BeanRouter } from '../bean/bean.router.js';
|
|
5
|
+
import { BeanRouterBase } from '../bean/bean.routerBase.js';
|
|
6
|
+
import 'zova';
|
|
7
|
+
declare module 'zova' {
|
|
8
|
+
export interface IBeanRecord {
|
|
9
|
+
'a-router.bean.router': BeanRouter;
|
|
10
|
+
'a-router.bean.routerBase': BeanRouterBase;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** beans: end */
|
|
14
|
+
/** config: begin */
|
|
15
|
+
export * from '../config/config.js';
|
|
16
|
+
import { config } from '../config/config.js';
|
|
17
|
+
/** config: end */
|
|
18
|
+
/** scope: begin */
|
|
19
|
+
import { BeanScopeBase, Scope, TypeModuleResource } from 'zova';
|
|
20
|
+
|
|
21
|
+
@Scope()
|
|
22
|
+
export class ScopeModuleARouter extends BeanScopeBase {}
|
|
23
|
+
|
|
24
|
+
export interface ScopeModuleARouter extends TypeModuleResource<any, typeof config, any, any, any, any> {}
|
|
25
|
+
|
|
26
|
+
import 'zova';
|
|
27
|
+
declare module 'zova' {
|
|
28
|
+
export interface IBeanScopeRecord {
|
|
29
|
+
'a-router': ScopeModuleARouter;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IBeanScopeConfig {
|
|
33
|
+
'a-router': ReturnType<typeof config>;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** scope: end */
|
package/src/bean/bean.router.ts
CHANGED
|
@@ -33,7 +33,7 @@ export class BeanRouter extends BeanBase {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
private _createRouter() {
|
|
36
|
-
const createHistory =
|
|
36
|
+
const createHistory = process.env.SERVER
|
|
37
37
|
? createMemoryHistory
|
|
38
38
|
: this.app.config.env.appRouterMode === 'history'
|
|
39
39
|
? createWebHistory
|
|
@@ -68,7 +68,7 @@ export class BeanRouter extends BeanBase {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
public checkPathValid(to?: { name?: string; path?: string } | string): boolean {
|
|
71
|
-
const _path = to && typeof to === 'object' ? to.name ?? to.path : to;
|
|
71
|
+
const _path = to && typeof to === 'object' ? (to.name ?? to.path) : to;
|
|
72
72
|
if (!_path) return true;
|
|
73
73
|
const moduleName = ModuleInfo.parseName(_path);
|
|
74
74
|
if (!moduleName) return true;
|
|
@@ -113,11 +113,13 @@ export class BeanRouter extends BeanBase {
|
|
|
113
113
|
private _registerRoute(module: IModule, route: IModuleRoute) {
|
|
114
114
|
// path
|
|
115
115
|
let path: string | undefined;
|
|
116
|
-
if (route.path) {
|
|
116
|
+
if (route.path !== undefined) {
|
|
117
117
|
if (route.meta?.absolute === true) {
|
|
118
118
|
path = route.path;
|
|
119
119
|
} else {
|
|
120
|
-
path =
|
|
120
|
+
path = route.path
|
|
121
|
+
? `/${module.info.pid}/${module.info.name}/${route.path}`
|
|
122
|
+
: `/${module.info.pid}/${module.info.name}`;
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
// name
|
package/src/bean/local.router.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Local, Use } from 'zova';
|
|
2
2
|
import * as ModuleInfo from '@cabloy/module-info';
|
|
3
|
-
import { ScopeModule } from '
|
|
4
|
-
import { BeanRouterBase } from './
|
|
3
|
+
import { ScopeModule } from '../.metadata/this.js';
|
|
4
|
+
import { BeanRouterBase } from './bean.routerBase.js';
|
|
5
5
|
import { BeanRouter } from './bean.router.js';
|
|
6
6
|
|
|
7
7
|
@Local()
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './resource/index.js';
|
|
3
|
-
export * from './api/index.js';
|
|
4
|
-
export * from './routes.js';
|
|
1
|
+
export * from './.metadata/index.js';
|
|
5
2
|
export * from './types.js';
|
|
6
3
|
export * from './monkey.js';
|
|
7
|
-
|
|
8
|
-
import './typings.js';
|
package/src/monkey.ts
CHANGED
|
@@ -14,7 +14,7 @@ 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 '
|
|
17
|
+
import { ScopeModule, __ThisModule__ } from './.metadata/this.js';
|
|
18
18
|
import { markRaw } from 'vue';
|
|
19
19
|
import { getRealRouteName } from './utils.js';
|
|
20
20
|
import { LocalRouter } from './bean/local.router.js';
|
|
@@ -52,6 +52,15 @@ export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule,
|
|
|
52
52
|
async appReady(_bean: BeanContainer) {
|
|
53
53
|
// use router
|
|
54
54
|
this.app.vue.use(this._beanRouter);
|
|
55
|
+
// ssr
|
|
56
|
+
if (process.env.SERVER) {
|
|
57
|
+
// push
|
|
58
|
+
const url = this.ctx.meta.ssr.context.req.url;
|
|
59
|
+
this._beanRouter.push(url);
|
|
60
|
+
await this._beanRouter.isReady();
|
|
61
|
+
} else if (process.env.CLIENT && this.ctx.meta.ssr.isRuntimeSsrPreHydration) {
|
|
62
|
+
await this._beanRouter.isReady();
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
|
|
57
66
|
const self = this;
|
package/src/types.ts
CHANGED
|
@@ -42,4 +42,12 @@ declare module 'zova' {
|
|
|
42
42
|
path: Record<keyof IPagePathRecord, IModuleRoute>;
|
|
43
43
|
name: Record<keyof IPageNameRecord, IModuleRoute>;
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
export interface IEventRecord {
|
|
47
|
+
'a-router:routerGuards': BeanRouter;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IEventResultRecord {
|
|
51
|
+
'a-router:routerGuards': void;
|
|
52
|
+
}
|
|
45
53
|
}
|
package/src/api/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/api/service/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const services = {};
|
package/src/component/.gitkeep
DELETED
|
File without changes
|
package/src/config/constants.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const constants = null;
|
package/src/config/errors.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export enum Errors {}
|
package/src/config/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|
package/src/config/locales.ts
DELETED
package/src/page/.gitkeep
DELETED
|
File without changes
|
package/src/resource/beans.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const components = {};
|
package/src/resource/events.ts
DELETED
package/src/resource/index.ts
DELETED
package/src/resource/scope.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BeanScopeBase, Scope, TypeLocaleBase, TypeModuleResource } from 'zova';
|
|
2
|
-
import { config, Errors, locales, constants } from '../config/index.js';
|
|
3
|
-
import { components } from './components.js';
|
|
4
|
-
import { services } from '../api/service/index.js';
|
|
5
|
-
|
|
6
|
-
@Scope()
|
|
7
|
-
export class ScopeModuleARouter extends BeanScopeBase {}
|
|
8
|
-
|
|
9
|
-
export interface ScopeModuleARouter
|
|
10
|
-
extends TypeModuleResource<
|
|
11
|
-
typeof components,
|
|
12
|
-
typeof config,
|
|
13
|
-
typeof Errors,
|
|
14
|
-
(typeof locales)[TypeLocaleBase],
|
|
15
|
-
typeof constants,
|
|
16
|
-
typeof services
|
|
17
|
-
> {}
|
|
18
|
-
|
|
19
|
-
import 'zova';
|
|
20
|
-
declare module 'zova' {
|
|
21
|
-
export interface IBeanScopeRecord {
|
|
22
|
-
'a-router': ScopeModuleARouter;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface IBeanScopeConfig {
|
|
26
|
-
'a-router': ReturnType<typeof config>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface IBeanScopeLocale {
|
|
30
|
-
'a-router': (typeof locales)[TypeLocaleBase];
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/resource/this.ts
DELETED
package/src/routes.ts
DELETED
package/src/typings.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|