@ray-js/router 1.3.21 → 1.3.23
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/LICENSE.md +9 -0
- package/lib/Router.js +72 -90
- package/lib/RouterScheduler.d.ts +1 -1
- package/lib/RouterScheduler.js +60 -118
- package/lib/history/index.js +42 -78
- package/lib/index.js +28 -27
- package/package.json +5 -5
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright © 2014-2022 Tuya.inc
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/lib/Router.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import "core-js/modules/es.string.starts-with.js";
|
|
4
|
-
import "core-js/modules/es.object.to-string.js";
|
|
5
|
-
import "core-js/modules/es.promise.js";
|
|
6
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
7
|
-
import "core-js/modules/es.string.search.js";
|
|
8
|
-
import "core-js/modules/es.string.replace.js";
|
|
9
1
|
import { url } from '@ray-js/library';
|
|
10
2
|
import { history } from './history';
|
|
11
|
-
export
|
|
3
|
+
export class Router {
|
|
12
4
|
/**
|
|
13
5
|
* 页面路由调度器
|
|
14
6
|
*/
|
|
@@ -16,94 +8,84 @@ export var Router = /*#__PURE__*/function () {
|
|
|
16
8
|
/**
|
|
17
9
|
* 当前环境地址栏
|
|
18
10
|
*/
|
|
19
|
-
function Router(options) {
|
|
20
|
-
_classCallCheck(this, Router);
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.scheduler = options.scheduler;
|
|
14
|
+
// window.router = this
|
|
23
15
|
}
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return Promise.resolve({
|
|
32
|
-
to: to
|
|
33
|
-
});
|
|
34
|
-
} // TODO: Web 应用下重复进入一个路由
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (this.$href) {
|
|
38
|
-
var _url$parse = url.parse(this.$href),
|
|
39
|
-
pathname = _url$parse.pathname,
|
|
40
|
-
search = _url$parse.search,
|
|
41
|
-
hash = _url$parse.hash;
|
|
42
|
-
|
|
43
|
-
if (url.format({
|
|
44
|
-
pathname: pathname,
|
|
45
|
-
search: search,
|
|
46
|
-
hash: hash
|
|
47
|
-
}) === to) {
|
|
48
|
-
console.warn('duplicate route to:', to);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
17
|
+
normalizeRoute(params) {
|
|
18
|
+
let {
|
|
19
|
+
to
|
|
20
|
+
} = params;
|
|
21
|
+
// FIXME: 绝对路径是否需要支持?
|
|
22
|
+
if (to.startsWith('//') || to.startsWith('http')) {
|
|
52
23
|
return Promise.resolve({
|
|
53
|
-
to
|
|
24
|
+
to
|
|
54
25
|
});
|
|
55
26
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
|
|
28
|
+
// TODO: Web 应用下重复进入一个路由
|
|
29
|
+
if (this.$href) {
|
|
30
|
+
const {
|
|
31
|
+
pathname,
|
|
32
|
+
search,
|
|
33
|
+
hash
|
|
34
|
+
} = url.parse(this.$href);
|
|
35
|
+
if (url.format({
|
|
36
|
+
pathname,
|
|
37
|
+
search,
|
|
38
|
+
hash
|
|
39
|
+
}) === to) {
|
|
40
|
+
console.warn('duplicate route to:', to);
|
|
41
|
+
}
|
|
65
42
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
return Promise.resolve({
|
|
44
|
+
to
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
push(to) {
|
|
48
|
+
this.normalizeRoute({
|
|
49
|
+
to
|
|
50
|
+
}).then(_ref => {
|
|
51
|
+
let {
|
|
52
|
+
to
|
|
53
|
+
} = _ref;
|
|
54
|
+
history.push(to);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
replace(to) {
|
|
58
|
+
this.normalizeRoute({
|
|
59
|
+
to
|
|
60
|
+
}).then(_ref2 => {
|
|
61
|
+
let {
|
|
62
|
+
to
|
|
63
|
+
} = _ref2;
|
|
64
|
+
history.replace(to);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
go(delta) {
|
|
68
|
+
// 在应用堆栈内进行跳转
|
|
69
|
+
history.go(delta);
|
|
70
|
+
}
|
|
71
|
+
back() {
|
|
72
|
+
history.goBack();
|
|
73
|
+
}
|
|
74
|
+
reload(to) {
|
|
75
|
+
if (to) {
|
|
69
76
|
this.normalizeRoute({
|
|
70
|
-
to
|
|
71
|
-
}).then(
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
to
|
|
78
|
+
}).then(_ref3 => {
|
|
79
|
+
let {
|
|
80
|
+
to
|
|
81
|
+
} = _ref3;
|
|
82
|
+
window.location.href = to;
|
|
74
83
|
});
|
|
84
|
+
} else {
|
|
85
|
+
window.location.reload();
|
|
75
86
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "back",
|
|
84
|
-
value: function back() {
|
|
85
|
-
history.goBack();
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "reload",
|
|
89
|
-
value: function reload(to) {
|
|
90
|
-
if (to) {
|
|
91
|
-
this.normalizeRoute({
|
|
92
|
-
to: to
|
|
93
|
-
}).then(function (_ref3) {
|
|
94
|
-
var to = _ref3.to;
|
|
95
|
-
window.location.href = to;
|
|
96
|
-
});
|
|
97
|
-
} else {
|
|
98
|
-
window.location.reload();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "href",
|
|
103
|
-
get: function get() {
|
|
104
|
-
return window.location.href;
|
|
105
|
-
}
|
|
106
|
-
}]);
|
|
107
|
-
|
|
108
|
-
return Router;
|
|
109
|
-
}();
|
|
87
|
+
}
|
|
88
|
+
get href() {
|
|
89
|
+
return window.location.href;
|
|
90
|
+
}
|
|
91
|
+
}
|
package/lib/RouterScheduler.d.ts
CHANGED
package/lib/RouterScheduler.js
CHANGED
|
@@ -1,129 +1,71 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
import "core-js/modules/es.array.concat.js";
|
|
9
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
10
|
-
import "core-js/modules/es.string.replace.js";
|
|
11
|
-
import "core-js/modules/es.array.splice.js";
|
|
12
|
-
import "core-js/modules/es.array.index-of.js";
|
|
13
|
-
import "core-js/modules/es.object.to-string.js";
|
|
14
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
15
2
|
import { RouterScheduler as IRouterScheduler } from '@ray-js/types';
|
|
16
|
-
|
|
17
3
|
/**
|
|
18
4
|
* web 环境下的路由协调器
|
|
19
5
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
export class RouterScheduler extends IRouterScheduler {
|
|
7
|
+
$currentRoute = '';
|
|
8
|
+
$listeners = {};
|
|
9
|
+
$entityMap = [];
|
|
10
|
+
basename = '/';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 当前调度器的 route 地址
|
|
14
|
+
*/
|
|
15
|
+
get currentRoute() {
|
|
16
|
+
return this.$currentRoute;
|
|
17
|
+
}
|
|
18
|
+
set currentRoute(val) {
|
|
19
|
+
if (val !== this.currentRoute) {
|
|
20
|
+
this.$currentRoute = val.replace(/\/$/, '');
|
|
21
|
+
this.emit('routeChange', this.currentRoute);
|
|
32
22
|
}
|
|
33
|
-
|
|
34
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
35
|
-
|
|
36
|
-
_defineProperty(_assertThisInitialized(_this), "$currentRoute", '');
|
|
37
|
-
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "$listeners", {});
|
|
39
|
-
|
|
40
|
-
_defineProperty(_assertThisInitialized(_this), "$entityMap", []);
|
|
41
|
-
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "basename", '/');
|
|
43
|
-
|
|
44
|
-
return _this;
|
|
45
23
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
get:
|
|
50
|
-
/**
|
|
51
|
-
* 当前调度器的 route 地址
|
|
52
|
-
*/
|
|
53
|
-
function get() {
|
|
54
|
-
return this.$currentRoute;
|
|
55
|
-
},
|
|
56
|
-
set: function set(val) {
|
|
57
|
-
if (val !== this.currentRoute) {
|
|
58
|
-
this.$currentRoute = val.replace(/\/$/, '');
|
|
59
|
-
this.emit('routeChange', this.currentRoute);
|
|
60
|
-
}
|
|
24
|
+
on(event, fn) {
|
|
25
|
+
if (!this.$listeners[event]) {
|
|
26
|
+
this.$listeners[event] = [];
|
|
61
27
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
events.splice(events.indexOf(fn), 1);
|
|
73
|
-
};
|
|
74
|
-
} // 给 TabBar 监听,用于处理当前高亮状态
|
|
75
|
-
|
|
76
|
-
}, {
|
|
77
|
-
key: "emit",
|
|
78
|
-
value: function emit(event) {
|
|
79
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
80
|
-
args[_key2 - 1] = arguments[_key2];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var fns = this.$listeners[event];
|
|
84
|
-
|
|
85
|
-
if (Array.isArray(fns)) {
|
|
86
|
-
fns.forEach(function (fn) {
|
|
87
|
-
fn.apply(void 0, args);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
28
|
+
const events = this.$listeners[event];
|
|
29
|
+
events.push(fn);
|
|
30
|
+
return () => {
|
|
31
|
+
events.splice(events.indexOf(fn), 1);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// 给 TabBar 监听,用于处理当前高亮状态
|
|
35
|
+
emit(event) {
|
|
36
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
37
|
+
args[_key - 1] = arguments[_key];
|
|
90
38
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, {
|
|
96
|
-
key: "registryPages",
|
|
97
|
-
value: function registryPages(params) {
|
|
98
|
-
var _this2 = this;
|
|
99
|
-
|
|
100
|
-
var pages = params.pages,
|
|
101
|
-
tabBar = params.tabBar;
|
|
102
|
-
var tabBarList = (tabBar === null || tabBar === void 0 ? void 0 : tabBar.list) || [];
|
|
103
|
-
pages.forEach(function (page) {
|
|
104
|
-
var isTabBar = tabBarList.some(function (item) {
|
|
105
|
-
return page.path === item.pagePath;
|
|
106
|
-
});
|
|
107
|
-
page.route = page.route || page.path;
|
|
108
|
-
page.originalRoute = page.route;
|
|
109
|
-
|
|
110
|
-
_this2.addPage(_objectSpread(_objectSpread({}, page), {}, {
|
|
111
|
-
isTabBar: isTabBar
|
|
112
|
-
}));
|
|
39
|
+
const fns = this.$listeners[event];
|
|
40
|
+
if (Array.isArray(fns)) {
|
|
41
|
+
fns.forEach(fn => {
|
|
42
|
+
fn(...args);
|
|
113
43
|
});
|
|
114
44
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 初始化路由,注册应用声明的路由,并处理映射关系
|
|
48
|
+
*/
|
|
49
|
+
registryPages(params) {
|
|
50
|
+
const {
|
|
51
|
+
pages,
|
|
52
|
+
tabBar
|
|
53
|
+
} = params;
|
|
54
|
+
const tabBarList = (tabBar === null || tabBar === void 0 ? void 0 : tabBar.list) || [];
|
|
55
|
+
pages.forEach(page => {
|
|
56
|
+
const isTabBar = tabBarList.some(item => page.path === item.pagePath);
|
|
57
|
+
page.route = page.route || page.path;
|
|
58
|
+
page.originalRoute = page.route;
|
|
59
|
+
this.addPage(_objectSpread(_objectSpread({}, page), {}, {
|
|
60
|
+
isTabBar
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getMatchedPage(pathname) {
|
|
65
|
+
this.currentRoute = pathname;
|
|
66
|
+
return this.matchPageByPathname(pathname);
|
|
67
|
+
}
|
|
68
|
+
addPage(page) {
|
|
69
|
+
this.$entityMap.push(page);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/lib/history/index.js
CHANGED
|
@@ -1,86 +1,50 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import "core-js/modules/es.object.to-string.js";
|
|
4
|
-
import "core-js/modules/es.promise.js";
|
|
5
1
|
import { createBrowserHistory } from 'history';
|
|
6
2
|
import React from 'react';
|
|
7
|
-
export
|
|
8
|
-
|
|
3
|
+
export let history;
|
|
4
|
+
let changeKey = '';
|
|
9
5
|
export function createHistory(options) {
|
|
10
|
-
|
|
6
|
+
const {
|
|
7
|
+
scheduler
|
|
8
|
+
} = options;
|
|
11
9
|
history = createBrowserHistory(options);
|
|
12
|
-
history.listen(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
page = _context.sent;
|
|
47
|
-
options.onChange(page, {
|
|
48
|
-
page: matchedPage
|
|
49
|
-
});
|
|
50
|
-
_context.next = 16;
|
|
51
|
-
break;
|
|
52
|
-
|
|
53
|
-
case 13:
|
|
54
|
-
console.warn('Not match any route!'); // 兜底 404 页面
|
|
55
|
-
|
|
56
|
-
NotFound = function () {
|
|
57
|
-
return /*#__PURE__*/React.createElement('div', null, 'Page Not Found');
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
options.onChange(NotFound, {
|
|
61
|
-
page: {
|
|
62
|
-
pathname: pathname,
|
|
63
|
-
route: '*',
|
|
64
|
-
path: '*',
|
|
65
|
-
config: {},
|
|
66
|
-
params: {},
|
|
67
|
-
component: function component() {
|
|
68
|
-
return Promise.resolve(NotFound);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
case 16:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
10
|
+
history.listen(async historyLocation => {
|
|
11
|
+
const {
|
|
12
|
+
key,
|
|
13
|
+
pathname
|
|
14
|
+
} = historyLocation;
|
|
15
|
+
if (key && key === changeKey) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
changeKey = key;
|
|
19
|
+
let matchedPage = scheduler.getMatchedPage(pathname);
|
|
20
|
+
if (!matchedPage) {
|
|
21
|
+
// 兜底通配页面
|
|
22
|
+
matchedPage = scheduler.getMatchedPage('*');
|
|
23
|
+
}
|
|
24
|
+
if (matchedPage) {
|
|
25
|
+
const page = await matchedPage.component();
|
|
26
|
+
options.onChange(page, {
|
|
27
|
+
page: matchedPage
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
console.warn('Not match any route!');
|
|
31
|
+
// 兜底 404 页面
|
|
32
|
+
const NotFound = function () {
|
|
33
|
+
return /*#__PURE__*/React.createElement('div', null, 'Page Not Found');
|
|
34
|
+
};
|
|
35
|
+
options.onChange(NotFound, {
|
|
36
|
+
page: {
|
|
37
|
+
pathname: pathname,
|
|
38
|
+
route: '*',
|
|
39
|
+
path: '*',
|
|
40
|
+
config: {},
|
|
41
|
+
params: {},
|
|
42
|
+
component: () => {
|
|
43
|
+
return Promise.resolve(NotFound);
|
|
76
44
|
}
|
|
77
45
|
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return function () {
|
|
82
|
-
return _ref.apply(this, arguments);
|
|
83
|
-
};
|
|
84
|
-
}());
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
85
49
|
return history;
|
|
86
50
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
2
|
-
import "core-js/modules/es.string.search.js";
|
|
3
|
-
import "core-js/modules/es.string.replace.js";
|
|
4
1
|
import { createHistory } from './history';
|
|
5
2
|
import { Router } from './Router';
|
|
6
3
|
import { RouterScheduler } from './RouterScheduler';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
scheduler
|
|
4
|
+
const scheduler = window.__ray__routerScheduler__ = new RouterScheduler();
|
|
5
|
+
const router = window.__ray__router__ = new Router({
|
|
6
|
+
scheduler
|
|
10
7
|
});
|
|
11
8
|
export function createRouter(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
const {
|
|
10
|
+
basename,
|
|
11
|
+
onChange,
|
|
12
|
+
routes,
|
|
13
|
+
tabBar,
|
|
14
|
+
pages
|
|
15
|
+
} = options;
|
|
16
|
+
const history = createHistory({
|
|
17
|
+
basename,
|
|
18
|
+
scheduler,
|
|
19
|
+
onChange: function () {
|
|
21
20
|
router.$href = window.location.href;
|
|
22
|
-
|
|
23
|
-
_onChange.apply(void 0, arguments);
|
|
21
|
+
onChange(...arguments);
|
|
24
22
|
}
|
|
25
|
-
});
|
|
23
|
+
});
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
// 设置路由基准路径
|
|
26
|
+
router.scheduler.basename = basename || '/';
|
|
28
27
|
|
|
28
|
+
// 调度器注册页面
|
|
29
29
|
router.scheduler.registryPages({
|
|
30
|
-
routes
|
|
31
|
-
tabBar
|
|
32
|
-
pages
|
|
30
|
+
routes,
|
|
31
|
+
tabBar,
|
|
32
|
+
pages
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const {
|
|
35
|
+
pathname,
|
|
36
|
+
search,
|
|
37
|
+
hash
|
|
38
|
+
} = history.location;
|
|
39
|
+
// 首次触发 history change
|
|
39
40
|
history.replace(pathname + search + hash);
|
|
40
41
|
return router;
|
|
41
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/router",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.23",
|
|
4
4
|
"description": "Ray Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ray"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@ray-js/library": "1.3.
|
|
24
|
-
"@ray-js/types": "1.3.
|
|
23
|
+
"@ray-js/library": "1.3.23",
|
|
24
|
+
"@ray-js/types": "1.3.23",
|
|
25
25
|
"history": "4.x"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@ray-js/cli": "1.3.
|
|
28
|
+
"@ray-js/cli": "1.3.23",
|
|
29
29
|
"@types/history": "^4.7.9"
|
|
30
30
|
},
|
|
31
31
|
"maintainers": [
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"email": "tuyafe@tuya.com"
|
|
35
35
|
}
|
|
36
36
|
],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "04708bb394d817a7a522fcde178f19f170d5d364",
|
|
38
38
|
"repository": {}
|
|
39
39
|
}
|