@tarojs/router 4.0.0-beta.61 → 4.0.0-beta.63

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.
@@ -1,3 +1,5 @@
1
+ import { loadNavigationBarStyle } from './style.js';
2
+
1
3
  const home_svg_str = `
2
4
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
5
  <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"/>
@@ -7,21 +9,36 @@ const back_svg_str = `
7
9
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
8
10
  <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"/>
9
11
  </svg>
10
-
11
12
  `;
12
- function initNavigationBar(container) {
13
- const navigationBar = document.createElement('taro-navigation-bar-wrap');
13
+ const loading_svg_str = `
14
+ <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>
15
+ `;
16
+ function initNavigationBar(config, container) {
17
+ if (config.router.mode === 'multi')
18
+ return;
19
+ const navigationBar = document.createElement('div');
14
20
  navigationBar.classList.add('taro-navigation-bar-no-icon');
15
- const navigationBarBackBtn = document.createElement('taro-navigation-bar-back');
16
- const navigationBarHomeBtn = document.createElement('taro-navigation-bar-home');
21
+ const navigationBarBackBtn = document.createElement('div');
22
+ navigationBarBackBtn.classList.add('taro-navigation-bar-back');
23
+ const navigationBarHomeBtn = document.createElement('div');
24
+ navigationBarHomeBtn.classList.add('taro-navigation-bar-home');
17
25
  navigationBarBackBtn.innerHTML = back_svg_str;
18
26
  navigationBarHomeBtn.innerHTML = home_svg_str;
19
- const navigationBarTitle = document.createElement('taro-navigation-bar-title');
27
+ const navigationBarTitleWrap = document.createElement('div');
28
+ navigationBarTitleWrap.classList.add('taro-navigation-bar-title-wrap');
29
+ const navigationBarLoading = document.createElement('div');
30
+ navigationBarLoading.classList.add('taro-navigation-bar-loading');
31
+ navigationBarLoading.innerHTML = loading_svg_str;
32
+ const navigationBarTitle = document.createElement('div');
33
+ navigationBarTitle.classList.add('taro-navigation-bar-title');
34
+ navigationBarTitleWrap.appendChild(navigationBarLoading);
35
+ navigationBarTitleWrap.appendChild(navigationBarTitle);
20
36
  navigationBar.appendChild(navigationBarHomeBtn);
21
37
  navigationBar.appendChild(navigationBarBackBtn);
22
- navigationBar.appendChild(navigationBarTitle);
38
+ navigationBar.appendChild(navigationBarTitleWrap);
23
39
  navigationBar.id = 'taro-navigation-bar';
24
40
  container.prepend(navigationBar);
41
+ loadNavigationBarStyle();
25
42
  }
26
43
 
27
44
  export { initNavigationBar };
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from 'tslib';
2
- import { incrementId, eventCenter, createPageConfig, hooks, stringify } from '@tarojs/runtime';
2
+ import { incrementId, eventCenter, createPageConfig, hooks, stringify, Current } from '@tarojs/runtime';
3
3
  import '../utils/index.js';
4
4
  import { RouterConfig } from './index.js';
5
5
  import MultiPageHandler from './multi-page.js';
@@ -21,7 +21,7 @@ function createMultiRouter(history, app, config, framework) {
21
21
  if (typeof app.onUnhandledRejection === 'function') {
22
22
  window.addEventListener('unhandledrejection', app.onUnhandledRejection);
23
23
  }
24
- eventCenter.on('__taroH5SetNavigationTitle', setMpaTitle);
24
+ eventCenter.on('__taroH5SetNavigationBarTitle', setMpaTitle);
25
25
  RouterConfig.config = config;
26
26
  const handler = new MultiPageHandler(config, history);
27
27
  const launchParam = {
@@ -68,12 +68,17 @@ function createMultiRouter(history, app, config, framework) {
68
68
  handler.load(page, pageConfig);
69
69
  (_f = app.onShow) === null || _f === void 0 ? void 0 : _f.call(app, launchParam);
70
70
  window.addEventListener('visibilitychange', () => {
71
- var _a, _b;
71
+ var _a, _b, _c;
72
+ const currentPath = ((_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) || '';
73
+ const path = currentPath.substring(0, currentPath.indexOf('?'));
74
+ const param = {};
75
+ // app的 onShow/onHide 生命周期的路径信息为当前页面的路径
76
+ Object.assign(param, launchParam, { path });
72
77
  if (document.visibilityState === 'visible') {
73
- (_a = app.onShow) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
78
+ (_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, param);
74
79
  }
75
80
  else {
76
- (_b = app.onHide) === null || _b === void 0 ? void 0 : _b.call(app, launchParam);
81
+ (_c = app.onHide) === null || _c === void 0 ? void 0 : _c.call(app, param);
77
82
  }
78
83
  });
79
84
  });
@@ -4,10 +4,11 @@ interface NavigationBarCache {
4
4
  fontColor?: string;
5
5
  title?: string;
6
6
  show?: boolean;
7
+ loading?: boolean;
7
8
  }
8
9
  declare class NavigationBarHandler {
9
10
  pageContext: PageHandler;
10
- navigationBarElement: Element;
11
+ navigationBarElement: HTMLElement;
11
12
  cache: Record<string, NavigationBarCache>;
12
13
  isLoadDdEntry: boolean;
13
14
  constructor(pageContext: PageHandler);
@@ -16,11 +17,14 @@ declare class NavigationBarHandler {
16
17
  get homeBtnElement(): Element | null;
17
18
  get backBtnElement(): Element | null;
18
19
  get titleElement(): Element | null;
20
+ get loadingElement(): Element | null;
19
21
  init(): void;
20
22
  setNavigationBarElement(): void;
21
23
  load(): void;
22
24
  setCacheValue(): void;
23
25
  setFnBtnState(): void;
26
+ shiftLoadingState(show: boolean): void;
27
+ setNavigationLoading(show?: boolean): void;
24
28
  setNavigationBarBackground(backgroundColor?: string): void;
25
29
  setNavigationBarTextStyle(fontColor?: string): void;
26
30
  setTitle(title?: any): void;
@@ -1,6 +1,5 @@
1
1
  import { eventCenter } from '@tarojs/runtime';
2
2
  import { reLaunch, navigateBack } from '../api.js';
3
- import { loadNavigationBarStyle } from '../style.js';
4
3
  import '../utils/index.js';
5
4
  import stacks from './stack.js';
6
5
  import { isDingTalk } from '../utils/navigate.js';
@@ -11,10 +10,12 @@ class NavigationBarHandler {
11
10
  this.cache = {};
12
11
  this.pageContext = pageContext;
13
12
  this.init();
14
- loadNavigationBarStyle();
15
- eventCenter.on('__taroH5SetNavigationTitle', (title) => {
13
+ eventCenter.on('__taroH5SetNavigationBarTitle', (title) => {
16
14
  this.setTitle(title);
17
15
  });
16
+ eventCenter.on('__taroH5setNavigationBarLoading', (loading) => {
17
+ this.setNavigationLoading(loading);
18
+ });
18
19
  eventCenter.on('__taroH5setNavigationBarColor', ({ backgroundColor, frontColor }) => {
19
20
  if (typeof backgroundColor === 'string')
20
21
  this.setNavigationBarBackground(backgroundColor);
@@ -32,19 +33,24 @@ class NavigationBarHandler {
32
33
  var _a;
33
34
  if (!this.navigationBarElement)
34
35
  return null;
35
- return (_a = this.navigationBarElement.getElementsByTagName('taro-navigation-bar-home')) === null || _a === void 0 ? void 0 : _a[0];
36
+ return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-home')) === null || _a === void 0 ? void 0 : _a[0];
36
37
  }
37
38
  get backBtnElement() {
38
39
  var _a;
39
40
  if (!this.navigationBarElement)
40
41
  return null;
41
- return (_a = this.navigationBarElement.getElementsByTagName('taro-navigation-bar-back')) === null || _a === void 0 ? void 0 : _a[0];
42
+ return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-back')) === null || _a === void 0 ? void 0 : _a[0];
42
43
  }
43
44
  get titleElement() {
44
45
  var _a;
45
46
  if (!this.navigationBarElement)
46
47
  return null;
47
- return (_a = this.navigationBarElement.getElementsByTagName('taro-navigation-bar-title')) === null || _a === void 0 ? void 0 : _a[0];
48
+ return (_a = this.navigationBarElement.getElementsByClassName('taro-navigation-bar-title')) === null || _a === void 0 ? void 0 : _a[0];
49
+ }
50
+ get loadingElement() {
51
+ if (!this.navigationBarElement)
52
+ return null;
53
+ return this.navigationBarElement.getElementsByClassName('taro-navigation-bar-loading')[0];
48
54
  }
49
55
  init() {
50
56
  var _a, _b;
@@ -55,8 +61,7 @@ class NavigationBarHandler {
55
61
  (_b = this.backBtnElement) === null || _b === void 0 ? void 0 : _b.addEventListener('click', this.backFn.bind(this));
56
62
  }
57
63
  setNavigationBarElement() {
58
- var _a;
59
- this.navigationBarElement = (_a = document.getElementsByTagName('taro-navigation-bar-wrap')) === null || _a === void 0 ? void 0 : _a[0];
64
+ this.navigationBarElement = document.getElementById('taro-navigation-bar');
60
65
  }
61
66
  load() {
62
67
  this.setCacheValue();
@@ -65,6 +70,7 @@ class NavigationBarHandler {
65
70
  this.setFnBtnState();
66
71
  this.setNavigationBarBackground();
67
72
  this.setNavigationBarTextStyle();
73
+ this.setNavigationLoading();
68
74
  }
69
75
  setCacheValue() {
70
76
  const currentPage = this.pageContext.currentPage;
@@ -84,6 +90,41 @@ class NavigationBarHandler {
84
90
  this.fnBtnToggleToHome();
85
91
  }
86
92
  }
93
+ shiftLoadingState(show) {
94
+ if (!this.loadingElement)
95
+ return;
96
+ if (show) {
97
+ this.loadingElement.classList.add('taro-navigation-bar-loading-show');
98
+ }
99
+ else {
100
+ this.loadingElement.classList.remove('taro-navigation-bar-loading-show');
101
+ }
102
+ }
103
+ setNavigationLoading(show) {
104
+ var _a;
105
+ if (!this.navigationBarElement)
106
+ return;
107
+ const currentPage = this.pageContext.currentPage;
108
+ let isShow;
109
+ if (typeof show === 'boolean') {
110
+ isShow = show;
111
+ this.cache[currentPage] &&
112
+ (this.cache[currentPage].loading = isShow);
113
+ }
114
+ else {
115
+ const cacheValue = (_a = this.cache[currentPage]) === null || _a === void 0 ? void 0 : _a.loading;
116
+ if (typeof cacheValue === 'boolean') {
117
+ isShow = cacheValue;
118
+ }
119
+ else {
120
+ // 默认值为 false
121
+ isShow = false;
122
+ this.cache[currentPage] &&
123
+ (this.cache[currentPage].loading = isShow);
124
+ }
125
+ }
126
+ this.shiftLoadingState(isShow);
127
+ }
87
128
  setNavigationBarBackground(backgroundColor) {
88
129
  var _a, _b, _c;
89
130
  if (!this.navigationBarElement)
@@ -168,23 +209,25 @@ class NavigationBarHandler {
168
209
  fnBtnToggleToHome() {
169
210
  if (!this.navigationBarElement)
170
211
  return;
171
- this.navigationBarElement.classList.add('taro-navigation-bar-home');
172
- this.navigationBarElement.classList.remove('taro-navigation-bar-back');
212
+ this.navigationBarElement.classList.add('taro-navigation-bar-home-icon');
213
+ this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon');
173
214
  }
174
215
  fnBtnToggleToBack() {
175
216
  if (!this.navigationBarElement)
176
217
  return;
177
- this.navigationBarElement.classList.remove('taro-navigation-bar-home');
178
- this.navigationBarElement.classList.add('taro-navigation-bar-back');
218
+ this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon');
219
+ this.navigationBarElement.classList.add('taro-navigation-bar-back-icon');
179
220
  }
180
221
  fnBtnToggleToNone() {
181
222
  if (!this.navigationBarElement)
182
223
  return;
183
- this.navigationBarElement.classList.remove('taro-navigation-bar-home');
184
- this.navigationBarElement.classList.remove('taro-navigation-bar-back');
224
+ this.navigationBarElement.classList.remove('taro-navigation-bar-home-icon');
225
+ this.navigationBarElement.classList.remove('taro-navigation-bar-back-icon');
185
226
  }
186
227
  setNavigationBarVisible(show) {
187
228
  var _a, _b;
229
+ if (!this.navigationBarElement)
230
+ return;
188
231
  let shouldShow;
189
232
  if (typeof show === 'boolean') {
190
233
  shouldShow = show;
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from 'tslib';
2
- import { incrementId, addLeadingSlash, eventCenter, stripBasename, Current, createPageConfig, hooks, stringify } from '@tarojs/runtime';
2
+ import { incrementId, addLeadingSlash, eventCenter, stripBasename, Current, safeExecute, createPageConfig, hooks, stringify } from '@tarojs/runtime';
3
3
  import { Action } from 'history';
4
4
  import UniversalRouter from 'universal-router';
5
5
  import { prependBasename } from '../history.js';
@@ -187,12 +187,23 @@ function createRouter(history, app, config, framework) {
187
187
  render({ location: history.location, action: Action.Push });
188
188
  (_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, launchParam);
189
189
  window.addEventListener('visibilitychange', () => {
190
- var _a, _b;
190
+ var _a, _b, _c, _d, _e, _f, _g;
191
+ const currentPath = ((_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) || '';
192
+ const path = currentPath.substring(0, currentPath.indexOf('?'));
193
+ const param = {};
194
+ // app的 onShow/onHide 生命周期的路径信息为当前页面的路径
195
+ Object.assign(param, launchParam, { path });
191
196
  if (document.visibilityState === 'visible') {
192
- (_a = app.onShow) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
197
+ (_b = app.onShow) === null || _b === void 0 ? void 0 : _b.call(app, param);
198
+ // 单页面app显示后一刻会触发当前 page.onShow 生命周期函数
199
+ (_d = (_c = Current.page) === null || _c === void 0 ? void 0 : _c.onShow) === null || _d === void 0 ? void 0 : _d.call(_c);
193
200
  }
194
201
  else {
195
- (_b = app.onHide) === null || _b === void 0 ? void 0 : _b.call(app, launchParam);
202
+ // 单页面app隐藏前一刻会触发当前 page.onHide 生命周期函数
203
+ if ((_e = Current.page) === null || _e === void 0 ? void 0 : _e.path) {
204
+ safeExecute((_f = Current.page) === null || _f === void 0 ? void 0 : _f.path, 'onHide');
205
+ }
206
+ (_g = app.onHide) === null || _g === void 0 ? void 0 : _g.call(app, param);
196
207
  }
197
208
  });
198
209
  return history.listen(render);
package/dist/style.js CHANGED
@@ -21,6 +21,7 @@ body {
21
21
  .taro_router > .taro_page.taro_tabbar_page,
22
22
  .taro_router > .taro_page.taro_page_show.taro_page_stationed {
23
23
  transform: none;
24
+ transition: none;
24
25
  }
25
26
 
26
27
  .taro_router > .taro_page.taro_page_show {
@@ -73,13 +74,13 @@ ${enableTabBar ? `
73
74
  function loadNavigationBarStyle() {
74
75
  const css = `
75
76
  .taro-navigation-bar-show {
77
+ display: flex;
76
78
  background: white;
77
79
  position: sticky;
78
80
  z-index: 500;
79
81
  top: 0;
80
82
  padding-bottom: 8px;
81
83
  padding-top: calc(env(safe-area-inset-top) + 8px);
82
- display: flex;
83
84
  justify-content: center;
84
85
  align-items: center;
85
86
  }
@@ -88,37 +89,73 @@ function loadNavigationBarStyle() {
88
89
  display: none;
89
90
  }
90
91
 
91
- taro-navigation-bar-title {
92
+ .taro-navigation-bar-title-wrap {
93
+ display: flex;
94
+ height: 24px;
95
+ }
96
+
97
+ .taro-navigation-bar-title-wrap > .taro-navigation-bar-loading {
98
+ display: none;
99
+ animation: loading 2s linear infinite;
100
+ }
101
+
102
+ .taro-navigation-bar-title-wrap .taro-navigation-bar-loading.taro-navigation-bar-loading-show {
103
+ display: flex;
104
+ }
105
+
106
+ .taro-navigation-bar-title-wrap > .taro-navigation-bar-title {
92
107
  font-size: 24px;
93
108
  height: 24px;
94
109
  line-height: 24px;
110
+ max-width: 100px;
111
+ white-space: nowrap;
112
+ overflow: hidden;
113
+ line-height: 24px;
114
+ text-overflow: ellipsis;
115
+ }
116
+
117
+ @keyframes loading {
118
+ from {
119
+ transform: rotate(0deg);
120
+ }
121
+ to {
122
+ transform: rotate(360deg);
123
+ }
95
124
  }
96
125
 
97
- .taro-navigation-bar-no-icon > taro-navigation-bar-home {
126
+ @keyframes loading {
127
+ from {
128
+ transform: rotate(0deg);
129
+ }
130
+ to {
131
+ transform: rotate(360deg);
132
+ }
133
+ }
134
+
135
+ .taro-navigation-bar-no-icon > .taro-navigation-bar-home {
98
136
  display: none;
99
137
  }
100
138
 
101
- .taro-navigation-bar-no-icon > taro-navigation-bar-back {
139
+ .taro-navigation-bar-no-icon > .taro-navigation-bar-back {
102
140
  display: none;
103
141
  }
104
142
 
105
- .taro-navigation-bar-home > taro-navigation-bar-home {
106
- display: block;
143
+ .taro-navigation-bar-home-icon > .taro-navigation-bar-home {
144
+ display: flex;
107
145
  left: 8px;
108
146
  position: absolute;
109
147
  width: 24px;
110
148
  height: 24px;
111
149
  }
112
150
 
113
- .taro-navigation-bar-back > taro-navigation-bar-back {
114
- display: block;
151
+ .taro-navigation-bar-back-icon > .taro-navigation-bar-back {
152
+ display: flex;
115
153
  left: 8px;
116
154
  position: absolute;
117
155
  width: 24px;
118
156
  height: 24px;
119
157
  }
120
-
121
- `;
158
+ `;
122
159
  addStyle(css);
123
160
  }
124
161
  function addStyle(css) {
@@ -6,4 +6,5 @@ declare function setNavigationBarStyle(option: {
6
6
  backgroundColor: string;
7
7
  frontColor: string;
8
8
  }): void;
9
- export { isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle };
9
+ declare function setNavigationBarLoading(loading: boolean): void;
10
+ export { isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading };
@@ -19,10 +19,13 @@ function setMpaTitle(title) {
19
19
  }
20
20
  }
21
21
  function setTitle(title) {
22
- eventCenter.trigger('__taroH5SetNavigationTitle', title);
22
+ eventCenter.trigger('__taroH5SetNavigationBarTitle', title);
23
23
  }
24
24
  function setNavigationBarStyle(option) {
25
25
  eventCenter.trigger('__taroH5setNavigationBarColor', option);
26
26
  }
27
+ function setNavigationBarLoading(loading) {
28
+ eventCenter.trigger('__taroH5setNavigationBarLoading', loading);
29
+ }
27
30
 
28
- export { isDingTalk, isWeixin, setMpaTitle, setNavigationBarStyle, setTitle };
31
+ export { isDingTalk, isWeixin, setMpaTitle, setNavigationBarLoading, setNavigationBarStyle, setTitle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/router",
3
- "version": "4.0.0-beta.61",
3
+ "version": "4.0.0-beta.63",
4
4
  "description": "Taro-router",
5
5
  "browser": "dist/index.js",
6
6
  "main:h5": "dist/index.esm.js",
@@ -44,12 +44,14 @@
44
44
  "rollup-plugin-ts": "^3.0.2",
45
45
  "ts-jest": "^29.0.5",
46
46
  "typescript": "^4.7.4",
47
- "@tarojs/runtime": "4.0.0-beta.61",
48
- "@tarojs/taro": "4.0.0-beta.61"
47
+ "@tarojs/runtime": "4.0.0-beta.63",
48
+ "@tarojs/taro": "4.0.0-beta.63",
49
+ "@tarojs/shared": "4.0.0-beta.63"
49
50
  },
50
51
  "peerDependencies": {
51
- "@tarojs/runtime": "4.0.0-beta.61",
52
- "@tarojs/taro": "4.0.0-beta.61"
52
+ "@tarojs/runtime": "4.0.0-beta.63",
53
+ "@tarojs/taro": "4.0.0-beta.63",
54
+ "@tarojs/shared": "4.0.0-beta.63"
53
55
  },
54
56
  "scripts": {
55
57
  "prebuild": "pnpm run clean",
package/types/api.d.ts CHANGED
@@ -11,3 +11,8 @@ export interface Option extends Base {
11
11
  export interface NavigateBackOption extends Base {
12
12
  delta: number
13
13
  }
14
+
15
+ export interface NavigateOption extends BaseOption {
16
+ url: string
17
+ events?: Record<string, any>
18
+ }