@tarojs/router 4.0.0-beta.75 → 4.0.0-beta.77
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 +1 -8
- package/dist/api.d.ts +6 -7
- package/dist/api.js +3 -16
- package/dist/events/resize.d.ts +2 -3
- package/dist/events/scroll.d.ts +2 -3
- package/dist/history.d.ts +10 -8
- package/dist/index.cjs.js +59 -56
- package/dist/index.d.ts +9 -10
- package/dist/index.esm.js +57 -54
- package/dist/navigationBar.d.ts +2 -3
- package/dist/router/index.d.ts +3 -4
- package/dist/router/index.js +3 -2
- package/dist/router/mpa.d.ts +4 -5
- package/dist/router/mpa.js +2 -2
- package/dist/router/multi-page.d.ts +7 -8
- package/dist/router/navigation-bar.d.ts +3 -3
- package/dist/router/navigation-bar.js +6 -6
- package/dist/router/page.d.ts +11 -10
- package/dist/router/page.js +26 -14
- package/dist/router/spa.d.ts +4 -5
- package/dist/router/spa.js +12 -11
- package/dist/router/stack.d.ts +2 -2
- package/dist/style.d.ts +4 -5
- package/dist/style.js +6 -4
- package/dist/tabbar.d.ts +2 -3
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/navigate.d.ts +6 -7
- package/package.json +18 -29
- package/dist/index.cjs.d.ts +0 -66
- package/dist/index.esm.d.ts +0 -66
package/LICENSE
CHANGED
|
@@ -154,15 +154,8 @@ See `/LICENSE` for details of the license.
|
|
|
154
154
|
|
|
155
155
|
==================
|
|
156
156
|
|
|
157
|
-
MIT (stencil-vue2-output-target):
|
|
158
|
-
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
|
-
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
|
-
See `/LICENSE` for details of the license.
|
|
161
|
-
|
|
162
|
-
==================
|
|
163
|
-
|
|
164
157
|
MIT (weui):
|
|
165
|
-
The following files embed [
|
|
158
|
+
The following files embed [weui](https://github.com/Tencent/weui) MIT:
|
|
166
159
|
`/packages/taro-components/src/components/*.scss`
|
|
167
160
|
See `/LICENSE.txt` for details of the license.
|
|
168
161
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Taro from '@tarojs/taro';
|
|
2
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
3
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
4
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
5
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
6
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
7
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
8
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages };
|
|
2
|
+
export declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
3
|
+
export declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
4
|
+
export declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
5
|
+
export declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
6
|
+
export declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
7
|
+
export declare function getCurrentPages(): Taro.Page[];
|
package/dist/api.js
CHANGED
|
@@ -16,13 +16,14 @@ function processNavigateUrl(option) {
|
|
|
16
16
|
const parts = routesAlias.getOrigin(history.location.pathname).split('/');
|
|
17
17
|
parts.pop();
|
|
18
18
|
pathPieces.pathname.split('/').forEach((item) => {
|
|
19
|
-
if (item === '.')
|
|
19
|
+
if (item === '.')
|
|
20
20
|
return;
|
|
21
|
-
}
|
|
22
21
|
item === '..' ? parts.pop() : parts.push(item);
|
|
23
22
|
});
|
|
24
23
|
pathPieces.pathname = parts.join('/');
|
|
25
24
|
}
|
|
25
|
+
// 确保是 / 开头的路径
|
|
26
|
+
pathPieces.pathname = addLeadingSlash(pathPieces.pathname);
|
|
26
27
|
// 处理自定义路由
|
|
27
28
|
pathPieces.pathname = routesAlias.getAlias(addLeadingSlash(pathPieces.pathname));
|
|
28
29
|
// 处理 basename
|
|
@@ -52,20 +53,6 @@ function navigate(option, method) {
|
|
|
52
53
|
if ('url' in option) {
|
|
53
54
|
const pathPieces = processNavigateUrl(option);
|
|
54
55
|
const state = { timestamp: Date.now() };
|
|
55
|
-
if (pathPieces.pathname) {
|
|
56
|
-
const originPath = routesAlias.getOrigin(pathPieces.pathname);
|
|
57
|
-
if (!RouterConfig.isPage(addLeadingSlash(originPath)) && !RouterConfig.isPage(addLeadingSlash(pathPieces.pathname))) {
|
|
58
|
-
const res = { errMsg: `${method}:fail page ${originPath} is not found` };
|
|
59
|
-
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
60
|
-
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
61
|
-
if (fail || complete) {
|
|
62
|
-
return resolve(res);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return reject(res);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
56
|
if (method === 'navigateTo') {
|
|
70
57
|
history.push(pathPieces, state);
|
|
71
58
|
}
|
package/dist/events/resize.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
2
|
-
declare function bindPageResize(page: PageInstance): void;
|
|
3
|
-
export { bindPageResize };
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
|
+
export declare function bindPageResize(page: PageInstance): void;
|
package/dist/events/scroll.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
2
|
-
declare function bindPageScroll(page: PageInstance, scrollEl: HTMLElement | Window, distance?: number): void;
|
|
3
|
-
export { bindPageScroll };
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
|
+
export declare function bindPageScroll(page: PageInstance, scrollEl: HTMLElement | Window, distance?: number): void;
|
package/dist/history.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Action, createBrowserHistory, createHashHistory } from 'history';
|
|
2
|
+
import type { IH5RouterConfig } from '@tarojs/taro/types/compile';
|
|
3
|
+
import type { Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from 'history';
|
|
4
|
+
import type { StateEvent } from '../types/history';
|
|
5
|
+
export declare let history: History;
|
|
4
6
|
declare class MpaHistory implements History {
|
|
5
7
|
action: Action;
|
|
6
8
|
get location(): Location;
|
|
@@ -17,8 +19,8 @@ declare class MpaHistory implements History {
|
|
|
17
19
|
replaceState: globalThis.History['replaceState'];
|
|
18
20
|
eventState(action: Required<StateEvent>['action']): (data: any, unused: string, url?: string | URL | null) => any;
|
|
19
21
|
}
|
|
20
|
-
declare function setHistory(h: History, base?: string): void;
|
|
21
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
22
|
-
|
|
23
|
-
declare function
|
|
24
|
-
export
|
|
22
|
+
export declare function setHistory(h: History, base?: string): void;
|
|
23
|
+
export declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
24
|
+
export { createBrowserHistory, createHashHistory };
|
|
25
|
+
export declare function setHistoryMode(mode?: IH5RouterConfig['mode'], base?: string): void;
|
|
26
|
+
export declare function prependBasename(url?: string): string;
|
package/dist/index.cjs.js
CHANGED
|
@@ -15,7 +15,8 @@ var UniversalRouter = require('universal-router');
|
|
|
15
15
|
function loadAnimateStyle(ms = 300) {
|
|
16
16
|
const css = `
|
|
17
17
|
body {
|
|
18
|
-
|
|
18
|
+
/* 防止 iOS 页面滚动 */
|
|
19
|
+
overflow: hidden;
|
|
19
20
|
}
|
|
20
21
|
.taro_router > .taro_page {
|
|
21
22
|
position: absolute;
|
|
@@ -72,8 +73,9 @@ ${enableTabBar ? `
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
` : ''}
|
|
75
|
-
.taro_page_shade,
|
|
76
|
-
.
|
|
76
|
+
.taro_page_shade:has(+.taro_page_stationed),
|
|
77
|
+
.taro_page_shade.taro_tabbar_page,
|
|
78
|
+
.taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) {
|
|
77
79
|
display: none;
|
|
78
80
|
}
|
|
79
81
|
`;
|
|
@@ -141,7 +143,7 @@ function loadNavigationBarStyle() {
|
|
|
141
143
|
to {
|
|
142
144
|
transform: rotate(360deg);
|
|
143
145
|
}
|
|
144
|
-
}
|
|
146
|
+
}
|
|
145
147
|
|
|
146
148
|
.taro-navigation-bar-no-icon > .taro-navigation-bar-home {
|
|
147
149
|
display: none;
|
|
@@ -263,8 +265,9 @@ class RouterConfig {
|
|
|
263
265
|
return this.router.mode || 'hash';
|
|
264
266
|
}
|
|
265
267
|
static get customRoutes() { return this.router.customRoutes || {}; }
|
|
268
|
+
// 这个方法不考虑 basename 和 customRoutes,只判断原始的 url 是否在 pages 中
|
|
266
269
|
static isPage(url = '') {
|
|
267
|
-
return this.pages.findIndex(e =>
|
|
270
|
+
return this.pages.findIndex(e => runtime.addLeadingSlash(e) === url) !== -1;
|
|
268
271
|
}
|
|
269
272
|
}
|
|
270
273
|
|
|
@@ -533,13 +536,14 @@ function processNavigateUrl(option) {
|
|
|
533
536
|
const parts = routesAlias.getOrigin(exports.history.location.pathname).split('/');
|
|
534
537
|
parts.pop();
|
|
535
538
|
pathPieces.pathname.split('/').forEach((item) => {
|
|
536
|
-
if (item === '.')
|
|
539
|
+
if (item === '.')
|
|
537
540
|
return;
|
|
538
|
-
}
|
|
539
541
|
item === '..' ? parts.pop() : parts.push(item);
|
|
540
542
|
});
|
|
541
543
|
pathPieces.pathname = parts.join('/');
|
|
542
544
|
}
|
|
545
|
+
// 确保是 / 开头的路径
|
|
546
|
+
pathPieces.pathname = runtime.addLeadingSlash(pathPieces.pathname);
|
|
543
547
|
// 处理自定义路由
|
|
544
548
|
pathPieces.pathname = routesAlias.getAlias(runtime.addLeadingSlash(pathPieces.pathname));
|
|
545
549
|
// 处理 basename
|
|
@@ -569,20 +573,6 @@ function navigate(option, method) {
|
|
|
569
573
|
if ('url' in option) {
|
|
570
574
|
const pathPieces = processNavigateUrl(option);
|
|
571
575
|
const state = { timestamp: Date.now() };
|
|
572
|
-
if (pathPieces.pathname) {
|
|
573
|
-
const originPath = routesAlias.getOrigin(pathPieces.pathname);
|
|
574
|
-
if (!RouterConfig.isPage(runtime.addLeadingSlash(originPath)) && !RouterConfig.isPage(runtime.addLeadingSlash(pathPieces.pathname))) {
|
|
575
|
-
const res = { errMsg: `${method}:fail page ${originPath} is not found` };
|
|
576
|
-
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
577
|
-
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
578
|
-
if (fail || complete) {
|
|
579
|
-
return resolve(res);
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
return reject(res);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
576
|
if (method === 'navigateTo') {
|
|
587
577
|
exports.history.push(pathPieces, state);
|
|
588
578
|
}
|
|
@@ -853,8 +843,8 @@ const launchStampId$1 = createStampId$1();
|
|
|
853
843
|
* - 不支持路由动画
|
|
854
844
|
*/
|
|
855
845
|
function createMultiRouter(history, app, config, framework) {
|
|
856
|
-
var _a, _b, _c, _d, _e, _f;
|
|
857
846
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
847
|
+
var _a, _b, _c, _d, _e, _f;
|
|
858
848
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
859
849
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
860
850
|
}
|
|
@@ -862,7 +852,7 @@ function createMultiRouter(history, app, config, framework) {
|
|
|
862
852
|
RouterConfig.config = config;
|
|
863
853
|
const handler = new MultiPageHandler(config, history);
|
|
864
854
|
const launchParam = {
|
|
865
|
-
path: config.pageName,
|
|
855
|
+
path: config.pageName, // 多页面模式没新开一个页面相当于重启,所以直接使用当前页面路径
|
|
866
856
|
query: handler.getQuery(launchStampId$1),
|
|
867
857
|
scene: 0,
|
|
868
858
|
shareTicket: '',
|
|
@@ -941,7 +931,7 @@ class NavigationBarHandler {
|
|
|
941
931
|
});
|
|
942
932
|
}
|
|
943
933
|
toHomeFn() {
|
|
944
|
-
reLaunch({ url: this.pageContext.
|
|
934
|
+
reLaunch({ url: this.pageContext.originHomePage });
|
|
945
935
|
}
|
|
946
936
|
backFn() {
|
|
947
937
|
navigateBack();
|
|
@@ -990,7 +980,7 @@ class NavigationBarHandler {
|
|
|
990
980
|
this.setNavigationLoading();
|
|
991
981
|
}
|
|
992
982
|
setCacheValue() {
|
|
993
|
-
const currentPage = this.pageContext.
|
|
983
|
+
const currentPage = this.pageContext.originPathname;
|
|
994
984
|
if (typeof this.cache[currentPage] !== 'object') {
|
|
995
985
|
this.cache[currentPage] = {};
|
|
996
986
|
}
|
|
@@ -1021,7 +1011,7 @@ class NavigationBarHandler {
|
|
|
1021
1011
|
var _a;
|
|
1022
1012
|
if (!this.navigationBarElement)
|
|
1023
1013
|
return;
|
|
1024
|
-
const currentPage = this.pageContext.
|
|
1014
|
+
const currentPage = this.pageContext.originPathname;
|
|
1025
1015
|
let isShow;
|
|
1026
1016
|
if (typeof show === 'boolean') {
|
|
1027
1017
|
isShow = show;
|
|
@@ -1046,7 +1036,7 @@ class NavigationBarHandler {
|
|
|
1046
1036
|
var _a, _b, _c;
|
|
1047
1037
|
if (!this.navigationBarElement)
|
|
1048
1038
|
return;
|
|
1049
|
-
const currentPage = this.pageContext.
|
|
1039
|
+
const currentPage = this.pageContext.originPathname;
|
|
1050
1040
|
let color;
|
|
1051
1041
|
if (typeof backgroundColor === 'string') {
|
|
1052
1042
|
color = backgroundColor;
|
|
@@ -1070,7 +1060,7 @@ class NavigationBarHandler {
|
|
|
1070
1060
|
var _a, _b, _c;
|
|
1071
1061
|
if (!this.navigationBarElement)
|
|
1072
1062
|
return;
|
|
1073
|
-
const currentPage = this.pageContext.
|
|
1063
|
+
const currentPage = this.pageContext.originPathname;
|
|
1074
1064
|
let color;
|
|
1075
1065
|
if (typeof fontColor === 'string') {
|
|
1076
1066
|
color = fontColor;
|
|
@@ -1092,7 +1082,7 @@ class NavigationBarHandler {
|
|
|
1092
1082
|
}
|
|
1093
1083
|
setTitle(title) {
|
|
1094
1084
|
var _a, _b, _c;
|
|
1095
|
-
const currentPage = this.pageContext.
|
|
1085
|
+
const currentPage = this.pageContext.originPathname;
|
|
1096
1086
|
let proceedTitle;
|
|
1097
1087
|
if (typeof title === 'string') {
|
|
1098
1088
|
proceedTitle = title;
|
|
@@ -1173,6 +1163,7 @@ class PageHandler {
|
|
|
1173
1163
|
this.defaultAnimation = { duration: 300, delay: 50 };
|
|
1174
1164
|
this.config = config;
|
|
1175
1165
|
this.homePage = runtime.getHomePage(this.routes[0].path, this.basename, this.customRoutes, this.config.entryPagePath);
|
|
1166
|
+
this.originHomePage = this.config.entryPagePath || this.routes[0].path || this.basename;
|
|
1176
1167
|
this.mount();
|
|
1177
1168
|
this.navigationBarHandler = new NavigationBarHandler(this);
|
|
1178
1169
|
}
|
|
@@ -1206,14 +1197,14 @@ class PageHandler {
|
|
|
1206
1197
|
}
|
|
1207
1198
|
set pathname(p) { this.router.pathname = p; }
|
|
1208
1199
|
get pathname() { return this.router.pathname; }
|
|
1200
|
+
// Note: 把 pathname 转换为原始路径,主要是处理 customRoutes 和 basename
|
|
1201
|
+
get originPathname() { return routesAlias.getOrigin(runtime.addLeadingSlash(runtime.stripBasename(this.pathname, this.basename))); }
|
|
1209
1202
|
get basename() { return this.router.basename || ''; }
|
|
1210
1203
|
get pageConfig() {
|
|
1211
|
-
const routePath = runtime.addLeadingSlash(runtime.stripBasename(this.pathname, this.basename));
|
|
1212
1204
|
const homePage = runtime.addLeadingSlash(this.homePage);
|
|
1213
1205
|
return this.routes.find(r => {
|
|
1214
|
-
var _a;
|
|
1215
1206
|
const pagePath = runtime.addLeadingSlash(r.path);
|
|
1216
|
-
return [pagePath, homePage].includes(
|
|
1207
|
+
return [pagePath, homePage].includes(this.originPathname);
|
|
1217
1208
|
});
|
|
1218
1209
|
}
|
|
1219
1210
|
isTabBar(pathname) {
|
|
@@ -1403,24 +1394,35 @@ class PageHandler {
|
|
|
1403
1394
|
});
|
|
1404
1395
|
}
|
|
1405
1396
|
}
|
|
1406
|
-
hide(page) {
|
|
1407
|
-
var _a;
|
|
1397
|
+
hide(page, animation = false) {
|
|
1398
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1408
1399
|
if (!page)
|
|
1409
1400
|
return;
|
|
1410
1401
|
// NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
|
|
1411
1402
|
const pageEl = this.getPageContainer(page);
|
|
1412
1403
|
if (pageEl) {
|
|
1413
|
-
if (
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1404
|
+
if (animation) {
|
|
1405
|
+
if (this.hideTimer) {
|
|
1406
|
+
clearTimeout(this.hideTimer);
|
|
1407
|
+
this.hideTimer = null;
|
|
1408
|
+
(_c = (_b = (_a = this.lastHidePage) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add) === null || _c === void 0 ? void 0 : _c.call(_b, 'taro_page_shade');
|
|
1409
|
+
}
|
|
1410
|
+
this.lastHidePage = pageEl;
|
|
1411
|
+
this.hideTimer = setTimeout(() => {
|
|
1412
|
+
this.hideTimer = null;
|
|
1413
|
+
pageEl.classList.add('taro_page_shade');
|
|
1414
|
+
}, this.animationDuration + this.animationDelay);
|
|
1415
|
+
(_d = page.onHide) === null || _d === void 0 ? void 0 : _d.call(page);
|
|
1417
1416
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1417
|
+
else {
|
|
1418
|
+
if (this.hideTimer) {
|
|
1419
|
+
clearTimeout(this.hideTimer);
|
|
1420
|
+
this.hideTimer = null;
|
|
1421
|
+
(_g = (_f = (_e = this.lastHidePage) === null || _e === void 0 ? void 0 : _e.classList) === null || _f === void 0 ? void 0 : _f.add) === null || _g === void 0 ? void 0 : _g.call(_f, 'taro_page_shade');
|
|
1422
|
+
}
|
|
1421
1423
|
pageEl.classList.add('taro_page_shade');
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
+
this.lastHidePage = pageEl;
|
|
1425
|
+
}
|
|
1424
1426
|
}
|
|
1425
1427
|
else {
|
|
1426
1428
|
setTimeout(() => this.hide(page), 0);
|
|
@@ -1512,10 +1514,10 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1512
1514
|
runtime.eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
1513
1515
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
1514
1516
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
1515
|
-
const render = (
|
|
1516
|
-
var
|
|
1517
|
+
const render = (_c) => tslib.__awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
1518
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1517
1519
|
handler.pathname = decodeURI(location.pathname);
|
|
1518
|
-
if ((
|
|
1520
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
1519
1521
|
window.scrollTo(0, 0);
|
|
1520
1522
|
runtime.eventCenter.trigger('__taroRouterChange', {
|
|
1521
1523
|
toLocation: {
|
|
@@ -1534,7 +1536,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1534
1536
|
path: handler.pathname,
|
|
1535
1537
|
query: handler.getQuery(createStampId()),
|
|
1536
1538
|
};
|
|
1537
|
-
(
|
|
1539
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
1538
1540
|
runtime.eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
1539
1541
|
}
|
|
1540
1542
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -1548,10 +1550,10 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1548
1550
|
if (!element)
|
|
1549
1551
|
return;
|
|
1550
1552
|
const pageConfig = handler.pageConfig;
|
|
1551
|
-
let enablePullDownRefresh = ((
|
|
1552
|
-
let navigationStyle = ((
|
|
1553
|
-
let navigationBarTextStyle = ((
|
|
1554
|
-
let navigationBarBackgroundColor = ((
|
|
1553
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
1554
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
1555
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
1556
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
1555
1557
|
if (pageConfig) {
|
|
1556
1558
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
1557
1559
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
@@ -1569,7 +1571,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1569
1571
|
runtime.eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
1570
1572
|
const currentPage = runtime.Current.page;
|
|
1571
1573
|
const pathname = handler.pathname;
|
|
1572
|
-
const methodName = (
|
|
1574
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
1573
1575
|
const cacheTabs = stacks.getTabs();
|
|
1574
1576
|
let shouldLoad = false;
|
|
1575
1577
|
stacks.method = '';
|
|
@@ -1588,6 +1590,7 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1588
1590
|
if (handler.isSamePage(currentPage))
|
|
1589
1591
|
return;
|
|
1590
1592
|
if (handler.isTabBar(currentPage.path)) {
|
|
1593
|
+
// NOTE: 从 tabBar 页面切换到 tabBar 页面
|
|
1591
1594
|
handler.hide(currentPage);
|
|
1592
1595
|
stacks.pushTab(currentPage.path.split('?')[0]);
|
|
1593
1596
|
}
|
|
@@ -1631,11 +1634,11 @@ function createRouter(history$1, app, config, framework) {
|
|
|
1631
1634
|
shouldLoad = true;
|
|
1632
1635
|
}
|
|
1633
1636
|
else if (action === 'PUSH') {
|
|
1634
|
-
handler.hide(currentPage);
|
|
1637
|
+
handler.hide(currentPage, true);
|
|
1635
1638
|
shouldLoad = true;
|
|
1636
1639
|
}
|
|
1637
1640
|
if (shouldLoad || stacks.length < 1) {
|
|
1638
|
-
const el = (
|
|
1641
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
1639
1642
|
const loadConfig = Object.assign({}, pageConfig);
|
|
1640
1643
|
const stacksIndex = stacks.length;
|
|
1641
1644
|
delete loadConfig['path'];
|
|
@@ -1724,11 +1727,11 @@ function handleAppMountWithTabbar(config, history, appId = config.appId || 'app'
|
|
|
1724
1727
|
initNavigationBar(config, container);
|
|
1725
1728
|
}
|
|
1726
1729
|
|
|
1727
|
-
Object.defineProperty(exports,
|
|
1730
|
+
Object.defineProperty(exports, "createBrowserHistory", {
|
|
1728
1731
|
enumerable: true,
|
|
1729
1732
|
get: function () { return history.createBrowserHistory; }
|
|
1730
1733
|
});
|
|
1731
|
-
Object.defineProperty(exports,
|
|
1734
|
+
Object.defineProperty(exports, "createHashHistory", {
|
|
1732
1735
|
enumerable: true,
|
|
1733
1736
|
get: function () { return history.createHashHistory; }
|
|
1734
1737
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { History } from
|
|
2
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export { handleAppMount, handleAppMountWithTabbar };
|
|
1
|
+
import type { History } from 'history';
|
|
2
|
+
import type { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
3
|
+
export * from './api';
|
|
4
|
+
export * from './history';
|
|
5
|
+
export { createMultiRouter } from './router/mpa';
|
|
6
|
+
export { createRouter } from './router/spa';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
export declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
9
|
+
export declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|