@tarojs/router 4.0.0-beta.8 → 4.0.0-beta.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +26 -1
- package/dist/events/resize.js +12 -6
- package/dist/history.js +3 -2
- package/dist/index.cjs.d.ts +8 -2
- package/dist/index.cjs.js +566 -105
- package/dist/index.esm.d.ts +8 -2
- package/dist/index.esm.js +565 -107
- package/dist/index.js +4 -1
- package/dist/navigationBar.d.ts +3 -0
- package/dist/navigationBar.js +44 -0
- package/dist/router/mpa.js +19 -3
- package/dist/router/navigation-bar.d.ts +36 -0
- package/dist/router/navigation-bar.js +252 -0
- package/dist/router/page.d.ts +3 -1
- package/dist/router/page.js +6 -0
- package/dist/router/spa.js +24 -6
- package/dist/style.d.ts +5 -1
- package/dist/style.js +95 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/navigate.d.ts +8 -2
- package/dist/utils/navigate.js +25 -19
- package/package.json +7 -5
- package/types/api.d.ts +5 -0
package/dist/style.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
function loadAnimateStyle(ms = 300) {
|
|
5
5
|
const css = `
|
|
6
|
+
body {
|
|
7
|
+
overflow: hidden; // 防止 iOS 页面滚动
|
|
8
|
+
}
|
|
6
9
|
.taro_router > .taro_page {
|
|
7
10
|
position: absolute;
|
|
8
11
|
left: 0;
|
|
@@ -18,6 +21,7 @@ function loadAnimateStyle(ms = 300) {
|
|
|
18
21
|
.taro_router > .taro_page.taro_tabbar_page,
|
|
19
22
|
.taro_router > .taro_page.taro_page_show.taro_page_stationed {
|
|
20
23
|
transform: none;
|
|
24
|
+
transition: none;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
.taro_router > .taro_page.taro_page_show {
|
|
@@ -64,6 +68,96 @@ ${enableTabBar ? `
|
|
|
64
68
|
`;
|
|
65
69
|
addStyle(css);
|
|
66
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* 插入导航栏相关的样式
|
|
73
|
+
*/
|
|
74
|
+
function loadNavigationBarStyle() {
|
|
75
|
+
const css = `
|
|
76
|
+
.taro-navigation-bar-show {
|
|
77
|
+
display: flex;
|
|
78
|
+
background: white;
|
|
79
|
+
position: sticky;
|
|
80
|
+
z-index: 500;
|
|
81
|
+
top: 0;
|
|
82
|
+
padding-bottom: 8px;
|
|
83
|
+
padding-top: calc(env(safe-area-inset-top) + 8px);
|
|
84
|
+
justify-content: center;
|
|
85
|
+
align-items: center;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.taro-navigation-bar-hide {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
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 {
|
|
107
|
+
font-size: 24px;
|
|
108
|
+
height: 24px;
|
|
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
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
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 {
|
|
136
|
+
display: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.taro-navigation-bar-no-icon > .taro-navigation-bar-back {
|
|
140
|
+
display: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.taro-navigation-bar-home-icon > .taro-navigation-bar-home {
|
|
144
|
+
display: flex;
|
|
145
|
+
left: 8px;
|
|
146
|
+
position: absolute;
|
|
147
|
+
width: 24px;
|
|
148
|
+
height: 24px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.taro-navigation-bar-back-icon > .taro-navigation-bar-back {
|
|
152
|
+
display: flex;
|
|
153
|
+
left: 8px;
|
|
154
|
+
position: absolute;
|
|
155
|
+
width: 24px;
|
|
156
|
+
height: 24px;
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
159
|
+
addStyle(css);
|
|
160
|
+
}
|
|
67
161
|
function addStyle(css) {
|
|
68
162
|
if (!css)
|
|
69
163
|
return;
|
|
@@ -72,4 +166,4 @@ function addStyle(css) {
|
|
|
72
166
|
document.getElementsByTagName('head')[0].appendChild(style);
|
|
73
167
|
}
|
|
74
168
|
|
|
75
|
-
export { addStyle, loadAnimateStyle, loadRouterStyle };
|
|
169
|
+
export { addStyle, loadAnimateStyle, loadNavigationBarStyle, loadRouterStyle };
|
package/dist/utils/index.js
CHANGED
package/dist/utils/navigate.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
declare const isWeixin: () => boolean;
|
|
2
2
|
declare const isDingTalk: () => boolean;
|
|
3
|
-
declare function
|
|
4
|
-
|
|
3
|
+
declare function setMpaTitle(title: string): void;
|
|
4
|
+
declare function setTitle(title: string): void;
|
|
5
|
+
declare function setNavigationBarStyle(option: {
|
|
6
|
+
backgroundColor: string;
|
|
7
|
+
frontColor: string;
|
|
8
|
+
}): void;
|
|
9
|
+
declare function setNavigationBarLoading(loading: boolean): void;
|
|
10
|
+
export { isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading };
|
package/dist/utils/navigate.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime';
|
|
2
2
|
|
|
3
|
-
let preTitle = document.title;
|
|
4
|
-
let isLoadDdEntry = false;
|
|
5
3
|
const isWeixin = () => !!navigator.userAgent.match(/\bMicroMessenger\b/ig);
|
|
6
4
|
const isDingTalk = () => !!navigator.userAgent.match(/\bDingTalk\b/ig);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const setDingTitle = require('dingtalk-jsapi/api/biz/navigation/setTitle').default;
|
|
19
|
-
setDingTitle({ title });
|
|
5
|
+
let preTitle = document.title;
|
|
6
|
+
let isLoadDdEntry = false;
|
|
7
|
+
function setMpaTitle(title) {
|
|
8
|
+
if (preTitle === title)
|
|
9
|
+
return;
|
|
10
|
+
document.title = title;
|
|
11
|
+
preTitle = title;
|
|
12
|
+
if (process.env.SUPPORT_DINGTALK_NAVIGATE !== 'disabled' && isDingTalk()) {
|
|
13
|
+
if (!isLoadDdEntry) {
|
|
14
|
+
isLoadDdEntry = true;
|
|
15
|
+
require('dingtalk-jsapi/platform');
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const setDingTitle = require('dingtalk-jsapi/api/biz/navigation/setTitle').default;
|
|
18
|
+
setDingTitle({ title });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function setTitle(title) {
|
|
22
|
+
eventCenter.trigger('__taroH5SetNavigationBarTitle', title);
|
|
23
|
+
}
|
|
24
|
+
function setNavigationBarStyle(option) {
|
|
25
|
+
eventCenter.trigger('__taroH5setNavigationBarColor', option);
|
|
26
|
+
}
|
|
27
|
+
function setNavigationBarLoading(loading) {
|
|
28
|
+
eventCenter.trigger('__taroH5setNavigationBarLoading', loading);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
export { isDingTalk, isWeixin, 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.
|
|
3
|
+
"version": "4.0.0-beta.80",
|
|
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.
|
|
48
|
-
"@tarojs/taro": "4.0.0-beta.
|
|
47
|
+
"@tarojs/runtime": "4.0.0-beta.80",
|
|
48
|
+
"@tarojs/taro": "4.0.0-beta.80",
|
|
49
|
+
"@tarojs/shared": "4.0.0-beta.80"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@tarojs/
|
|
52
|
-
"@tarojs/
|
|
52
|
+
"@tarojs/runtime": "4.0.0-beta.80",
|
|
53
|
+
"@tarojs/shared": "4.0.0-beta.80",
|
|
54
|
+
"@tarojs/taro": "4.0.0-beta.80"
|
|
53
55
|
},
|
|
54
56
|
"scripts": {
|
|
55
57
|
"prebuild": "pnpm run clean",
|