@ray-js/router 1.6.31 → 1.7.0
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/lib/Router.d.ts +20 -2
- package/lib/Router.js +21 -1
- package/package.json +5 -5
package/lib/Router.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Router as TRouter
|
2
|
-
import { RouterScheduler } from './RouterScheduler';
|
1
|
+
import type { RouteOptions, Router as TRouter } from '@ray-js/types';
|
2
|
+
import type { RouterScheduler } from './RouterScheduler';
|
3
3
|
export declare class Router implements TRouter {
|
4
4
|
/**
|
5
5
|
* 页面路由调度器
|
@@ -13,7 +13,25 @@ export declare class Router implements TRouter {
|
|
13
13
|
scheduler: RouterScheduler;
|
14
14
|
});
|
15
15
|
private normalizeRoute;
|
16
|
+
/**
|
17
|
+
* 跳转到指定路由
|
18
|
+
* @param to - routes.config.ts 中配置的路由地址
|
19
|
+
* @param options
|
20
|
+
* @param options.subpackage - 分包名
|
21
|
+
*
|
22
|
+
* @example
|
23
|
+
* router.push('/cat', { subpackage: 'packageA' });
|
24
|
+
*/
|
16
25
|
push(to: string, options?: RouteOptions): void;
|
26
|
+
/**
|
27
|
+
* 替换当前路由
|
28
|
+
* @param to - routes.config.ts 中配置的路由地址
|
29
|
+
* @param options
|
30
|
+
* @param options.subpackage - 分包名
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* router.replace('/cat', { subpackage: 'packageA' });
|
34
|
+
*/
|
17
35
|
replace(to: string, options?: RouteOptions): void;
|
18
36
|
go(delta: number): void;
|
19
37
|
back(): void;
|
package/lib/Router.js
CHANGED
@@ -14,7 +14,7 @@ export class Router {
|
|
14
14
|
// window.router = this
|
15
15
|
}
|
16
16
|
normalizeRoute(params) {
|
17
|
-
|
17
|
+
const {
|
18
18
|
to
|
19
19
|
} = params;
|
20
20
|
// FIXME: 绝对路径是否需要支持?
|
@@ -43,6 +43,16 @@ export class Router {
|
|
43
43
|
to
|
44
44
|
});
|
45
45
|
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* 跳转到指定路由
|
49
|
+
* @param to - routes.config.ts 中配置的路由地址
|
50
|
+
* @param options
|
51
|
+
* @param options.subpackage - 分包名
|
52
|
+
*
|
53
|
+
* @example
|
54
|
+
* router.push('/cat', { subpackage: 'packageA' });
|
55
|
+
*/
|
46
56
|
push(to) {
|
47
57
|
this.normalizeRoute({
|
48
58
|
to
|
@@ -53,6 +63,16 @@ export class Router {
|
|
53
63
|
history.push(to);
|
54
64
|
});
|
55
65
|
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* 替换当前路由
|
69
|
+
* @param to - routes.config.ts 中配置的路由地址
|
70
|
+
* @param options
|
71
|
+
* @param options.subpackage - 分包名
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* router.replace('/cat', { subpackage: 'packageA' });
|
75
|
+
*/
|
56
76
|
replace(to) {
|
57
77
|
this.normalizeRoute({
|
58
78
|
to
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/router",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.7.0",
|
4
4
|
"description": "Ray Core",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -23,17 +23,17 @@
|
|
23
23
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@ray-js/library": "1.
|
27
|
-
"@ray-js/types": "1.
|
26
|
+
"@ray-js/library": "1.7.0",
|
27
|
+
"@ray-js/types": "1.7.0",
|
28
28
|
"history": "^4.10.1"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
|
-
"@ray-js/cli": "1.
|
31
|
+
"@ray-js/cli": "1.7.0",
|
32
32
|
"@types/history": "^5.0.0"
|
33
33
|
},
|
34
34
|
"publishConfig": {
|
35
35
|
"access": "public",
|
36
36
|
"registry": "https://registry.npmjs.com"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "c230e01c313aca9700e12d14b80488aae9bec3d3"
|
39
39
|
}
|