@tarojs/router 3.6.22-nightly.0 → 3.6.22
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/dist/index.cjs.js +44 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +44 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/router/multi-page.d.ts +1 -0
- package/dist/router/multi-page.js +12 -1
- package/dist/router/page.d.ts +1 -0
- package/dist/router/page.js +13 -2
- package/dist/router/spa.js +18 -5
- package/dist/style.d.ts +1 -0
- package/dist/style.js +1 -1
- package/dist/utils/navigate.d.ts +2 -4
- package/dist/utils/navigate.js +2 -16
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var history = require('history');
|
|
6
6
|
var runtime = require('@tarojs/runtime');
|
|
7
|
-
var MobileDetect = require('mobile-detect');
|
|
8
7
|
var queryString = require('query-string');
|
|
9
8
|
var components = require('@tarojs/components/dist/components');
|
|
10
9
|
var taro = require('@tarojs/taro');
|
|
@@ -12,7 +11,6 @@ var UniversalRouter = require('universal-router');
|
|
|
12
11
|
|
|
13
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
13
|
|
|
15
|
-
var MobileDetect__default = /*#__PURE__*/_interopDefaultLegacy(MobileDetect);
|
|
16
14
|
var queryString__default = /*#__PURE__*/_interopDefaultLegacy(queryString);
|
|
17
15
|
var UniversalRouter__default = /*#__PURE__*/_interopDefaultLegacy(UniversalRouter);
|
|
18
16
|
|
|
@@ -398,15 +396,9 @@ function getCurrentPages() {
|
|
|
398
396
|
return pages.map(e => { var _a; return (Object.assign(Object.assign({}, e), { route: ((_a = e.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) || '' })); });
|
|
399
397
|
}
|
|
400
398
|
|
|
401
|
-
let md;
|
|
402
399
|
let preTitle = document.title;
|
|
403
400
|
let isLoadDdEntry = false;
|
|
404
|
-
|
|
405
|
-
if (!md) {
|
|
406
|
-
md = new MobileDetect__default["default"](navigator.userAgent);
|
|
407
|
-
}
|
|
408
|
-
return md;
|
|
409
|
-
}
|
|
401
|
+
const isDingTalk = () => !!navigator.userAgent.match(/\bDingTalk\b/ig);
|
|
410
402
|
function setTitle(title) {
|
|
411
403
|
return __awaiter(this, void 0, void 0, function* () {
|
|
412
404
|
if (preTitle === title)
|
|
@@ -424,10 +416,6 @@ function setTitle(title) {
|
|
|
424
416
|
return title;
|
|
425
417
|
});
|
|
426
418
|
}
|
|
427
|
-
function isDingTalk() {
|
|
428
|
-
const md = getMobileDetect();
|
|
429
|
-
return md.match(/DingTalk/ig);
|
|
430
|
-
}
|
|
431
419
|
|
|
432
420
|
let pageResizeFn;
|
|
433
421
|
function bindPageResize(page) {
|
|
@@ -628,6 +616,14 @@ class MultiPageHandler {
|
|
|
628
616
|
: {};
|
|
629
617
|
return Object.assign(Object.assign({}, query), options);
|
|
630
618
|
}
|
|
619
|
+
isDefaultNavigationStyle() {
|
|
620
|
+
var _a, _b;
|
|
621
|
+
let style = (_a = this.config.window) === null || _a === void 0 ? void 0 : _a.navigationStyle;
|
|
622
|
+
if (typeof ((_b = this.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationStyle) === 'string') {
|
|
623
|
+
style = this.pageConfig.navigationStyle;
|
|
624
|
+
}
|
|
625
|
+
return style !== 'custom';
|
|
626
|
+
}
|
|
631
627
|
mount() {
|
|
632
628
|
setHistoryMode(this.routerMode, this.router.basename);
|
|
633
629
|
loadRouterStyle(this.usingWindowScroll);
|
|
@@ -690,10 +686,13 @@ class MultiPageHandler {
|
|
|
690
686
|
return;
|
|
691
687
|
(_a = page.onLoad) === null || _a === void 0 ? void 0 : _a.call(page, this.getQuery('', page.options), () => {
|
|
692
688
|
var _a;
|
|
689
|
+
const pageEl = this.getPageContainer(page);
|
|
693
690
|
if (this.isTabBar) {
|
|
694
|
-
const pageEl = this.getPageContainer(page);
|
|
695
691
|
pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_tabbar_page');
|
|
696
692
|
}
|
|
693
|
+
if (this.isDefaultNavigationStyle()) {
|
|
694
|
+
pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_navigation_page');
|
|
695
|
+
}
|
|
697
696
|
this.onReady(page, true);
|
|
698
697
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
699
698
|
this.bindPageEvents(page, pageConfig);
|
|
@@ -852,6 +851,14 @@ class PageHandler {
|
|
|
852
851
|
})) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
|
|
853
852
|
return !!pagePath && this.tabBarList.some(t => stripTrailing(t.pagePath) === pagePath);
|
|
854
853
|
}
|
|
854
|
+
isDefaultNavigationStyle() {
|
|
855
|
+
var _a, _b;
|
|
856
|
+
let style = (_a = this.config.window) === null || _a === void 0 ? void 0 : _a.navigationStyle;
|
|
857
|
+
if (typeof ((_b = this.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationStyle) === 'string') {
|
|
858
|
+
style = this.pageConfig.navigationStyle;
|
|
859
|
+
}
|
|
860
|
+
return style !== 'custom';
|
|
861
|
+
}
|
|
855
862
|
isSamePage(page) {
|
|
856
863
|
const routePath = stripBasename(this.pathname, this.basename);
|
|
857
864
|
const pagePath = stripBasename(page === null || page === void 0 ? void 0 : page.path, this.basename);
|
|
@@ -958,19 +965,22 @@ class PageHandler {
|
|
|
958
965
|
if (pageEl) {
|
|
959
966
|
pageEl.classList.remove('taro_page_shade');
|
|
960
967
|
this.isTabBar(this.pathname) && pageEl.classList.add('taro_tabbar_page');
|
|
968
|
+
this.isDefaultNavigationStyle() && pageEl.classList.add('taro_navigation_page');
|
|
961
969
|
this.addAnimation(pageEl, pageNo === 0);
|
|
962
970
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
963
971
|
this.bindPageEvents(page, pageConfig);
|
|
964
972
|
this.triggerRouterChange();
|
|
965
973
|
}
|
|
966
974
|
else {
|
|
975
|
+
// FIXME 在 iOS 端快速切换页面时,可能不会执行回调注入对应类名导致 TabBar 白屏
|
|
967
976
|
(_b = page.onLoad) === null || _b === void 0 ? void 0 : _b.call(page, param, () => {
|
|
968
977
|
var _a;
|
|
969
978
|
pageEl = this.getPageContainer(page);
|
|
970
979
|
this.isTabBar(this.pathname) && (pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_tabbar_page'));
|
|
980
|
+
this.isDefaultNavigationStyle() && (pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_navigation_page'));
|
|
971
981
|
this.addAnimation(pageEl, pageNo === 0);
|
|
972
|
-
this.onReady(page, true);
|
|
973
982
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
983
|
+
this.onReady(page, true);
|
|
974
984
|
this.bindPageEvents(page, pageConfig);
|
|
975
985
|
this.triggerRouterChange();
|
|
976
986
|
});
|
|
@@ -1032,8 +1042,8 @@ class PageHandler {
|
|
|
1032
1042
|
var _a;
|
|
1033
1043
|
pageEl = this.getPageContainer(page);
|
|
1034
1044
|
this.addAnimation(pageEl, pageNo === 0);
|
|
1035
|
-
this.onReady(page, false);
|
|
1036
1045
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
1046
|
+
this.onReady(page, false);
|
|
1037
1047
|
this.bindPageEvents(page, pageConfig);
|
|
1038
1048
|
this.triggerRouterChange();
|
|
1039
1049
|
});
|
|
@@ -1149,7 +1159,7 @@ function createRouter(app, config, framework) {
|
|
|
1149
1159
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
1150
1160
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
1151
1161
|
const render = ({ location, action }) => __awaiter(this, void 0, void 0, function* () {
|
|
1152
|
-
var _c, _d, _e, _f, _g, _h;
|
|
1162
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1153
1163
|
handler.pathname = decodeURI(location.pathname);
|
|
1154
1164
|
if ((_c = window.__taroAppConfig) === null || _c === void 0 ? void 0 : _c.usingWindowScroll)
|
|
1155
1165
|
window.scrollTo(0, 0);
|
|
@@ -1178,22 +1188,35 @@ function createRouter(app, config, framework) {
|
|
|
1178
1188
|
window.location.reload();
|
|
1179
1189
|
}
|
|
1180
1190
|
else {
|
|
1181
|
-
throw
|
|
1191
|
+
throw error;
|
|
1182
1192
|
}
|
|
1183
1193
|
}
|
|
1184
1194
|
if (!element)
|
|
1185
1195
|
return;
|
|
1186
1196
|
const pageConfig = handler.pageConfig;
|
|
1187
1197
|
let enablePullDownRefresh = ((_e = config === null || config === void 0 ? void 0 : config.window) === null || _e === void 0 ? void 0 : _e.enablePullDownRefresh) || false;
|
|
1198
|
+
let navigationStyle = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.navigationStyle) || 'default';
|
|
1199
|
+
let navigationBarTextStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationBarTextStyle) || 'white';
|
|
1200
|
+
let navigationBarBackgroundColor = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarBackgroundColor) || '#000000';
|
|
1188
1201
|
if (pageConfig) {
|
|
1189
|
-
setTitle((
|
|
1202
|
+
setTitle((_j = pageConfig.navigationBarTitleText) !== null && _j !== void 0 ? _j : document.title);
|
|
1190
1203
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
1191
1204
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
1192
1205
|
}
|
|
1206
|
+
if (typeof pageConfig.navigationStyle === 'string') {
|
|
1207
|
+
navigationStyle = pageConfig.navigationStyle;
|
|
1208
|
+
}
|
|
1209
|
+
if (typeof pageConfig.navigationBarTextStyle === 'string') {
|
|
1210
|
+
navigationBarTextStyle = pageConfig.navigationBarTextStyle;
|
|
1211
|
+
}
|
|
1212
|
+
if (typeof pageConfig.navigationBarBackgroundColor === 'string') {
|
|
1213
|
+
navigationBarBackgroundColor = pageConfig.navigationBarBackgroundColor;
|
|
1214
|
+
}
|
|
1193
1215
|
}
|
|
1216
|
+
runtime.eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
1194
1217
|
const currentPage = runtime.Current.page;
|
|
1195
1218
|
const pathname = handler.pathname;
|
|
1196
|
-
const methodName = (
|
|
1219
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
1197
1220
|
const cacheTabs = stacks.getTabs();
|
|
1198
1221
|
let shouldLoad = false;
|
|
1199
1222
|
stacks.method = '';
|
|
@@ -1259,7 +1282,7 @@ function createRouter(app, config, framework) {
|
|
|
1259
1282
|
shouldLoad = true;
|
|
1260
1283
|
}
|
|
1261
1284
|
if (shouldLoad || stacks.length < 1) {
|
|
1262
|
-
const el = (
|
|
1285
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
1263
1286
|
const loadConfig = Object.assign({}, pageConfig);
|
|
1264
1287
|
const stacksIndex = stacks.length;
|
|
1265
1288
|
delete loadConfig['path'];
|