@tarojs/router 4.0.0-canary.8 → 4.0.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/LICENSE +17 -3
- package/README.md +1 -1
- package/dist/api.js +31 -22
- package/dist/events/resize.d.ts +1 -1
- package/dist/events/resize.js +15 -7
- package/dist/events/scroll.d.ts +1 -1
- package/dist/events/scroll.js +4 -1
- package/dist/history.d.ts +22 -1
- package/dist/history.js +20 -8
- package/dist/index.cjs.js +798 -339
- package/dist/index.d.ts +6 -1
- package/dist/index.esm.js +758 -311
- package/dist/index.js +52 -4
- package/dist/navigationBar.d.ts +2 -0
- package/dist/navigationBar.js +44 -0
- package/dist/router/index.js +7 -3
- package/dist/router/mpa.d.ts +2 -1
- package/dist/router/mpa.js +29 -19
- package/dist/router/multi-page.d.ts +5 -2
- package/dist/router/multi-page.js +27 -43
- package/dist/router/navigation-bar.d.ts +36 -0
- package/dist/router/navigation-bar.js +252 -0
- package/dist/router/page.d.ts +11 -4
- package/dist/router/page.js +63 -59
- package/dist/router/spa.d.ts +2 -1
- package/dist/router/spa.js +81 -43
- package/dist/router/stack.d.ts +1 -1
- package/dist/router/stack.js +2 -1
- package/dist/style.d.ts +6 -1
- package/dist/style.js +109 -6
- package/dist/tabbar.d.ts +2 -1
- package/dist/tabbar.js +4 -3
- package/dist/utils/index.d.ts +1 -8
- package/dist/utils/index.js +5 -20
- package/dist/utils/navigate.d.ts +9 -5
- package/dist/utils/navigate.js +24 -37
- package/package.json +28 -27
- package/types/api.d.ts +5 -0
- package/types/component.d.ts +5 -0
- package/types/router.d.ts +2 -0
- package/types/taro.d.ts +8 -0
- package/dist/index.cjs.d.ts +0 -22
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.d.ts +0 -22
- package/dist/index.esm.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,50 +1,256 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var history = require('history');
|
|
6
|
-
var runtime = require('@tarojs/runtime');
|
|
7
|
-
var MobileDetect = require('mobile-detect');
|
|
8
|
-
var queryString = require('query-string');
|
|
9
3
|
var components = require('@tarojs/components/dist/components');
|
|
10
4
|
var taro = require('@tarojs/taro');
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var runtime = require('@tarojs/runtime');
|
|
7
|
+
var shared = require('@tarojs/shared');
|
|
8
|
+
var history = require('history');
|
|
9
|
+
var queryString = require('query-string');
|
|
11
10
|
var UniversalRouter = require('universal-router');
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* 插入页面动画需要的样式
|
|
14
|
+
*/
|
|
15
|
+
function loadAnimateStyle(ms = 300) {
|
|
16
|
+
const css = `
|
|
17
|
+
body {
|
|
18
|
+
/* 防止 iOS 页面滚动 */
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
.taro_router > .taro_page {
|
|
22
|
+
position: absolute;
|
|
23
|
+
left: 0;
|
|
24
|
+
top: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
background-color: #fff;
|
|
28
|
+
transform: translate(100%, 0);
|
|
29
|
+
transition: transform ${ms}ms;
|
|
30
|
+
z-index: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.taro_router > .taro_page.taro_tabbar_page,
|
|
34
|
+
.taro_router > .taro_page.taro_page_show.taro_page_stationed {
|
|
35
|
+
transform: none;
|
|
36
|
+
transition: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.taro_router > .taro_page.taro_page_show {
|
|
40
|
+
transform: translate(0, 0);
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
addStyle(css);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 插入路由相关样式
|
|
47
|
+
*/
|
|
48
|
+
function loadRouterStyle(enableTabBar, enableWindowScroll, enhanceAnimation) {
|
|
49
|
+
const css = `
|
|
50
|
+
.taro_router {
|
|
51
|
+
position: relative;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.taro_page {
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 100%;
|
|
59
|
+
${enableWindowScroll ? '' : `
|
|
60
|
+
overflow-x: hidden;
|
|
61
|
+
overflow-y: scroll;
|
|
62
|
+
max-height: 100vh;
|
|
63
|
+
`}
|
|
64
|
+
}
|
|
65
|
+
${enableTabBar ? `
|
|
66
|
+
.taro-tabbar__container > .taro-tabbar__panel {
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.taro-tabbar__container > .taro-tabbar__panel > .taro_page.taro_tabbar_page {
|
|
71
|
+
max-height: calc(100vh - var(--taro-tabbar-height) - constant(safe-area-inset-bottom));
|
|
72
|
+
max-height: calc(100vh - var(--taro-tabbar-height) - env(safe-area-inset-bottom));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
` : ''}
|
|
76
|
+
${enhanceAnimation
|
|
77
|
+
? `.taro_page_shade:has(+.taro_page_stationed),
|
|
78
|
+
.taro_page_shade.taro_tabbar_page,
|
|
79
|
+
.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) {
|
|
80
|
+
display: none;
|
|
81
|
+
}` : ` .taro_page_shade,
|
|
82
|
+
.taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
|
|
83
|
+
display: none;
|
|
84
|
+
}`}
|
|
85
|
+
`;
|
|
86
|
+
addStyle(css);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 插入导航栏相关的样式
|
|
90
|
+
*/
|
|
91
|
+
function loadNavigationBarStyle() {
|
|
92
|
+
const css = `
|
|
93
|
+
.taro-navigation-bar-show {
|
|
94
|
+
display: flex;
|
|
95
|
+
background: white;
|
|
96
|
+
position: sticky;
|
|
97
|
+
z-index: 500;
|
|
98
|
+
top: 0;
|
|
99
|
+
padding-bottom: 8px;
|
|
100
|
+
padding-top: calc(env(safe-area-inset-top) + 8px);
|
|
101
|
+
justify-content: center;
|
|
102
|
+
align-items: center;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.taro-navigation-bar-hide {
|
|
106
|
+
display: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.taro-navigation-bar-title-wrap {
|
|
110
|
+
display: flex;
|
|
111
|
+
height: 24px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.taro-navigation-bar-title-wrap > .taro-navigation-bar-loading {
|
|
115
|
+
display: none;
|
|
116
|
+
animation: loading 2s linear infinite;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.taro-navigation-bar-title-wrap .taro-navigation-bar-loading.taro-navigation-bar-loading-show {
|
|
120
|
+
display: flex;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.taro-navigation-bar-title-wrap > .taro-navigation-bar-title {
|
|
124
|
+
font-size: 24px;
|
|
125
|
+
height: 24px;
|
|
126
|
+
line-height: 24px;
|
|
127
|
+
max-width: 100px;
|
|
128
|
+
white-space: nowrap;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
line-height: 24px;
|
|
131
|
+
text-overflow: ellipsis;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@keyframes loading {
|
|
135
|
+
from {
|
|
136
|
+
transform: rotate(0deg);
|
|
137
|
+
}
|
|
138
|
+
to {
|
|
139
|
+
transform: rotate(360deg);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@keyframes loading {
|
|
144
|
+
from {
|
|
145
|
+
transform: rotate(0deg);
|
|
146
|
+
}
|
|
147
|
+
to {
|
|
148
|
+
transform: rotate(360deg);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.taro-navigation-bar-no-icon > .taro-navigation-bar-home {
|
|
153
|
+
display: none;
|
|
154
|
+
}
|
|
14
155
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
156
|
+
.taro-navigation-bar-no-icon > .taro-navigation-bar-back {
|
|
157
|
+
display: none;
|
|
158
|
+
}
|
|
18
159
|
|
|
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
|
-
|
|
47
|
-
|
|
160
|
+
.taro-navigation-bar-home-icon > .taro-navigation-bar-home {
|
|
161
|
+
display: flex;
|
|
162
|
+
left: 8px;
|
|
163
|
+
position: absolute;
|
|
164
|
+
width: 24px;
|
|
165
|
+
height: 24px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.taro-navigation-bar-back-icon > .taro-navigation-bar-back {
|
|
169
|
+
display: flex;
|
|
170
|
+
left: 8px;
|
|
171
|
+
position: absolute;
|
|
172
|
+
width: 24px;
|
|
173
|
+
height: 24px;
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
addStyle(css);
|
|
177
|
+
}
|
|
178
|
+
function addStyle(css) {
|
|
179
|
+
if (!css)
|
|
180
|
+
return;
|
|
181
|
+
const style = document.createElement('style');
|
|
182
|
+
style.innerHTML = css;
|
|
183
|
+
document.getElementsByTagName('head')[0].appendChild(style);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const home_svg_str = `
|
|
187
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
188
|
+
<path d="M23.8899 12.2737C23.8232 12.3584 23.7237 12.3997 23.6198 12.3974H20.7994V23.5996C20.7994 23.8194 20.6213 24 20.4001 24H14.7994C14.5791 24 14.4002 23.8194 14.4002 23.5996V15.6H9.59963V23.5996C9.59963 23.8194 9.42075 24 9.20033 24H3.59968C3.48981 24 3.38964 23.954 3.31764 23.8811C3.24495 23.8091 3.2004 23.7087 3.2004 23.5996V12.3975H0.398546V12.3967C0.296893 12.396 0.194446 12.3544 0.11579 12.2738C-0.0371146 12.114 -0.0400714 11.864 0.11579 11.7076L11.7201 0.117284C11.8767 -0.0390948 12.1298 -0.0390948 12.2863 0.117284L23.8899 11.7076C24.0465 11.864 24.0265 12.0995 23.8899 12.2737ZM12.0029 0.964625L1.37086 11.5854L3.59968 11.5839V11.5999C3.65537 11.5999 3.70804 11.611 3.75557 11.6307C3.89952 11.692 4.00046 11.8339 4.00046 11.9996V23.1991H8.79955V15.2003C8.79955 14.9789 8.97917 14.8002 9.20033 14.8002H14.7995C15.0207 14.8002 15.2003 14.9789 15.2003 15.2003V23.1991H20.0001V11.9996C20.0001 11.8339 20.1003 11.692 20.2443 11.6307C20.2918 11.611 20.3453 11.5999 20.4001 11.5999V11.5713L22.6193 11.5691L12.0029 0.964625Z" fill="currentColor"/>
|
|
189
|
+
</svg>
|
|
190
|
+
`;
|
|
191
|
+
const back_svg_str = `
|
|
192
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
193
|
+
<path d="M17.8206 22.9016L7.45515 11.8756L17.8206 1.09845C18.0598 0.849741 18.0598 0.435233 17.8206 0.186528C17.5814 -0.0621762 17.1827 -0.0621762 16.9435 0.186528L6.1794 11.4611C5.9402 11.7098 5.9402 12.1244 6.1794 12.3731L16.9435 23.8135C17.1827 24.0622 17.5814 24.0622 17.8206 23.8135C18.0598 23.5648 18.0598 23.1503 17.8206 22.9016Z" fill="currentColor"/>
|
|
194
|
+
</svg>
|
|
195
|
+
`;
|
|
196
|
+
const loading_svg_str = `
|
|
197
|
+
<svg t="1709608074670" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4741" width="24" height="24"><path d="M256 529.066667H85.333333a17.066667 17.066667 0 1 1 0-34.133334h170.666667a17.066667 17.066667 0 0 1 0 34.133334z" opacity=".278" p-id="4742"></path><path d="M99.84 640a17.066667 17.066667 0 0 1-4.437333-33.553067l164.693333-44.373333a17.066667 17.066667 0 1 1 8.891733 32.9728l-164.693333 44.373333a17.544533 17.544533 0 0 1-4.4544 0.580267z" opacity=".322" p-id="4743"></path><path d="M264.533333 462.523733a16.896 16.896 0 0 1-4.369066-0.580266l-164.693334-43.52a17.0496 17.0496 0 1 1 8.721067-32.989867l164.693333 43.52a17.066667 17.066667 0 1 1-4.352 33.570133z" opacity=".239" p-id="4744"></path><path d="M384.017067 307.2a17.032533 17.032533 0 0 1-14.7968-8.533333l-85.333334-147.626667a17.066667 17.066667 0 0 1 29.559467-17.083733l85.333333 147.626666A17.066667 17.066667 0 0 1 384.017067 307.2z" opacity=".122" p-id="4745"></path><path d="M639.982933 307.2a17.0496 17.0496 0 0 1-14.762666-25.6l85.333333-147.626667a17.066667 17.066667 0 1 1 29.559467 17.066667l-85.333334 147.626667a17.032533 17.032533 0 0 1-14.7968 8.533333z" opacity=".922" p-id="4746"></path><path d="M692.906667 347.306667a17.066667 17.066667 0 0 1-12.117334-29.098667l120.337067-121.173333a17.066667 17.066667 0 1 1 24.234667 24.046933l-120.337067 121.173333a17.1008 17.1008 0 0 1-12.117333 5.051734z" opacity=".878" p-id="4747"></path><path d="M733.883733 401.066667a17.066667 17.066667 0 0 1-8.5504-31.8464l147.626667-85.333334a17.0496 17.0496 0 1 1 17.066667 29.5424l-147.626667 85.333334a16.776533 16.776533 0 0 1-8.516267 2.304z" opacity=".839" p-id="4748"></path><path d="M512 273.066667a17.066667 17.066667 0 0 1-17.066667-17.066667V85.333333a17.066667 17.066667 0 0 1 34.133334 0v170.666667a17.066667 17.066667 0 0 1-17.066667 17.066667z" p-id="4749"></path><path d="M578.577067 281.6a17.066667 17.066667 0 0 1-16.520534-21.418667l43.52-164.693333a17.066667 17.066667 0 0 1 33.006934 8.721067l-43.52 164.693333a17.066667 17.066667 0 0 1-16.4864 12.6976z" opacity=".961" p-id="4750"></path><path d="M445.44 282.453333a17.066667 17.066667 0 0 1-16.469333-12.629333l-44.373334-164.693333a17.066667 17.066667 0 0 1 32.955734-8.891734l44.373333 164.693334a17.066667 17.066667 0 0 1-16.4864 21.521066z" opacity=".078" p-id="4751"></path><path d="M924.177067 640c-1.4848 0-2.9696-0.187733-4.4544-0.580267l-164.693334-44.373333a17.066667 17.066667 0 0 1 8.874667-32.9728l164.693333 44.373333a17.066667 17.066667 0 0 1-4.420266 33.553067z" opacity=".722" p-id="4752"></path><path d="M881.476267 742.4a17.015467 17.015467 0 0 1-8.482134-2.269867l-148.48-85.333333a17.0496 17.0496 0 1 1 16.9984-29.5936l148.48 85.333333a17.0496 17.0496 0 0 1-8.516266 31.863467z" opacity=".678" p-id="4753"></path><path d="M813.226667 830.293333a17.015467 17.015467 0 0 1-12.066134-5.000533l-120.337066-120.337067a17.0496 17.0496 0 1 1 24.132266-24.132266l120.337067 120.337066a17.0496 17.0496 0 0 1-12.066133 29.1328z" opacity=".639" p-id="4754"></path><path d="M938.666667 529.066667H768a17.066667 17.066667 0 1 1 0-34.133334h170.666667a17.066667 17.066667 0 1 1 0 34.133334z" opacity=".761" p-id="4755"></path><path d="M401.066667 941.226667a17.066667 17.066667 0 0 1-16.4864-21.504l44.373333-164.693334a17.066667 17.066667 0 1 1 32.955733 8.874667l-44.373333 164.693333a17.066667 17.066667 0 0 1-16.469333 12.629334z" opacity=".478" p-id="4756"></path><path d="M298.6496 898.56a17.066667 17.066667 0 0 1-14.779733-25.565867l85.333333-148.48a17.083733 17.083733 0 0 1 29.5936 16.9984l-85.333333 148.48a17.032533 17.032533 0 0 1-14.813867 8.567467z" opacity=".439" p-id="4757"></path><path d="M512 955.733333a17.066667 17.066667 0 0 1-17.066667-17.066666V768a17.066667 17.066667 0 1 1 34.133334 0v170.666667a17.066667 17.066667 0 0 1-17.066667 17.066666z" opacity=".522" p-id="4758"></path><path d="M725.3504 898.56a17.032533 17.032533 0 0 1-14.7968-8.533333l-85.333333-147.626667a17.066667 17.066667 0 0 1 29.559466-17.066667l85.333334 147.626667a17.066667 17.066667 0 0 1-14.762667 25.6z" opacity=".6" p-id="4759"></path><path d="M622.062933 942.08c-7.509333 0-14.421333-5.0176-16.469333-12.629333l-44.3904-164.693334a17.066667 17.066667 0 1 1 32.9728-8.874666l44.3904 164.693333a17.066667 17.066667 0 0 1-16.503467 21.504z" opacity=".561" p-id="4760"></path><path d="M759.4496 463.36a17.083733 17.083733 0 0 1-4.420267-33.553067l164.693334-44.373333a17.066667 17.066667 0 0 1 8.874666 32.955733l-164.693333 44.373334a16.657067 16.657067 0 0 1-4.4544 0.597333z" opacity=".702" p-id="4761"></path><path d="M330.24 347.306667a17.015467 17.015467 0 0 1-12.066133-5.000534l-120.32-120.32a17.0496 17.0496 0 1 1 24.132266-24.132266l120.32 120.32a17.0496 17.0496 0 0 1-12.066133 29.1328z" opacity=".161" p-id="4762"></path><path d="M290.116267 401.066667a17.032533 17.032533 0 0 1-8.533334-2.286934l-147.626666-85.333333a17.066667 17.066667 0 1 1 17.083733-29.5424l147.626667 85.333333a17.066667 17.066667 0 0 1-8.5504 31.829334z" opacity=".2" p-id="4763"></path><path d="M142.523733 742.4a17.066667 17.066667 0 0 1-8.567466-31.8464l147.626666-85.333333a17.066667 17.066667 0 1 1 17.083734 29.559466l-147.626667 85.333334a16.930133 16.930133 0 0 1-8.516267 2.286933z" opacity=".361" p-id="4764"></path><path d="M209.92 830.293333a17.066667 17.066667 0 0 1-12.117333-29.098666l120.32-121.173334a17.066667 17.066667 0 0 1 24.2176 24.029867l-120.32 121.1904a16.896 16.896 0 0 1-12.100267 5.051733z" opacity=".4" p-id="4765"></path></svg>
|
|
198
|
+
`;
|
|
199
|
+
function initNavigationBar(config, container) {
|
|
200
|
+
if (config.router.mode === 'multi')
|
|
201
|
+
return;
|
|
202
|
+
const navigationBar = document.createElement('div');
|
|
203
|
+
navigationBar.classList.add('taro-navigation-bar-no-icon');
|
|
204
|
+
const navigationBarBackBtn = document.createElement('div');
|
|
205
|
+
navigationBarBackBtn.classList.add('taro-navigation-bar-back');
|
|
206
|
+
const navigationBarHomeBtn = document.createElement('div');
|
|
207
|
+
navigationBarHomeBtn.classList.add('taro-navigation-bar-home');
|
|
208
|
+
navigationBarBackBtn.innerHTML = back_svg_str;
|
|
209
|
+
navigationBarHomeBtn.innerHTML = home_svg_str;
|
|
210
|
+
const navigationBarTitleWrap = document.createElement('div');
|
|
211
|
+
navigationBarTitleWrap.classList.add('taro-navigation-bar-title-wrap');
|
|
212
|
+
const navigationBarLoading = document.createElement('div');
|
|
213
|
+
navigationBarLoading.classList.add('taro-navigation-bar-loading');
|
|
214
|
+
navigationBarLoading.innerHTML = loading_svg_str;
|
|
215
|
+
const navigationBarTitle = document.createElement('div');
|
|
216
|
+
navigationBarTitle.classList.add('taro-navigation-bar-title');
|
|
217
|
+
navigationBarTitleWrap.appendChild(navigationBarLoading);
|
|
218
|
+
navigationBarTitleWrap.appendChild(navigationBarTitle);
|
|
219
|
+
navigationBar.appendChild(navigationBarHomeBtn);
|
|
220
|
+
navigationBar.appendChild(navigationBarBackBtn);
|
|
221
|
+
navigationBar.appendChild(navigationBarTitleWrap);
|
|
222
|
+
navigationBar.id = 'taro-navigation-bar';
|
|
223
|
+
container.prepend(navigationBar);
|
|
224
|
+
loadNavigationBarStyle();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function initTabbar(config, history) {
|
|
228
|
+
if (config.tabBar == null || config.tabBar.custom) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
// TODO: custom-tab-bar
|
|
232
|
+
components.defineCustomElementTaroTabbar();
|
|
233
|
+
const tabbar = document.createElement('taro-tabbar');
|
|
234
|
+
const homePage = config.entryPagePath || (config.pages ? config.pages[0] : '');
|
|
235
|
+
tabbar.conf = config.tabBar;
|
|
236
|
+
tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname;
|
|
237
|
+
const routerConfig = config.router;
|
|
238
|
+
tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash';
|
|
239
|
+
if (routerConfig.customRoutes) {
|
|
240
|
+
tabbar.conf.custom = true;
|
|
241
|
+
tabbar.conf.customRoutes = routerConfig.customRoutes;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
tabbar.conf.custom = false;
|
|
245
|
+
tabbar.conf.customRoutes = {};
|
|
246
|
+
}
|
|
247
|
+
if (typeof routerConfig.basename !== 'undefined') {
|
|
248
|
+
tabbar.conf.basename = routerConfig.basename;
|
|
249
|
+
}
|
|
250
|
+
const container = document.getElementById('container');
|
|
251
|
+
container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
|
|
252
|
+
taro.initTabBarApis(config);
|
|
253
|
+
}
|
|
48
254
|
|
|
49
255
|
class RouterConfig {
|
|
50
256
|
static set config(e) {
|
|
@@ -63,8 +269,9 @@ class RouterConfig {
|
|
|
63
269
|
return this.router.mode || 'hash';
|
|
64
270
|
}
|
|
65
271
|
static get customRoutes() { return this.router.customRoutes || {}; }
|
|
272
|
+
// 这个方法不考虑 basename 和 customRoutes,只判断原始的 url 是否在 pages 中
|
|
66
273
|
static isPage(url = '') {
|
|
67
|
-
return this.pages.findIndex(e =>
|
|
274
|
+
return this.pages.findIndex(e => runtime.addLeadingSlash(e) === url) !== -1;
|
|
68
275
|
}
|
|
69
276
|
}
|
|
70
277
|
|
|
@@ -91,14 +298,14 @@ class MpaHistory {
|
|
|
91
298
|
}
|
|
92
299
|
parseUrl(to) {
|
|
93
300
|
let url = to.pathname || '';
|
|
94
|
-
if (RouterConfig.isPage(url)) {
|
|
301
|
+
if (RouterConfig.isPage(runtime.addLeadingSlash(url))) {
|
|
95
302
|
url += '.html';
|
|
96
303
|
}
|
|
97
304
|
if (to.search) {
|
|
98
305
|
url += `?${to.search}`;
|
|
99
306
|
}
|
|
100
307
|
if (to.hash) {
|
|
101
|
-
url += `#${to.hash}`;
|
|
308
|
+
url += to.hash.startsWith('#') ? to.hash : `#${to.hash}`;
|
|
102
309
|
}
|
|
103
310
|
return url;
|
|
104
311
|
}
|
|
@@ -147,6 +354,13 @@ class MpaHistory {
|
|
|
147
354
|
};
|
|
148
355
|
}
|
|
149
356
|
}
|
|
357
|
+
function setHistory(h, base = '/') {
|
|
358
|
+
exports.history = h;
|
|
359
|
+
basename = base;
|
|
360
|
+
}
|
|
361
|
+
function createMpaHistory(_) {
|
|
362
|
+
return new MpaHistory();
|
|
363
|
+
}
|
|
150
364
|
function setHistoryMode(mode, base = '/') {
|
|
151
365
|
const options = {
|
|
152
366
|
window
|
|
@@ -156,7 +370,7 @@ function setHistoryMode(mode, base = '/') {
|
|
|
156
370
|
exports.history = history.createBrowserHistory(options);
|
|
157
371
|
}
|
|
158
372
|
else if (mode === 'multi') {
|
|
159
|
-
exports.history =
|
|
373
|
+
exports.history = createMpaHistory();
|
|
160
374
|
}
|
|
161
375
|
else {
|
|
162
376
|
// default is hash
|
|
@@ -248,24 +462,34 @@ class Stacks {
|
|
|
248
462
|
}
|
|
249
463
|
const stacks = new Stacks();
|
|
250
464
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
465
|
+
const isWeixin = () => !!navigator.userAgent.match(/\bMicroMessenger\b/ig);
|
|
466
|
+
const isDingTalk = () => !!navigator.userAgent.match(/\bDingTalk\b/ig);
|
|
467
|
+
let preTitle = document.title;
|
|
468
|
+
let isLoadDdEntry = false;
|
|
469
|
+
function setMpaTitle(title) {
|
|
470
|
+
if (preTitle === title)
|
|
471
|
+
return;
|
|
472
|
+
document.title = title;
|
|
473
|
+
preTitle = title;
|
|
474
|
+
if (process.env.SUPPORT_DINGTALK_NAVIGATE !== 'disabled' && isDingTalk()) {
|
|
475
|
+
if (!isLoadDdEntry) {
|
|
476
|
+
isLoadDdEntry = true;
|
|
477
|
+
require('dingtalk-jsapi/platform');
|
|
478
|
+
}
|
|
479
|
+
const setDingTitle = require('dingtalk-jsapi/api/biz/navigation/setTitle').default;
|
|
480
|
+
setDingTitle({ title });
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function setTitle(title) {
|
|
484
|
+
runtime.eventCenter.trigger('__taroH5SetNavigationBarTitle', title);
|
|
485
|
+
}
|
|
486
|
+
function setNavigationBarStyle(option) {
|
|
487
|
+
runtime.eventCenter.trigger('__taroH5setNavigationBarColor', option);
|
|
488
|
+
}
|
|
489
|
+
function setNavigationBarLoading(loading) {
|
|
490
|
+
runtime.eventCenter.trigger('__taroH5setNavigationBarLoading', loading);
|
|
491
|
+
}
|
|
492
|
+
|
|
269
493
|
class RoutesAlias {
|
|
270
494
|
constructor() {
|
|
271
495
|
this.conf = [];
|
|
@@ -295,18 +519,19 @@ class RoutesAlias {
|
|
|
295
519
|
set(customRoutes = {}) {
|
|
296
520
|
for (let key in customRoutes) {
|
|
297
521
|
const path = customRoutes[key];
|
|
298
|
-
key = addLeadingSlash(key);
|
|
522
|
+
key = runtime.addLeadingSlash(key);
|
|
299
523
|
if (typeof path === 'string') {
|
|
300
|
-
this.conf.push([key, addLeadingSlash(path)]);
|
|
524
|
+
this.conf.push([key, runtime.addLeadingSlash(path)]);
|
|
301
525
|
}
|
|
302
526
|
else if ((path === null || path === void 0 ? void 0 : path.length) > 0) {
|
|
303
|
-
this.conf.push(...path.map(p => [key, addLeadingSlash(p)]));
|
|
527
|
+
this.conf.push(...path.map(p => [key, runtime.addLeadingSlash(p)]));
|
|
304
528
|
}
|
|
305
529
|
}
|
|
306
530
|
}
|
|
307
531
|
}
|
|
308
532
|
const routesAlias = new RoutesAlias();
|
|
309
533
|
|
|
534
|
+
const routeEvtChannel = shared.EventChannel.routeChannel;
|
|
310
535
|
function processNavigateUrl(option) {
|
|
311
536
|
var _a;
|
|
312
537
|
const pathPieces = history.parsePath(option.url);
|
|
@@ -315,15 +540,16 @@ function processNavigateUrl(option) {
|
|
|
315
540
|
const parts = routesAlias.getOrigin(exports.history.location.pathname).split('/');
|
|
316
541
|
parts.pop();
|
|
317
542
|
pathPieces.pathname.split('/').forEach((item) => {
|
|
318
|
-
if (item === '.')
|
|
543
|
+
if (item === '.')
|
|
319
544
|
return;
|
|
320
|
-
}
|
|
321
545
|
item === '..' ? parts.pop() : parts.push(item);
|
|
322
546
|
});
|
|
323
547
|
pathPieces.pathname = parts.join('/');
|
|
324
548
|
}
|
|
549
|
+
// 确保是 / 开头的路径
|
|
550
|
+
pathPieces.pathname = runtime.addLeadingSlash(pathPieces.pathname);
|
|
325
551
|
// 处理自定义路由
|
|
326
|
-
pathPieces.pathname = routesAlias.getAlias(addLeadingSlash(pathPieces.pathname));
|
|
552
|
+
pathPieces.pathname = routesAlias.getAlias(runtime.addLeadingSlash(pathPieces.pathname));
|
|
327
553
|
// 处理 basename
|
|
328
554
|
pathPieces.pathname = prependBasename(pathPieces.pathname);
|
|
329
555
|
// hack fix history v5 bug: https://github.com/remix-run/history/issues/814
|
|
@@ -332,12 +558,16 @@ function processNavigateUrl(option) {
|
|
|
332
558
|
return pathPieces;
|
|
333
559
|
}
|
|
334
560
|
function navigate(option, method) {
|
|
335
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
561
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
336
562
|
return new Promise((resolve, reject) => {
|
|
337
563
|
stacks.method = method;
|
|
338
564
|
const { success, complete, fail } = option;
|
|
339
565
|
const unListen = exports.history.listen(() => {
|
|
340
566
|
const res = { errMsg: `${method}:ok` };
|
|
567
|
+
if (method === 'navigateTo') {
|
|
568
|
+
res.eventChannel = routeEvtChannel;
|
|
569
|
+
routeEvtChannel.addEvents(option.events);
|
|
570
|
+
}
|
|
341
571
|
success === null || success === void 0 ? void 0 : success(res);
|
|
342
572
|
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
343
573
|
resolve(res);
|
|
@@ -348,6 +578,7 @@ function navigate(option, method) {
|
|
|
348
578
|
const pathPieces = processNavigateUrl(option);
|
|
349
579
|
const state = { timestamp: Date.now() };
|
|
350
580
|
if (method === 'navigateTo') {
|
|
581
|
+
// Note: 由于 spa 会针对弱网情况下,短时间内多次跳转同一个页面跳转加了锁,后续如果有用户反馈返回无效,那可能是这个问题
|
|
351
582
|
exports.history.push(pathPieces, state);
|
|
352
583
|
}
|
|
353
584
|
else if (method === 'redirectTo' || method === 'switchTab') {
|
|
@@ -372,7 +603,12 @@ function navigate(option, method) {
|
|
|
372
603
|
const res = { errMsg: `${method}:fail ${error.message || error}` };
|
|
373
604
|
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
374
605
|
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
375
|
-
|
|
606
|
+
if (fail || complete) {
|
|
607
|
+
return resolve(res);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
return reject(res);
|
|
611
|
+
}
|
|
376
612
|
}
|
|
377
613
|
});
|
|
378
614
|
});
|
|
@@ -403,47 +639,22 @@ function getCurrentPages() {
|
|
|
403
639
|
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, '')) || '' })); });
|
|
404
640
|
}
|
|
405
641
|
|
|
406
|
-
let md;
|
|
407
|
-
let preTitle = document.title;
|
|
408
|
-
let isLoadDdEntry = false;
|
|
409
|
-
function getMobileDetect() {
|
|
410
|
-
if (!md) {
|
|
411
|
-
md = new MobileDetect__default["default"](navigator.userAgent);
|
|
412
|
-
}
|
|
413
|
-
return md;
|
|
414
|
-
}
|
|
415
|
-
function setTitle(title) {
|
|
416
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
417
|
-
if (preTitle === title)
|
|
418
|
-
return title;
|
|
419
|
-
document.title = title;
|
|
420
|
-
preTitle = title;
|
|
421
|
-
if (process.env.SUPPORT_DINGTALK_NAVIGATE !== 'disabled' && isDingTalk()) {
|
|
422
|
-
if (!isLoadDdEntry) {
|
|
423
|
-
isLoadDdEntry = true;
|
|
424
|
-
require('dingtalk-jsapi/platform');
|
|
425
|
-
}
|
|
426
|
-
const setDingTitle = require('dingtalk-jsapi/api/biz/navigation/setTitle').default;
|
|
427
|
-
setDingTitle({ title });
|
|
428
|
-
}
|
|
429
|
-
return title;
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
function isDingTalk() {
|
|
433
|
-
const md = getMobileDetect();
|
|
434
|
-
return md.match(/DingTalk/ig);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
642
|
let pageResizeFn;
|
|
438
643
|
function bindPageResize(page) {
|
|
439
644
|
pageResizeFn && window.removeEventListener('resize', pageResizeFn);
|
|
440
645
|
pageResizeFn = function () {
|
|
441
|
-
page.onResize
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
646
|
+
if (page.onResize) {
|
|
647
|
+
const mediaQuery = window.matchMedia('(orientation: portrait)');
|
|
648
|
+
page.onResize({
|
|
649
|
+
deviceOrientation: mediaQuery.matches ? 'portrait' : 'landscape',
|
|
650
|
+
size: {
|
|
651
|
+
windowHeight: window.innerHeight,
|
|
652
|
+
windowWidth: window.innerWidth,
|
|
653
|
+
screenHeight: window.screen.height,
|
|
654
|
+
screenWidth: window.screen.width,
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
447
658
|
};
|
|
448
659
|
window.addEventListener('resize', pageResizeFn, false);
|
|
449
660
|
}
|
|
@@ -482,111 +693,10 @@ function getOffset() {
|
|
|
482
693
|
}
|
|
483
694
|
}
|
|
484
695
|
|
|
485
|
-
/**
|
|
486
|
-
* 插入页面动画需要的样式
|
|
487
|
-
*/
|
|
488
|
-
function loadAnimateStyle(ms = 300) {
|
|
489
|
-
const css = `
|
|
490
|
-
.taro_router > .taro_page {
|
|
491
|
-
position: absolute;
|
|
492
|
-
left: 0;
|
|
493
|
-
top: 0;
|
|
494
|
-
width: 100%;
|
|
495
|
-
height: 100%;
|
|
496
|
-
background-color: #fff;
|
|
497
|
-
transform: translate(100%, 0);
|
|
498
|
-
transition: transform ${ms}ms;
|
|
499
|
-
z-index: 0;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
.taro_router > .taro_page.taro_tabbar_page,
|
|
503
|
-
.taro_router > .taro_page.taro_page_show.taro_page_stationed {
|
|
504
|
-
transform: none;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
.taro_router > .taro_page.taro_page_show {
|
|
508
|
-
transform: translate(0, 0);
|
|
509
|
-
}
|
|
510
|
-
`;
|
|
511
|
-
addStyle(css);
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* 插入路由相关样式
|
|
515
|
-
*/
|
|
516
|
-
function loadRouterStyle(usingWindowScroll) {
|
|
517
|
-
const css = `
|
|
518
|
-
.taro_router {
|
|
519
|
-
position: relative;
|
|
520
|
-
width: 100%;
|
|
521
|
-
height: 100%;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
.taro_page {
|
|
525
|
-
width: 100%;
|
|
526
|
-
height: 100%;
|
|
527
|
-
${usingWindowScroll ? '' : `
|
|
528
|
-
overflow-x: hidden;
|
|
529
|
-
overflow-y: scroll;
|
|
530
|
-
max-height: 100vh;
|
|
531
|
-
`}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
.taro-tabbar__container > .taro-tabbar__panel {
|
|
535
|
-
overflow: hidden;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
.taro-tabbar__container > .taro-tabbar__panel > .taro_page.taro_tabbar_page {
|
|
539
|
-
max-height: calc(100vh - var(--taro-tabbar-height) - constant(safe-area-inset-bottom));
|
|
540
|
-
max-height: calc(100vh - var(--taro-tabbar-height) - env(safe-area-inset-bottom));
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.taro_page_shade,
|
|
544
|
-
.taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) {
|
|
545
|
-
display: none;
|
|
546
|
-
}
|
|
547
|
-
`;
|
|
548
|
-
addStyle(css);
|
|
549
|
-
}
|
|
550
|
-
function addStyle(css) {
|
|
551
|
-
if (!css)
|
|
552
|
-
return;
|
|
553
|
-
const style = document.createElement('style');
|
|
554
|
-
style.innerHTML = css;
|
|
555
|
-
document.getElementsByTagName('head')[0].appendChild(style);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// @ts-nocheck
|
|
559
|
-
function initTabbar(config) {
|
|
560
|
-
if (config.tabBar == null || config.tabBar.custom) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
// TODO: custom-tab-bar
|
|
564
|
-
components.defineCustomElementTaroTabbar();
|
|
565
|
-
const tabbar = document.createElement('taro-tabbar');
|
|
566
|
-
const homePage = config.entryPagePath || (config.pages ? config.pages[0] : '');
|
|
567
|
-
tabbar.conf = config.tabBar;
|
|
568
|
-
tabbar.conf.homePage = exports.history.location.pathname === '/' ? homePage : exports.history.location.pathname;
|
|
569
|
-
const routerConfig = config.router;
|
|
570
|
-
tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash';
|
|
571
|
-
if (routerConfig.customRoutes) {
|
|
572
|
-
tabbar.conf.custom = true;
|
|
573
|
-
tabbar.conf.customRoutes = routerConfig.customRoutes;
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
tabbar.conf.custom = false;
|
|
577
|
-
tabbar.conf.customRoutes = {};
|
|
578
|
-
}
|
|
579
|
-
if (typeof routerConfig.basename !== 'undefined') {
|
|
580
|
-
tabbar.conf.basename = routerConfig.basename;
|
|
581
|
-
}
|
|
582
|
-
const container = document.getElementById('container');
|
|
583
|
-
container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
|
|
584
|
-
taro.initTabBarApis(config);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
696
|
/* eslint-disable dot-notation */
|
|
588
697
|
class MultiPageHandler {
|
|
589
|
-
constructor(config) {
|
|
698
|
+
constructor(config, history) {
|
|
699
|
+
this.history = history;
|
|
590
700
|
this.config = config;
|
|
591
701
|
this.mount();
|
|
592
702
|
}
|
|
@@ -602,7 +712,7 @@ class MultiPageHandler {
|
|
|
602
712
|
get pageConfig() { return this.config.route; }
|
|
603
713
|
get isTabBar() {
|
|
604
714
|
var _a;
|
|
605
|
-
const routePath = addLeadingSlash(stripBasename(this.pathname, this.basename));
|
|
715
|
+
const routePath = runtime.addLeadingSlash(runtime.stripBasename(this.pathname, this.basename));
|
|
606
716
|
const pagePath = ((_a = Object.entries(this.customRoutes).find(([, target]) => {
|
|
607
717
|
if (typeof target === 'string') {
|
|
608
718
|
return target === routePath;
|
|
@@ -629,43 +739,22 @@ class MultiPageHandler {
|
|
|
629
739
|
getQuery(search = '', options = {}) {
|
|
630
740
|
search = search ? `${search}&${this.search}` : this.search;
|
|
631
741
|
const query = search
|
|
632
|
-
?
|
|
742
|
+
? queryString.parse(search)
|
|
633
743
|
: {};
|
|
634
744
|
return Object.assign(Object.assign({}, query), options);
|
|
635
745
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
let isPosition = true;
|
|
642
|
-
if (!app) {
|
|
643
|
-
app = document.createElement('div');
|
|
644
|
-
app.id = appId;
|
|
645
|
-
isPosition = false;
|
|
646
|
-
}
|
|
647
|
-
const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
|
|
648
|
-
app.classList.add('taro_router');
|
|
649
|
-
if (this.tabBarList.length > 1) {
|
|
650
|
-
const container = document.createElement('div');
|
|
651
|
-
container.classList.add('taro-tabbar__container');
|
|
652
|
-
container.id = 'container';
|
|
653
|
-
const panel = document.createElement('div');
|
|
654
|
-
panel.classList.add('taro-tabbar__panel');
|
|
655
|
-
panel.appendChild(app.cloneNode(true));
|
|
656
|
-
container.appendChild(panel);
|
|
657
|
-
if (!isPosition) {
|
|
658
|
-
appWrapper.appendChild(container);
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
appWrapper.replaceChild(container, app);
|
|
662
|
-
}
|
|
663
|
-
initTabbar(this.config);
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
if (!isPosition)
|
|
667
|
-
appWrapper.appendChild(app);
|
|
746
|
+
isDefaultNavigationStyle() {
|
|
747
|
+
var _a, _b;
|
|
748
|
+
let style = (_a = this.config.window) === null || _a === void 0 ? void 0 : _a.navigationStyle;
|
|
749
|
+
if (typeof ((_b = this.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationStyle) === 'string') {
|
|
750
|
+
style = this.pageConfig.navigationStyle;
|
|
668
751
|
}
|
|
752
|
+
return style !== 'custom';
|
|
753
|
+
}
|
|
754
|
+
mount() {
|
|
755
|
+
setHistory(this.history, this.basename);
|
|
756
|
+
// Note: 注入页面样式
|
|
757
|
+
loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll);
|
|
669
758
|
}
|
|
670
759
|
onReady(page, onLoad = true) {
|
|
671
760
|
var _a;
|
|
@@ -695,10 +784,13 @@ class MultiPageHandler {
|
|
|
695
784
|
return;
|
|
696
785
|
(_a = page.onLoad) === null || _a === void 0 ? void 0 : _a.call(page, this.getQuery('', page.options), () => {
|
|
697
786
|
var _a;
|
|
787
|
+
const pageEl = this.getPageContainer(page);
|
|
698
788
|
if (this.isTabBar) {
|
|
699
|
-
const pageEl = this.getPageContainer(page);
|
|
700
789
|
pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_tabbar_page');
|
|
701
790
|
}
|
|
791
|
+
if (this.isDefaultNavigationStyle()) {
|
|
792
|
+
pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_navigation_page');
|
|
793
|
+
}
|
|
702
794
|
this.onReady(page, true);
|
|
703
795
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
704
796
|
this.bindPageEvents(page, pageConfig);
|
|
@@ -755,16 +847,17 @@ const launchStampId$1 = createStampId$1();
|
|
|
755
847
|
* - TabBar 会多次加载
|
|
756
848
|
* - 不支持路由动画
|
|
757
849
|
*/
|
|
758
|
-
function createMultiRouter(app, config, framework) {
|
|
759
|
-
|
|
760
|
-
|
|
850
|
+
function createMultiRouter(history, app, config, framework) {
|
|
851
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
852
|
+
var _a, _b, _c, _d, _e, _f;
|
|
761
853
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
762
854
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
763
855
|
}
|
|
856
|
+
runtime.eventCenter.on('__taroH5SetNavigationBarTitle', setMpaTitle);
|
|
764
857
|
RouterConfig.config = config;
|
|
765
|
-
const handler = new MultiPageHandler(config);
|
|
858
|
+
const handler = new MultiPageHandler(config, history);
|
|
766
859
|
const launchParam = {
|
|
767
|
-
path: config.pageName,
|
|
860
|
+
path: config.pageName, // 多页面模式没新开一个页面相当于重启,所以直接使用当前页面路径
|
|
768
861
|
query: handler.getQuery(launchStampId$1),
|
|
769
862
|
scene: 0,
|
|
770
863
|
shareTicket: '',
|
|
@@ -794,7 +887,7 @@ function createMultiRouter(app, config, framework) {
|
|
|
794
887
|
return;
|
|
795
888
|
let enablePullDownRefresh = ((_c = config === null || config === void 0 ? void 0 : config.window) === null || _c === void 0 ? void 0 : _c.enablePullDownRefresh) || false;
|
|
796
889
|
if (pageConfig) {
|
|
797
|
-
|
|
890
|
+
setMpaTitle((_d = pageConfig.navigationBarTitleText) !== null && _d !== void 0 ? _d : document.title);
|
|
798
891
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
799
892
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
800
893
|
}
|
|
@@ -806,19 +899,281 @@ function createMultiRouter(app, config, framework) {
|
|
|
806
899
|
const page = runtime.createPageConfig(enablePullDownRefresh ? runtime.hooks.call('createPullDownComponent', el, pathName, framework, handler.PullDownRefresh) : el, pathName + runtime.stringify(launchParam), {}, loadConfig);
|
|
807
900
|
handler.load(page, pageConfig);
|
|
808
901
|
(_f = app.onShow) === null || _f === void 0 ? void 0 : _f.call(app, launchParam);
|
|
902
|
+
window.addEventListener('visibilitychange', () => {
|
|
903
|
+
var _a, _b, _c;
|
|
904
|
+
const currentPath = ((_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) || '';
|
|
905
|
+
const path = currentPath.substring(0, currentPath.indexOf('?'));
|
|
906
|
+
const param = {};
|
|
907
|
+
// app的 onShow/onHide 生命周期的路径信息为当前页面的路径
|
|
908
|
+
Object.assign(param, launchParam, { path });
|
|
909
|
+
if (document.visibilityState === 'visible') {
|
|
910
|
+
(_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, param);
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
(_c = app.onHide) === null || _c === void 0 ? void 0 : _c.call(app, param);
|
|
914
|
+
}
|
|
915
|
+
});
|
|
809
916
|
});
|
|
810
917
|
}
|
|
811
918
|
|
|
919
|
+
class NavigationBarHandler {
|
|
920
|
+
constructor(pageContext) {
|
|
921
|
+
this.isLoadDdEntry = false;
|
|
922
|
+
this.cache = {};
|
|
923
|
+
this.pageContext = pageContext;
|
|
924
|
+
this.init();
|
|
925
|
+
runtime.eventCenter.on('__taroH5SetNavigationBarTitle', (title) => {
|
|
926
|
+
this.setTitle(title);
|
|
927
|
+
});
|
|
928
|
+
runtime.eventCenter.on('__taroH5setNavigationBarLoading', (loading) => {
|
|
929
|
+
this.setNavigationLoading(loading);
|
|
930
|
+
});
|
|
931
|
+
runtime.eventCenter.on('__taroH5setNavigationBarColor', ({ backgroundColor, frontColor }) => {
|
|
932
|
+
if (typeof backgroundColor === 'string')
|
|
933
|
+
this.setNavigationBarBackground(backgroundColor);
|
|
934
|
+
if (typeof frontColor === 'string')
|
|
935
|
+
this.setNavigationBarTextStyle(frontColor);
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
toHomeFn() {
|
|
939
|
+
reLaunch({ url: this.pageContext.originHomePage });
|
|
940
|
+
}
|
|
941
|
+
backFn() {
|
|
942
|
+
navigateBack();
|
|
943
|
+
}
|
|
944
|
+
get homeBtnElement() {
|
|
945
|
+
var _a;
|
|
946
|
+
if (!this.navigationBarElement)
|
|
947
|
+
return null;
|
|
948
|
+
return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-home')) === null || _a === void 0 ? void 0 : _a[0];
|
|
949
|
+
}
|
|
950
|
+
get backBtnElement() {
|
|
951
|
+
var _a;
|
|
952
|
+
if (!this.navigationBarElement)
|
|
953
|
+
return null;
|
|
954
|
+
return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-back')) === null || _a === void 0 ? void 0 : _a[0];
|
|
955
|
+
}
|
|
956
|
+
get titleElement() {
|
|
957
|
+
var _a;
|
|
958
|
+
if (!this.navigationBarElement)
|
|
959
|
+
return null;
|
|
960
|
+
return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-title')) === null || _a === void 0 ? void 0 : _a[0];
|
|
961
|
+
}
|
|
962
|
+
get loadingElement() {
|
|
963
|
+
if (!this.navigationBarElement)
|
|
964
|
+
return null;
|
|
965
|
+
return this.navigationBarElement.getElementsByClassName('taro-navigation-bar-loading')[0];
|
|
966
|
+
}
|
|
967
|
+
init() {
|
|
968
|
+
var _a, _b;
|
|
969
|
+
this.setNavigationBarElement();
|
|
970
|
+
if (!this.navigationBarElement)
|
|
971
|
+
return;
|
|
972
|
+
(_a = this.homeBtnElement) === null || _a === void 0 ? void 0 : _a.addEventListener('click', this.toHomeFn.bind(this));
|
|
973
|
+
(_b = this.backBtnElement) === null || _b === void 0 ? void 0 : _b.addEventListener('click', this.backFn.bind(this));
|
|
974
|
+
}
|
|
975
|
+
setNavigationBarElement() {
|
|
976
|
+
this.navigationBarElement = document.getElementById('taro-navigation-bar');
|
|
977
|
+
}
|
|
978
|
+
load() {
|
|
979
|
+
this.setCacheValue();
|
|
980
|
+
this.setTitle();
|
|
981
|
+
this.setNavigationBarVisible();
|
|
982
|
+
this.setFnBtnState();
|
|
983
|
+
this.setNavigationBarBackground();
|
|
984
|
+
this.setNavigationBarTextStyle();
|
|
985
|
+
this.setNavigationLoading();
|
|
986
|
+
}
|
|
987
|
+
setCacheValue() {
|
|
988
|
+
const currentPage = this.pageContext.originPathname;
|
|
989
|
+
if (typeof this.cache[currentPage] !== 'object') {
|
|
990
|
+
this.cache[currentPage] = {};
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
setFnBtnState() {
|
|
994
|
+
const currentRouter = this.pageContext.currentPage;
|
|
995
|
+
if (this.pageContext.isTabBar(currentRouter) || this.pageContext.homePage === currentRouter) {
|
|
996
|
+
this.fnBtnToggleToNone();
|
|
997
|
+
}
|
|
998
|
+
else if (stacks.length > 1) {
|
|
999
|
+
this.fnBtnToggleToBack();
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
this.fnBtnToggleToHome();
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
shiftLoadingState(show) {
|
|
1006
|
+
if (!this.loadingElement)
|
|
1007
|
+
return;
|
|
1008
|
+
if (show) {
|
|
1009
|
+
this.loadingElement.classList.add('taro-navigation-bar-loading-show');
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
this.loadingElement.classList.remove('taro-navigation-bar-loading-show');
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
setNavigationLoading(show) {
|
|
1016
|
+
var _a;
|
|
1017
|
+
if (!this.navigationBarElement)
|
|
1018
|
+
return;
|
|
1019
|
+
const currentPage = this.pageContext.originPathname;
|
|
1020
|
+
let isShow;
|
|
1021
|
+
if (typeof show === 'boolean') {
|
|
1022
|
+
isShow = show;
|
|
1023
|
+
this.cache[currentPage] &&
|
|
1024
|
+
(this.cache[currentPage].loading = isShow);
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
const cacheValue = (_a = this.cache[currentPage]) === null || _a === void 0 ? void 0 : _a.loading;
|
|
1028
|
+
if (typeof cacheValue === 'boolean') {
|
|
1029
|
+
isShow = cacheValue;
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
// 默认值为 false
|
|
1033
|
+
isShow = false;
|
|
1034
|
+
this.cache[currentPage] &&
|
|
1035
|
+
(this.cache[currentPage].loading = isShow);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
this.shiftLoadingState(isShow);
|
|
1039
|
+
}
|
|
1040
|
+
setNavigationBarBackground(backgroundColor) {
|
|
1041
|
+
var _a, _b, _c;
|
|
1042
|
+
if (!this.navigationBarElement)
|
|
1043
|
+
return;
|
|
1044
|
+
const currentPage = this.pageContext.originPathname;
|
|
1045
|
+
let color;
|
|
1046
|
+
if (typeof backgroundColor === 'string') {
|
|
1047
|
+
color = backgroundColor;
|
|
1048
|
+
this.cache[currentPage] &&
|
|
1049
|
+
(this.cache[currentPage].backgroundColor = color);
|
|
1050
|
+
}
|
|
1051
|
+
else {
|
|
1052
|
+
const cacheValue = (_a = this.cache[currentPage]) === null || _a === void 0 ? void 0 : _a.backgroundColor;
|
|
1053
|
+
if (typeof cacheValue === 'string') {
|
|
1054
|
+
color = cacheValue;
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
color = ((_c = (_b = this.pageContext.config) === null || _b === void 0 ? void 0 : _b.window) === null || _c === void 0 ? void 0 : _c.navigationBarBackgroundColor) || '#000000';
|
|
1058
|
+
this.cache[currentPage] &&
|
|
1059
|
+
(this.cache[currentPage].backgroundColor = color);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
this.navigationBarElement.style.background = color;
|
|
1063
|
+
}
|
|
1064
|
+
setNavigationBarTextStyle(fontColor) {
|
|
1065
|
+
var _a, _b, _c;
|
|
1066
|
+
if (!this.navigationBarElement)
|
|
1067
|
+
return;
|
|
1068
|
+
const currentPage = this.pageContext.originPathname;
|
|
1069
|
+
let color;
|
|
1070
|
+
if (typeof fontColor === 'string') {
|
|
1071
|
+
color = fontColor;
|
|
1072
|
+
this.cache[currentPage] &&
|
|
1073
|
+
(this.cache[currentPage].fontColor = color);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
const cacheValue = (_a = this.cache[currentPage]) === null || _a === void 0 ? void 0 : _a.fontColor;
|
|
1077
|
+
if (typeof cacheValue === 'string') {
|
|
1078
|
+
color = cacheValue;
|
|
1079
|
+
}
|
|
1080
|
+
else {
|
|
1081
|
+
color = ((_c = (_b = this.pageContext.config) === null || _b === void 0 ? void 0 : _b.window) === null || _c === void 0 ? void 0 : _c.navigationBarTextStyle) || 'white';
|
|
1082
|
+
this.cache[currentPage] &&
|
|
1083
|
+
(this.cache[currentPage].fontColor = color);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
this.navigationBarElement.style.color = color;
|
|
1087
|
+
}
|
|
1088
|
+
setTitle(title) {
|
|
1089
|
+
var _a, _b, _c;
|
|
1090
|
+
const currentPage = this.pageContext.originPathname;
|
|
1091
|
+
let proceedTitle;
|
|
1092
|
+
if (typeof title === 'string') {
|
|
1093
|
+
proceedTitle = title;
|
|
1094
|
+
this.cache[currentPage] &&
|
|
1095
|
+
(this.cache[currentPage].title = proceedTitle);
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
const cacheValue = (_a = this.cache[currentPage]) === null || _a === void 0 ? void 0 : _a.title;
|
|
1099
|
+
if (typeof cacheValue === 'string') {
|
|
1100
|
+
proceedTitle = cacheValue;
|
|
1101
|
+
}
|
|
1102
|
+
else {
|
|
1103
|
+
proceedTitle = (_c = (_b = this.pageContext.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationBarTitleText) !== null && _c !== void 0 ? _c : document.title;
|
|
1104
|
+
this.cache[currentPage] &&
|
|
1105
|
+
(this.cache[currentPage].title = proceedTitle);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
if (process.env.SUPPORT_DINGTALK_NAVIGATE !== 'disabled' && isDingTalk()) {
|
|
1109
|
+
if (!this.isLoadDdEntry) {
|
|
1110
|
+
this.isLoadDdEntry = true;
|
|
1111
|
+
require('dingtalk-jsapi/platform');
|
|
1112
|
+
}
|
|
1113
|
+
const setDingTitle = require('dingtalk-jsapi/api/biz/navigation/setTitle').default;
|
|
1114
|
+
setDingTitle({ proceedTitle });
|
|
1115
|
+
}
|
|
1116
|
+
document.title = proceedTitle;
|
|
1117
|
+
if (!this.titleElement)
|
|
1118
|
+
return;
|
|
1119
|
+
this.titleElement.innerHTML = proceedTitle;
|
|
1120
|
+
}
|
|
1121
|
+
fnBtnToggleToHome() {
|
|
1122
|
+
if (!this.navigationBarElement)
|
|
1123
|
+
return;
|
|
1124
|
+
this.navigationBarElement.classList.add('taro-navigation-bar-home-icon');
|
|
1125
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon');
|
|
1126
|
+
}
|
|
1127
|
+
fnBtnToggleToBack() {
|
|
1128
|
+
if (!this.navigationBarElement)
|
|
1129
|
+
return;
|
|
1130
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon');
|
|
1131
|
+
this.navigationBarElement.classList.add('taro-navigation-bar-back-icon');
|
|
1132
|
+
}
|
|
1133
|
+
fnBtnToggleToNone() {
|
|
1134
|
+
if (!this.navigationBarElement)
|
|
1135
|
+
return;
|
|
1136
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon');
|
|
1137
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon');
|
|
1138
|
+
}
|
|
1139
|
+
setNavigationBarVisible(show) {
|
|
1140
|
+
var _a, _b;
|
|
1141
|
+
if (!this.navigationBarElement)
|
|
1142
|
+
return;
|
|
1143
|
+
let shouldShow;
|
|
1144
|
+
if (typeof show === 'boolean') {
|
|
1145
|
+
shouldShow = show;
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
shouldShow = (_a = this.pageContext.config.window) === null || _a === void 0 ? void 0 : _a.navigationStyle;
|
|
1149
|
+
if (typeof ((_b = this.pageContext.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationStyle) === 'string') {
|
|
1150
|
+
shouldShow = this.pageContext.pageConfig.navigationStyle;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (shouldShow === 'default') {
|
|
1154
|
+
this.navigationBarElement.classList.add('taro-navigation-bar-show');
|
|
1155
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-hide');
|
|
1156
|
+
}
|
|
1157
|
+
else {
|
|
1158
|
+
this.navigationBarElement.classList.add('taro-navigation-bar-hide');
|
|
1159
|
+
this.navigationBarElement.classList.remove('taro-navigation-bar-show');
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
812
1164
|
/* eslint-disable dot-notation */
|
|
813
1165
|
class PageHandler {
|
|
814
|
-
constructor(config) {
|
|
1166
|
+
constructor(config, history) {
|
|
1167
|
+
this.history = history;
|
|
815
1168
|
this.defaultAnimation = { duration: 300, delay: 50 };
|
|
816
1169
|
this.config = config;
|
|
817
|
-
this.homePage = getHomePage(this.routes[0].path, this.basename, this.customRoutes, this.config.entryPagePath);
|
|
1170
|
+
this.homePage = runtime.getHomePage(this.routes[0].path, this.basename, this.customRoutes, this.config.entryPagePath);
|
|
1171
|
+
this.originHomePage = this.config.entryPagePath || this.routes[0].path || this.basename;
|
|
818
1172
|
this.mount();
|
|
1173
|
+
this.navigationBarHandler = new NavigationBarHandler(this);
|
|
819
1174
|
}
|
|
820
1175
|
get currentPage() {
|
|
821
|
-
const routePath = getCurrentPage(this.routerMode, this.basename);
|
|
1176
|
+
const routePath = runtime.getCurrentPage(this.routerMode, this.basename);
|
|
822
1177
|
return routePath === '/' ? this.homePage : routePath;
|
|
823
1178
|
}
|
|
824
1179
|
get appId() { return this.config.appId || 'app'; }
|
|
@@ -847,19 +1202,19 @@ class PageHandler {
|
|
|
847
1202
|
}
|
|
848
1203
|
set pathname(p) { this.router.pathname = p; }
|
|
849
1204
|
get pathname() { return this.router.pathname; }
|
|
1205
|
+
// Note: 把 pathname 转换为原始路径,主要是处理 customRoutes 和 basename
|
|
1206
|
+
get originPathname() { return routesAlias.getOrigin(runtime.addLeadingSlash(runtime.stripBasename(this.pathname, this.basename))); }
|
|
850
1207
|
get basename() { return this.router.basename || ''; }
|
|
851
1208
|
get pageConfig() {
|
|
852
|
-
const
|
|
853
|
-
const homePage = addLeadingSlash(this.homePage);
|
|
1209
|
+
const homePage = runtime.addLeadingSlash(this.homePage);
|
|
854
1210
|
return this.routes.find(r => {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
return [pagePath, homePage].includes(routePath) || ((_a = routesAlias.getConfig(pagePath)) === null || _a === void 0 ? void 0 : _a.includes(routePath));
|
|
1211
|
+
const pagePath = runtime.addLeadingSlash(r.path);
|
|
1212
|
+
return [pagePath, homePage].includes(this.originPathname);
|
|
858
1213
|
});
|
|
859
1214
|
}
|
|
860
1215
|
isTabBar(pathname) {
|
|
861
1216
|
var _a;
|
|
862
|
-
const routePath = addLeadingSlash(stripBasename(pathname, this.basename)).split('?')[0];
|
|
1217
|
+
const routePath = runtime.addLeadingSlash(runtime.stripBasename(pathname, this.basename)).split('?')[0];
|
|
863
1218
|
const pagePath = ((_a = Object.entries(this.customRoutes).find(([, target]) => {
|
|
864
1219
|
if (typeof target === 'string') {
|
|
865
1220
|
return target === routePath;
|
|
@@ -869,11 +1224,19 @@ class PageHandler {
|
|
|
869
1224
|
}
|
|
870
1225
|
return false;
|
|
871
1226
|
})) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
|
|
872
|
-
return !!pagePath && this.tabBarList.some(t => stripTrailing(t.pagePath) === pagePath);
|
|
1227
|
+
return !!pagePath && this.tabBarList.some(t => runtime.stripTrailing(t.pagePath) === pagePath);
|
|
1228
|
+
}
|
|
1229
|
+
isDefaultNavigationStyle() {
|
|
1230
|
+
var _a, _b;
|
|
1231
|
+
let style = (_a = this.config.window) === null || _a === void 0 ? void 0 : _a.navigationStyle;
|
|
1232
|
+
if (typeof ((_b = this.pageConfig) === null || _b === void 0 ? void 0 : _b.navigationStyle) === 'string') {
|
|
1233
|
+
style = this.pageConfig.navigationStyle;
|
|
1234
|
+
}
|
|
1235
|
+
return style !== 'custom';
|
|
873
1236
|
}
|
|
874
1237
|
isSamePage(page) {
|
|
875
|
-
const routePath = stripBasename(this.pathname, this.basename);
|
|
876
|
-
const pagePath = stripBasename(page === null || page === void 0 ? void 0 : page.path, this.basename);
|
|
1238
|
+
const routePath = runtime.stripBasename(this.pathname, this.basename);
|
|
1239
|
+
const pagePath = runtime.stripBasename(page === null || page === void 0 ? void 0 : page.path, this.basename);
|
|
877
1240
|
return pagePath.startsWith(routePath + '?');
|
|
878
1241
|
}
|
|
879
1242
|
get search() {
|
|
@@ -903,46 +1266,17 @@ class PageHandler {
|
|
|
903
1266
|
getQuery(stamp = '', search = '', options = {}) {
|
|
904
1267
|
search = search ? `${search}&${this.search}` : this.search;
|
|
905
1268
|
const query = search
|
|
906
|
-
?
|
|
1269
|
+
? queryString.parse(search, { decode: false })
|
|
907
1270
|
: {};
|
|
908
1271
|
query.stamp = stamp;
|
|
909
1272
|
return Object.assign(Object.assign({}, query), options);
|
|
910
1273
|
}
|
|
911
1274
|
mount() {
|
|
912
|
-
|
|
1275
|
+
setHistory(this.history, this.basename);
|
|
913
1276
|
this.pathname = exports.history.location.pathname;
|
|
1277
|
+
// Note: 注入页面样式
|
|
914
1278
|
this.animation && loadAnimateStyle(this.animationDuration);
|
|
915
|
-
loadRouterStyle(this.usingWindowScroll);
|
|
916
|
-
const appId = this.appId;
|
|
917
|
-
let app = document.getElementById(appId);
|
|
918
|
-
let isPosition = true;
|
|
919
|
-
if (!app) {
|
|
920
|
-
app = document.createElement('div');
|
|
921
|
-
app.id = appId;
|
|
922
|
-
isPosition = false;
|
|
923
|
-
}
|
|
924
|
-
const appWrapper = (app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body;
|
|
925
|
-
app.classList.add('taro_router');
|
|
926
|
-
if (this.tabBarList.length > 1) {
|
|
927
|
-
const container = document.createElement('div');
|
|
928
|
-
container.classList.add('taro-tabbar__container');
|
|
929
|
-
container.id = 'container';
|
|
930
|
-
const panel = document.createElement('div');
|
|
931
|
-
panel.classList.add('taro-tabbar__panel');
|
|
932
|
-
panel.appendChild(app.cloneNode(true));
|
|
933
|
-
container.appendChild(panel);
|
|
934
|
-
if (!isPosition) {
|
|
935
|
-
appWrapper.appendChild(container);
|
|
936
|
-
}
|
|
937
|
-
else {
|
|
938
|
-
appWrapper.replaceChild(container, app);
|
|
939
|
-
}
|
|
940
|
-
initTabbar(this.config);
|
|
941
|
-
}
|
|
942
|
-
else {
|
|
943
|
-
if (!isPosition)
|
|
944
|
-
appWrapper.appendChild(app);
|
|
945
|
-
}
|
|
1279
|
+
loadRouterStyle(this.tabBarList.length > 1, this.usingWindowScroll, this.router.enhanceAnimation);
|
|
946
1280
|
}
|
|
947
1281
|
onReady(page, onLoad = true) {
|
|
948
1282
|
var _a;
|
|
@@ -977,19 +1311,24 @@ class PageHandler {
|
|
|
977
1311
|
if (pageEl) {
|
|
978
1312
|
pageEl.classList.remove('taro_page_shade');
|
|
979
1313
|
this.isTabBar(this.pathname) && pageEl.classList.add('taro_tabbar_page');
|
|
1314
|
+
this.isDefaultNavigationStyle() && pageEl.classList.add('taro_navigation_page');
|
|
980
1315
|
this.addAnimation(pageEl, pageNo === 0);
|
|
981
1316
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
1317
|
+
this.navigationBarHandler.load();
|
|
982
1318
|
this.bindPageEvents(page, pageConfig);
|
|
983
1319
|
this.triggerRouterChange();
|
|
984
1320
|
}
|
|
985
1321
|
else {
|
|
1322
|
+
// FIXME 在 iOS 端快速切换页面时,可能不会执行回调注入对应类名导致 TabBar 白屏
|
|
986
1323
|
(_b = page.onLoad) === null || _b === void 0 ? void 0 : _b.call(page, param, () => {
|
|
987
1324
|
var _a;
|
|
988
1325
|
pageEl = this.getPageContainer(page);
|
|
989
1326
|
this.isTabBar(this.pathname) && (pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_tabbar_page'));
|
|
1327
|
+
this.isDefaultNavigationStyle() && (pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_navigation_page'));
|
|
990
1328
|
this.addAnimation(pageEl, pageNo === 0);
|
|
991
|
-
this.onReady(page, true);
|
|
992
1329
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
1330
|
+
this.navigationBarHandler.load();
|
|
1331
|
+
this.onReady(page, true);
|
|
993
1332
|
this.bindPageEvents(page, pageConfig);
|
|
994
1333
|
this.triggerRouterChange();
|
|
995
1334
|
});
|
|
@@ -1043,6 +1382,7 @@ class PageHandler {
|
|
|
1043
1382
|
pageEl.classList.remove('taro_page_shade');
|
|
1044
1383
|
this.addAnimation(pageEl, pageNo === 0);
|
|
1045
1384
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
1385
|
+
this.navigationBarHandler.load();
|
|
1046
1386
|
this.bindPageEvents(page, pageConfig);
|
|
1047
1387
|
this.triggerRouterChange();
|
|
1048
1388
|
}
|
|
@@ -1051,31 +1391,44 @@ class PageHandler {
|
|
|
1051
1391
|
var _a;
|
|
1052
1392
|
pageEl = this.getPageContainer(page);
|
|
1053
1393
|
this.addAnimation(pageEl, pageNo === 0);
|
|
1054
|
-
this.onReady(page, false);
|
|
1055
1394
|
(_a = page.onShow) === null || _a === void 0 ? void 0 : _a.call(page);
|
|
1395
|
+
this.navigationBarHandler.load();
|
|
1396
|
+
this.onReady(page, false);
|
|
1056
1397
|
this.bindPageEvents(page, pageConfig);
|
|
1057
1398
|
this.triggerRouterChange();
|
|
1058
1399
|
});
|
|
1059
1400
|
}
|
|
1060
1401
|
}
|
|
1061
|
-
hide(page) {
|
|
1062
|
-
var _a;
|
|
1402
|
+
hide(page, animation = false) {
|
|
1403
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1063
1404
|
if (!page)
|
|
1064
1405
|
return;
|
|
1065
1406
|
// NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
|
|
1066
1407
|
const pageEl = this.getPageContainer(page);
|
|
1067
1408
|
if (pageEl) {
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1409
|
+
if (animation) {
|
|
1410
|
+
if (this.hideTimer) {
|
|
1411
|
+
clearTimeout(this.hideTimer);
|
|
1412
|
+
this.hideTimer = null;
|
|
1413
|
+
(_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');
|
|
1414
|
+
}
|
|
1415
|
+
this.lastHidePage = pageEl;
|
|
1416
|
+
this.hideTimer = setTimeout(() => {
|
|
1417
|
+
this.hideTimer = null;
|
|
1418
|
+
pageEl.classList.add('taro_page_shade');
|
|
1419
|
+
}, this.animationDuration + this.animationDelay);
|
|
1420
|
+
(_d = page.onHide) === null || _d === void 0 ? void 0 : _d.call(page);
|
|
1072
1421
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1422
|
+
else {
|
|
1423
|
+
if (this.hideTimer) {
|
|
1424
|
+
clearTimeout(this.hideTimer);
|
|
1425
|
+
this.hideTimer = null;
|
|
1426
|
+
(_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');
|
|
1427
|
+
}
|
|
1428
|
+
(_h = page.onHide) === null || _h === void 0 ? void 0 : _h.call(page);
|
|
1076
1429
|
pageEl.classList.add('taro_page_shade');
|
|
1077
|
-
|
|
1078
|
-
|
|
1430
|
+
this.lastHidePage = pageEl;
|
|
1431
|
+
}
|
|
1079
1432
|
}
|
|
1080
1433
|
else {
|
|
1081
1434
|
setTimeout(() => this.hide(page), 0);
|
|
@@ -1139,24 +1492,28 @@ class PageHandler {
|
|
|
1139
1492
|
|
|
1140
1493
|
const createStampId = runtime.incrementId();
|
|
1141
1494
|
let launchStampId = createStampId();
|
|
1142
|
-
function createRouter(app, config, framework) {
|
|
1495
|
+
function createRouter(history$1, app, config, framework) {
|
|
1143
1496
|
var _a, _b;
|
|
1144
1497
|
if (typeof app.onUnhandledRejection === 'function') {
|
|
1145
1498
|
window.addEventListener('unhandledrejection', app.onUnhandledRejection);
|
|
1146
1499
|
}
|
|
1147
1500
|
RouterConfig.config = config;
|
|
1148
|
-
const handler = new PageHandler(config);
|
|
1501
|
+
const handler = new PageHandler(config, history$1);
|
|
1502
|
+
// Note: 弱网情况下,快速切换 tab,会造成同个页面实例被多次挂在到页面上,原因是资源请求是异步的,短时间内发起多个请求,
|
|
1503
|
+
// 会在资源加载完成后,同时走到挂载的逻辑,造成 pageStampId 更新不及时,两个 page 的Id 相同,后面很多操作是通过 getElementById 来进行的
|
|
1504
|
+
// 所以需要加一个锁来应对这个情况
|
|
1505
|
+
const pageLock = {};
|
|
1149
1506
|
routesAlias.set(handler.router.customRoutes);
|
|
1150
1507
|
const basename = handler.router.basename;
|
|
1151
1508
|
const routes = handler.routes.map(route => {
|
|
1152
|
-
const routePath = addLeadingSlash(route.path);
|
|
1509
|
+
const routePath = runtime.addLeadingSlash(route.path);
|
|
1153
1510
|
const paths = routesAlias.getAll(routePath);
|
|
1154
1511
|
return {
|
|
1155
1512
|
path: paths.length < 1 ? routePath : paths,
|
|
1156
1513
|
action: route.load
|
|
1157
1514
|
};
|
|
1158
1515
|
});
|
|
1159
|
-
const router = new
|
|
1516
|
+
const router = new UniversalRouter(routes, { baseUrl: basename || '' });
|
|
1160
1517
|
const launchParam = {
|
|
1161
1518
|
path: handler.currentPage,
|
|
1162
1519
|
query: handler.getQuery(launchStampId),
|
|
@@ -1167,29 +1524,35 @@ function createRouter(app, config, framework) {
|
|
|
1167
1524
|
runtime.eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
1168
1525
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
1169
1526
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
1170
|
-
const render = (
|
|
1171
|
-
var
|
|
1172
|
-
|
|
1173
|
-
|
|
1527
|
+
const render = (_c) => tslib.__awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
1528
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1529
|
+
// Note: 由于下面有异步加载操作 先不要在这里去设置 handler.pathname
|
|
1530
|
+
const currentPathname = decodeURI(location.pathname);
|
|
1531
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
1174
1532
|
window.scrollTo(0, 0);
|
|
1175
1533
|
runtime.eventCenter.trigger('__taroRouterChange', {
|
|
1176
1534
|
toLocation: {
|
|
1177
|
-
path:
|
|
1535
|
+
path: currentPathname
|
|
1178
1536
|
}
|
|
1179
1537
|
});
|
|
1180
|
-
let element, params;
|
|
1538
|
+
let element, context, params;
|
|
1539
|
+
const routerPath = handler.router.forcePath || currentPathname;
|
|
1540
|
+
pageLock[routerPath] = typeof pageLock[routerPath] === 'number' ? pageLock[routerPath] + 1 : 1;
|
|
1541
|
+
const currentLock = pageLock[routerPath];
|
|
1542
|
+
let postLock;
|
|
1181
1543
|
try {
|
|
1182
|
-
const result = yield router.resolve(
|
|
1183
|
-
[element, , params] = yield Promise.all(result);
|
|
1544
|
+
const result = yield router.resolve(routerPath);
|
|
1545
|
+
[element, context, params] = yield Promise.all(result);
|
|
1546
|
+
postLock = pageLock[routerPath];
|
|
1184
1547
|
}
|
|
1185
1548
|
catch (error) {
|
|
1186
1549
|
if (error.status === 404) {
|
|
1187
1550
|
const notFoundEvent = {
|
|
1188
1551
|
isEntryPage: stacks.length === 0,
|
|
1189
|
-
path:
|
|
1552
|
+
path: currentPathname,
|
|
1190
1553
|
query: handler.getQuery(createStampId()),
|
|
1191
1554
|
};
|
|
1192
|
-
(
|
|
1555
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
1193
1556
|
runtime.eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
1194
1557
|
}
|
|
1195
1558
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -1197,22 +1560,36 @@ function createRouter(app, config, framework) {
|
|
|
1197
1560
|
window.location.reload();
|
|
1198
1561
|
}
|
|
1199
1562
|
else {
|
|
1200
|
-
throw
|
|
1563
|
+
throw error;
|
|
1201
1564
|
}
|
|
1202
1565
|
}
|
|
1203
|
-
if (!element)
|
|
1566
|
+
if (!element || currentLock !== postLock)
|
|
1204
1567
|
return;
|
|
1205
|
-
|
|
1206
|
-
|
|
1568
|
+
// Note: 异步结束后,在设置 handler.pathname
|
|
1569
|
+
// context.pathname 在 universal-router 被处理过了,是发起资源请求的时候传入的 pathname,即 await router.resolve(routerPath) 这个 routerPath
|
|
1570
|
+
handler.pathname = context.pathname;
|
|
1571
|
+
const { pathname, pageConfig } = handler;
|
|
1572
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
1573
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
1574
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
1575
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
1207
1576
|
if (pageConfig) {
|
|
1208
|
-
setTitle((_f = pageConfig.navigationBarTitleText) !== null && _f !== void 0 ? _f : document.title);
|
|
1209
1577
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
1210
1578
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
1211
1579
|
}
|
|
1580
|
+
if (typeof pageConfig.navigationStyle === 'string') {
|
|
1581
|
+
navigationStyle = pageConfig.navigationStyle;
|
|
1582
|
+
}
|
|
1583
|
+
if (typeof pageConfig.navigationBarTextStyle === 'string') {
|
|
1584
|
+
navigationBarTextStyle = pageConfig.navigationBarTextStyle;
|
|
1585
|
+
}
|
|
1586
|
+
if (typeof pageConfig.navigationBarBackgroundColor === 'string') {
|
|
1587
|
+
navigationBarBackgroundColor = pageConfig.navigationBarBackgroundColor;
|
|
1588
|
+
}
|
|
1212
1589
|
}
|
|
1590
|
+
runtime.eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
1213
1591
|
const currentPage = runtime.Current.page;
|
|
1214
|
-
const
|
|
1215
|
-
const methodName = (_g = stacks.method) !== null && _g !== void 0 ? _g : '';
|
|
1592
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
1216
1593
|
const cacheTabs = stacks.getTabs();
|
|
1217
1594
|
let shouldLoad = false;
|
|
1218
1595
|
stacks.method = '';
|
|
@@ -1227,10 +1604,11 @@ function createRouter(app, config, framework) {
|
|
|
1227
1604
|
}
|
|
1228
1605
|
shouldLoad = true;
|
|
1229
1606
|
}
|
|
1230
|
-
else if (currentPage && handler.isTabBar(
|
|
1607
|
+
else if (currentPage && handler.isTabBar(pathname)) {
|
|
1231
1608
|
if (handler.isSamePage(currentPage))
|
|
1232
1609
|
return;
|
|
1233
1610
|
if (handler.isTabBar(currentPage.path)) {
|
|
1611
|
+
// NOTE: 从 tabBar 页面切换到 tabBar 页面
|
|
1234
1612
|
handler.hide(currentPage);
|
|
1235
1613
|
stacks.pushTab(currentPage.path.split('?')[0]);
|
|
1236
1614
|
}
|
|
@@ -1244,8 +1622,8 @@ function createRouter(app, config, framework) {
|
|
|
1244
1622
|
handler.unload(currentPage, stacks.length, true);
|
|
1245
1623
|
}
|
|
1246
1624
|
}
|
|
1247
|
-
if (cacheTabs[
|
|
1248
|
-
stacks.popTab(
|
|
1625
|
+
if (cacheTabs[pathname]) {
|
|
1626
|
+
stacks.popTab(pathname);
|
|
1249
1627
|
return handler.show(stacks.getItem(0), pageConfig, 0);
|
|
1250
1628
|
}
|
|
1251
1629
|
shouldLoad = true;
|
|
@@ -1274,11 +1652,11 @@ function createRouter(app, config, framework) {
|
|
|
1274
1652
|
shouldLoad = true;
|
|
1275
1653
|
}
|
|
1276
1654
|
else if (action === 'PUSH') {
|
|
1277
|
-
handler.hide(currentPage);
|
|
1655
|
+
handler.hide(currentPage, true);
|
|
1278
1656
|
shouldLoad = true;
|
|
1279
1657
|
}
|
|
1280
1658
|
if (shouldLoad || stacks.length < 1) {
|
|
1281
|
-
const el = (
|
|
1659
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
1282
1660
|
const loadConfig = Object.assign({}, pageConfig);
|
|
1283
1661
|
const stacksIndex = stacks.length;
|
|
1284
1662
|
delete loadConfig['path'];
|
|
@@ -1297,21 +1675,102 @@ function createRouter(app, config, framework) {
|
|
|
1297
1675
|
handler.load(page, pageConfig, pageStampId, stacksIndex);
|
|
1298
1676
|
}
|
|
1299
1677
|
});
|
|
1300
|
-
const routePath = addLeadingSlash(stripBasename(
|
|
1678
|
+
const routePath = runtime.addLeadingSlash(runtime.stripBasename(history$1.location.pathname, handler.basename));
|
|
1301
1679
|
if (routePath === '/') {
|
|
1302
|
-
|
|
1680
|
+
history$1.replace(prependBasename(handler.homePage + history$1.location.search));
|
|
1303
1681
|
}
|
|
1304
|
-
render({ location:
|
|
1682
|
+
render({ location: history$1.location, action: history.Action.Push });
|
|
1305
1683
|
(_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, launchParam);
|
|
1306
|
-
|
|
1684
|
+
window.addEventListener('visibilitychange', () => {
|
|
1685
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1686
|
+
const currentPath = ((_a = runtime.Current.page) === null || _a === void 0 ? void 0 : _a.path) || '';
|
|
1687
|
+
const path = currentPath.substring(0, currentPath.indexOf('?'));
|
|
1688
|
+
const param = {};
|
|
1689
|
+
// app的 onShow/onHide 生命周期的路径信息为当前页面的路径
|
|
1690
|
+
Object.assign(param, launchParam, { path });
|
|
1691
|
+
if (document.visibilityState === 'visible') {
|
|
1692
|
+
(_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, param);
|
|
1693
|
+
// 单页面app显示后一刻会触发当前 page.onShow 生命周期函数
|
|
1694
|
+
(_d = (_c = runtime.Current.page) === null || _c === void 0 ? void 0 : _c.onShow) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
// 单页面app隐藏前一刻会触发当前 page.onHide 生命周期函数
|
|
1698
|
+
if ((_e = runtime.Current.page) === null || _e === void 0 ? void 0 : _e.path) {
|
|
1699
|
+
runtime.safeExecute((_f = runtime.Current.page) === null || _f === void 0 ? void 0 : _f.path, 'onHide');
|
|
1700
|
+
}
|
|
1701
|
+
(_g = app.onHide) === null || _g === void 0 ? void 0 : _g.call(app, param);
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
return history$1.listen(render);
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
function handleAppMount(config, _, appId = config.appId || 'app') {
|
|
1708
|
+
let app = document.getElementById(appId);
|
|
1709
|
+
let isPosition = true;
|
|
1710
|
+
if (!app) {
|
|
1711
|
+
app = document.createElement('div');
|
|
1712
|
+
app.id = appId;
|
|
1713
|
+
isPosition = false;
|
|
1714
|
+
}
|
|
1715
|
+
const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
|
|
1716
|
+
app.classList.add('taro_router');
|
|
1717
|
+
if (!isPosition)
|
|
1718
|
+
appWrapper.appendChild(app);
|
|
1719
|
+
initNavigationBar(config, appWrapper);
|
|
1720
|
+
}
|
|
1721
|
+
function handleAppMountWithTabbar(config, history, appId = config.appId || 'app') {
|
|
1722
|
+
let app = document.getElementById(appId);
|
|
1723
|
+
let isPosition = true;
|
|
1724
|
+
if (!app) {
|
|
1725
|
+
app = document.createElement('div');
|
|
1726
|
+
app.id = appId;
|
|
1727
|
+
isPosition = false;
|
|
1728
|
+
}
|
|
1729
|
+
const appWrapper = ((app === null || app === void 0 ? void 0 : app.parentNode) || (app === null || app === void 0 ? void 0 : app.parentElement) || document.body);
|
|
1730
|
+
app.classList.add('taro_router');
|
|
1731
|
+
const container = document.createElement('div');
|
|
1732
|
+
container.classList.add('taro-tabbar__container');
|
|
1733
|
+
container.id = 'container';
|
|
1734
|
+
const panel = document.createElement('div');
|
|
1735
|
+
panel.classList.add('taro-tabbar__panel');
|
|
1736
|
+
panel.appendChild(app.cloneNode(true));
|
|
1737
|
+
container.appendChild(panel);
|
|
1738
|
+
if (!isPosition) {
|
|
1739
|
+
appWrapper.appendChild(container);
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
appWrapper.replaceChild(container, app);
|
|
1743
|
+
}
|
|
1744
|
+
initTabbar(config, history);
|
|
1745
|
+
initNavigationBar(config, container);
|
|
1307
1746
|
}
|
|
1308
1747
|
|
|
1748
|
+
Object.defineProperty(exports, "createBrowserHistory", {
|
|
1749
|
+
enumerable: true,
|
|
1750
|
+
get: function () { return history.createBrowserHistory; }
|
|
1751
|
+
});
|
|
1752
|
+
Object.defineProperty(exports, "createHashHistory", {
|
|
1753
|
+
enumerable: true,
|
|
1754
|
+
get: function () { return history.createHashHistory; }
|
|
1755
|
+
});
|
|
1756
|
+
exports.createMpaHistory = createMpaHistory;
|
|
1309
1757
|
exports.createMultiRouter = createMultiRouter;
|
|
1310
1758
|
exports.createRouter = createRouter;
|
|
1311
1759
|
exports.getCurrentPages = getCurrentPages;
|
|
1760
|
+
exports.handleAppMount = handleAppMount;
|
|
1761
|
+
exports.handleAppMountWithTabbar = handleAppMountWithTabbar;
|
|
1762
|
+
exports.isDingTalk = isDingTalk;
|
|
1763
|
+
exports.isWeixin = isWeixin;
|
|
1312
1764
|
exports.navigateBack = navigateBack;
|
|
1313
1765
|
exports.navigateTo = navigateTo;
|
|
1766
|
+
exports.prependBasename = prependBasename;
|
|
1314
1767
|
exports.reLaunch = reLaunch;
|
|
1315
1768
|
exports.redirectTo = redirectTo;
|
|
1769
|
+
exports.routesAlias = routesAlias;
|
|
1770
|
+
exports.setHistory = setHistory;
|
|
1771
|
+
exports.setHistoryMode = setHistoryMode;
|
|
1772
|
+
exports.setMpaTitle = setMpaTitle;
|
|
1773
|
+
exports.setNavigationBarLoading = setNavigationBarLoading;
|
|
1774
|
+
exports.setNavigationBarStyle = setNavigationBarStyle;
|
|
1775
|
+
exports.setTitle = setTitle;
|
|
1316
1776
|
exports.switchTab = switchTab;
|
|
1317
|
-
//# sourceMappingURL=index.cjs.js.map
|