@ray-js/router 0.4.12 → 0.4.15-beta-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.js +55 -124
- package/lib/RouterScheduler.js +64 -128
- package/lib/history/index.js +48 -81
- package/lib/index.js +21 -39
- package/package.json +5 -5
package/lib/Router.js
CHANGED
|
@@ -1,135 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
9
10
|
import { url } from '@ray-js/library';
|
|
10
11
|
import { history } from './history';
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var to, _url$parse, pathname, search, hash;
|
|
30
|
-
|
|
31
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
32
|
-
while (1) {
|
|
33
|
-
switch (_context.prev = _context.next) {
|
|
34
|
-
case 0:
|
|
35
|
-
to = params.to; // FIXME: 绝对路径是否需要支持?
|
|
36
|
-
|
|
37
|
-
if (!(to.startsWith('//') || to.startsWith('http'))) {
|
|
38
|
-
_context.next = 3;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return _context.abrupt("return", {
|
|
43
|
-
to: to
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
case 3:
|
|
47
|
-
if (this.scheduler.basename) {
|
|
48
|
-
to = this.scheduler.basename + to;
|
|
49
|
-
} // TODO: Web 应用下重复进入一个路由
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (this.$href) {
|
|
53
|
-
_url$parse = url.parse(this.$href), pathname = _url$parse.pathname, search = _url$parse.search, hash = _url$parse.hash;
|
|
54
|
-
|
|
55
|
-
if (url.format({
|
|
56
|
-
pathname: pathname,
|
|
57
|
-
search: search,
|
|
58
|
-
hash: hash
|
|
59
|
-
}) === to) {
|
|
12
|
+
export class Router {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.scheduler = options.scheduler;
|
|
15
|
+
}
|
|
16
|
+
normalizeRoute(params) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
let { to } = params;
|
|
19
|
+
// FIXME: 绝对路径是否需要支持?
|
|
20
|
+
if (to.startsWith('//') || to.startsWith('http')) {
|
|
21
|
+
return { to };
|
|
22
|
+
}
|
|
23
|
+
if (this.scheduler.basename) {
|
|
24
|
+
to = this.scheduler.basename + to;
|
|
25
|
+
}
|
|
26
|
+
// TODO: Web 应用下重复进入一个路由
|
|
27
|
+
if (this.$href) {
|
|
28
|
+
const { pathname, search, hash } = url.parse(this.$href);
|
|
29
|
+
if (url.format({ pathname, search, hash }) === to) {
|
|
60
30
|
console.warn('duplicate route to:', to);
|
|
61
|
-
}
|
|
62
31
|
}
|
|
63
|
-
|
|
64
|
-
return _context.abrupt("return", {
|
|
65
|
-
to: to
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
case 6:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
32
|
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
function normalizeRoute() {
|
|
77
|
-
return _normalizeRoute.apply(this, arguments);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return normalizeRoute;
|
|
81
|
-
}()
|
|
82
|
-
}, {
|
|
83
|
-
key: "push",
|
|
84
|
-
value: function push(to) {
|
|
85
|
-
this.normalizeRoute({
|
|
86
|
-
to: to
|
|
87
|
-
}).then(function (_ref) {
|
|
88
|
-
var to = _ref.to;
|
|
89
|
-
history.push(to);
|
|
90
|
-
});
|
|
33
|
+
return { to };
|
|
34
|
+
});
|
|
91
35
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
36
|
+
push(to) {
|
|
37
|
+
this.normalizeRoute({ to }).then(({ to }) => {
|
|
38
|
+
history.push(to);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
replace(to) {
|
|
42
|
+
this.normalizeRoute({ to }).then(({ to }) => {
|
|
43
|
+
history.replace(to);
|
|
44
|
+
});
|
|
101
45
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// 在应用堆栈内进行跳转
|
|
106
|
-
history.go(delta);
|
|
46
|
+
go(delta) {
|
|
47
|
+
// 在应用堆栈内进行跳转
|
|
48
|
+
history.go(delta);
|
|
107
49
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
value: function back() {
|
|
111
|
-
history.goBack();
|
|
50
|
+
back() {
|
|
51
|
+
history.goBack();
|
|
112
52
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
window.location.reload();
|
|
125
|
-
}
|
|
53
|
+
reload(to) {
|
|
54
|
+
if (to) {
|
|
55
|
+
this.normalizeRoute({ to }).then(({ to }) => {
|
|
56
|
+
window.location.href = to;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
window.location.reload();
|
|
61
|
+
}
|
|
126
62
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
get: function get() {
|
|
130
|
-
return window.location.href;
|
|
63
|
+
get hostHref() {
|
|
64
|
+
return window.location.href;
|
|
131
65
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return Router;
|
|
135
|
-
}();
|
|
66
|
+
}
|
package/lib/RouterScheduler.js
CHANGED
|
@@ -1,145 +1,81 @@
|
|
|
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.array.splice.js";
|
|
10
|
-
import "core-js/modules/es.array.index-of.js";
|
|
11
|
-
import "core-js/modules/es.object.to-string.js";
|
|
12
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
13
1
|
import { RouterScheduler as IRouterScheduler } from '@ray-js/types';
|
|
14
|
-
|
|
15
2
|
/**
|
|
16
3
|
* web 环境下的路由协调器
|
|
17
4
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_classCallCheck(this, RouterScheduler);
|
|
27
|
-
|
|
28
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
|
-
args[_key] = arguments[_key];
|
|
5
|
+
export class RouterScheduler extends IRouterScheduler {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.$currentRoute = '';
|
|
9
|
+
this.$listeners = {};
|
|
10
|
+
this.$entityMap = {};
|
|
11
|
+
this.basename = '';
|
|
30
12
|
}
|
|
31
|
-
|
|
32
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
|
-
|
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "$currentRoute", '');
|
|
35
|
-
|
|
36
|
-
_defineProperty(_assertThisInitialized(_this), "$listeners", {});
|
|
37
|
-
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "$entityMap", {});
|
|
39
|
-
|
|
40
|
-
_defineProperty(_assertThisInitialized(_this), "basename", '');
|
|
41
|
-
|
|
42
|
-
return _this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_createClass(RouterScheduler, [{
|
|
46
|
-
key: "currentRoute",
|
|
47
|
-
get:
|
|
48
13
|
/**
|
|
49
14
|
* 当前调度器的 route 地址
|
|
50
15
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
set: function set(val) {
|
|
55
|
-
if (val !== this.currentRoute) {
|
|
56
|
-
this.$currentRoute = val;
|
|
57
|
-
this.emit('routeChange', this.currentRoute);
|
|
58
|
-
}
|
|
16
|
+
get currentRoute() {
|
|
17
|
+
return this.$currentRoute;
|
|
59
18
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
events
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fns.forEach(function (fn) {
|
|
85
|
-
fn.apply(void 0, args);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
19
|
+
set currentRoute(val) {
|
|
20
|
+
if (val !== this.currentRoute) {
|
|
21
|
+
this.$currentRoute = val;
|
|
22
|
+
this.emit('routeChange', this.currentRoute);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
on(event, fn) {
|
|
26
|
+
if (!this.$listeners[event]) {
|
|
27
|
+
this.$listeners[event] = [];
|
|
28
|
+
}
|
|
29
|
+
const events = this.$listeners[event];
|
|
30
|
+
events.push(fn);
|
|
31
|
+
return () => {
|
|
32
|
+
events.splice(events.indexOf(fn), 1);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// 给 TabBar 监听,用于处理当前高亮状态
|
|
36
|
+
emit(event, ...args) {
|
|
37
|
+
const fns = this.$listeners[event];
|
|
38
|
+
if (Array.isArray(fns)) {
|
|
39
|
+
fns.forEach((fn) => {
|
|
40
|
+
fn(...args);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
88
43
|
}
|
|
89
44
|
/**
|
|
90
45
|
* 初始化路由,注册应用声明的路由,并处理映射关系
|
|
91
46
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return false;
|
|
47
|
+
registryPages(params) {
|
|
48
|
+
const { pages, tabBar } = params;
|
|
49
|
+
const tabBarList = tabBar.list || [];
|
|
50
|
+
pages.forEach((page) => {
|
|
51
|
+
const isTabBar = tabBarList.some((item) => {
|
|
52
|
+
if (item.route) {
|
|
53
|
+
return page.route === item.route;
|
|
54
|
+
}
|
|
55
|
+
else if (item.id) {
|
|
56
|
+
return page.id === item.id;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
});
|
|
60
|
+
page.route = this.basename + page.route;
|
|
61
|
+
page.originalRoute = page.route;
|
|
62
|
+
this.addPage(Object.assign(Object.assign({}, page), { isTabBar }));
|
|
110
63
|
});
|
|
111
|
-
page.route = _this2.basename + page.route;
|
|
112
|
-
page.originalRoute = page.route;
|
|
113
|
-
|
|
114
|
-
_this2.addPage(_objectSpread(_objectSpread({}, page), {}, {
|
|
115
|
-
isTabBar: isTabBar
|
|
116
|
-
}));
|
|
117
|
-
});
|
|
118
64
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.currentRoute = pathname;
|
|
129
|
-
return this.matchPageByPathname(pathname);
|
|
65
|
+
getMatchedPage(pathname) {
|
|
66
|
+
// 适配 `domain.com/basename/` & `domain.com/basename`
|
|
67
|
+
// 注册首页使用的是 `/` 需预处理
|
|
68
|
+
if (this.basename === pathname) {
|
|
69
|
+
pathname = pathname + '/';
|
|
70
|
+
}
|
|
71
|
+
this.currentRoute = pathname;
|
|
72
|
+
return this.matchPageByPathname(pathname);
|
|
130
73
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.$entityMap[depth] = [];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this.$entityMap[depth].push(page);
|
|
74
|
+
addPage(page) {
|
|
75
|
+
const depth = this.slashDepth(page.route);
|
|
76
|
+
if (!this.$entityMap[depth]) {
|
|
77
|
+
this.$entityMap[depth] = [];
|
|
78
|
+
}
|
|
79
|
+
this.$entityMap[depth].push(page);
|
|
141
80
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return RouterScheduler;
|
|
145
|
-
}(IRouterScheduler);
|
|
81
|
+
}
|
package/lib/history/index.js
CHANGED
|
@@ -1,87 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
5
10
|
import { createBrowserHistory } from 'history';
|
|
6
11
|
import React from 'react';
|
|
7
|
-
export
|
|
8
|
-
|
|
12
|
+
export let history;
|
|
13
|
+
let changeKey = '';
|
|
9
14
|
export function createHistory(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
matchedPage = scheduler.getMatchedPage('*');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!matchedPage) {
|
|
38
|
-
_context.next = 13;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
_context.next = 9;
|
|
43
|
-
return matchedPage.component();
|
|
44
|
-
|
|
45
|
-
case 9:
|
|
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, {
|
|
15
|
+
const { scheduler } = options;
|
|
16
|
+
history = createBrowserHistory(options);
|
|
17
|
+
history.listen((historyLocation) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { key, pathname } = historyLocation;
|
|
19
|
+
if (key && key === changeKey) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
changeKey = key;
|
|
23
|
+
let matchedPage = scheduler.getMatchedPage(pathname);
|
|
24
|
+
if (!matchedPage) {
|
|
25
|
+
// 兜底通配页面
|
|
26
|
+
matchedPage = scheduler.getMatchedPage('*');
|
|
27
|
+
}
|
|
28
|
+
if (matchedPage) {
|
|
29
|
+
const page = yield matchedPage.component();
|
|
30
|
+
options.onChange(page, { page: matchedPage });
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.warn('Not match any route!');
|
|
34
|
+
// 兜底 404 页面
|
|
35
|
+
const NotFound = function NotFound() {
|
|
36
|
+
return React.createElement('div', null, 'Page Not Found');
|
|
37
|
+
};
|
|
38
|
+
options.onChange(NotFound, {
|
|
61
39
|
page: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
case 16:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
40
|
+
id: pathname,
|
|
41
|
+
pathname: pathname,
|
|
42
|
+
route: '*',
|
|
43
|
+
path: '*',
|
|
44
|
+
config: {},
|
|
45
|
+
params: {},
|
|
46
|
+
component: () => {
|
|
47
|
+
return Promise.resolve(NotFound);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
78
51
|
}
|
|
79
|
-
}, _callee);
|
|
80
52
|
}));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return _ref.apply(this, arguments);
|
|
84
|
-
};
|
|
85
|
-
}());
|
|
86
|
-
return history;
|
|
87
|
-
}
|
|
53
|
+
return history;
|
|
54
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,45 +1,27 @@
|
|
|
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: scheduler
|
|
10
|
-
});
|
|
4
|
+
const scheduler = (window.__ray__routerScheduler__ = new RouterScheduler());
|
|
5
|
+
const router = (window.__ray__router__ = new Router({ scheduler }));
|
|
11
6
|
export function createRouter(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const { basename, onChange, routes, tabBar, pages } = options;
|
|
8
|
+
const history = createHistory({
|
|
9
|
+
basename,
|
|
10
|
+
scheduler,
|
|
11
|
+
onChange: (...args) => {
|
|
12
|
+
router.$href = window.location.href;
|
|
13
|
+
onChange(...args);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
// 设置路由基准路径
|
|
17
|
+
if (basename) {
|
|
18
|
+
router.scheduler.basename = basename;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
router.scheduler.registryPages({
|
|
33
|
-
routes: routes,
|
|
34
|
-
tabBar: tabBar,
|
|
35
|
-
pages: pages
|
|
36
|
-
});
|
|
37
|
-
var _history$location = history.location,
|
|
38
|
-
pathname = _history$location.pathname,
|
|
39
|
-
search = _history$location.search,
|
|
40
|
-
hash = _history$location.hash; // 首次触发 history change
|
|
41
|
-
|
|
42
|
-
history.replace(pathname + search + hash);
|
|
43
|
-
return router;
|
|
20
|
+
// 调度器注册页面
|
|
21
|
+
router.scheduler.registryPages({ routes, tabBar, pages });
|
|
22
|
+
const { pathname, search, hash } = history.location;
|
|
23
|
+
// 首次触发 history change
|
|
24
|
+
history.replace(pathname + search + hash);
|
|
25
|
+
return router;
|
|
44
26
|
}
|
|
45
|
-
export default router;
|
|
27
|
+
export default router;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/router",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15-beta-0",
|
|
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": "^0.4.
|
|
24
|
-
"@ray-js/types": "^0.4.
|
|
23
|
+
"@ray-js/library": "^0.4.15-beta-0",
|
|
24
|
+
"@ray-js/types": "^0.4.15-beta-0",
|
|
25
25
|
"history": "4.x"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@ray-js/cli": "^0.4.
|
|
28
|
+
"@ray-js/cli": "^0.4.15-beta-0",
|
|
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": "c9b5b2e847299ecbd30c8b1feb2413045c139bf7",
|
|
38
38
|
"repository": {}
|
|
39
39
|
}
|