@rsmax/web 1.3.12 → 1.3.14
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/CHANGELOG.md +8 -0
- package/assets/normalize.css +27 -126
- package/cjs/KeepAlive.d.ts +10 -0
- package/cjs/KeepAlive.js +96 -0
- package/cjs/PullToRefresh.d.ts +2 -2
- package/cjs/PullToRefresh.js +2 -2
- package/cjs/TabBar.d.ts +2 -4
- package/cjs/TabBar.js +8 -12
- package/cjs/api.js +11 -7
- package/cjs/bootstrap.d.ts +1 -1
- package/cjs/bootstrap.js +1 -6
- package/cjs/bootstrapMpa.js +3 -3
- package/cjs/createApp.d.ts +2 -3
- package/cjs/createApp.js +42 -24
- package/cjs/createAppConfig.js +3 -2
- package/cjs/createPageConfig.d.ts +1 -1
- package/cjs/createPageConfig.js +8 -6
- package/cjs/hooks/useQuery.js +2 -2
- package/cjs/types/config.d.ts +1 -1
- package/esm/KeepAlive.d.ts +10 -0
- package/esm/KeepAlive.js +68 -0
- package/esm/PullToRefresh.d.ts +2 -2
- package/esm/PullToRefresh.js +2 -2
- package/esm/TabBar.d.ts +2 -4
- package/esm/TabBar.js +9 -13
- package/esm/api.js +11 -7
- package/esm/bootstrap.d.ts +1 -1
- package/esm/bootstrap.js +1 -6
- package/esm/bootstrapMpa.js +3 -3
- package/esm/createApp.d.ts +2 -3
- package/esm/createApp.js +43 -25
- package/esm/createAppConfig.js +3 -2
- package/esm/createPageConfig.d.ts +1 -1
- package/esm/createPageConfig.js +8 -6
- package/esm/hooks/useQuery.js +2 -2
- package/esm/types/config.d.ts +1 -1
- package/package.json +20 -18
- package/rstest.config.js +7 -0
- package/vitest.config.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.14](https://github.com/remaxjs/remax/compare/v1.3.13...v1.3.14) (2025-09-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rsmax/web
|
|
9
|
+
|
|
10
|
+
## [1.3.13](https://github.com/remaxjs/remax/compare/v1.3.12...v1.3.13) (2025-06-16)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @rsmax/web
|
|
13
|
+
|
|
6
14
|
## [1.3.12](https://github.com/remaxjs/remax/compare/v1.3.11...v1.3.12) (2025-06-08)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @rsmax/web
|
package/assets/normalize.css
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
/*! normalize.css
|
|
1
|
+
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
|
2
2
|
|
|
3
3
|
/* Document
|
|
4
4
|
========================================================================== */
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 1. Correct the line height in all browsers.
|
|
8
|
-
* 2. Prevent adjustments of font size after orientation changes in
|
|
9
|
-
* IE on Windows Phone and in iOS.
|
|
8
|
+
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
html {
|
|
13
12
|
line-height: 1.15; /* 1 */
|
|
14
|
-
-ms-text-size-adjust: 100%; /* 2 */
|
|
15
13
|
-webkit-text-size-adjust: 100%; /* 2 */
|
|
16
14
|
}
|
|
17
15
|
|
|
@@ -19,7 +17,7 @@ html {
|
|
|
19
17
|
========================================================================== */
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
|
-
* Remove the margin in all browsers
|
|
20
|
+
* Remove the margin in all browsers.
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
body {
|
|
@@ -27,15 +25,10 @@ body {
|
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
28
|
+
* Render the `main` element consistently in IE.
|
|
31
29
|
*/
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
aside,
|
|
35
|
-
footer,
|
|
36
|
-
header,
|
|
37
|
-
nav,
|
|
38
|
-
section {
|
|
31
|
+
main {
|
|
39
32
|
display: block;
|
|
40
33
|
}
|
|
41
34
|
|
|
@@ -52,26 +45,6 @@ h1 {
|
|
|
52
45
|
/* Grouping content
|
|
53
46
|
========================================================================== */
|
|
54
47
|
|
|
55
|
-
/**
|
|
56
|
-
* Add the correct display in IE 9-.
|
|
57
|
-
* 1. Add the correct display in IE.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
figcaption,
|
|
61
|
-
figure,
|
|
62
|
-
main {
|
|
63
|
-
/* 1 */
|
|
64
|
-
display: block;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Add the correct margin in IE 8.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
figure {
|
|
72
|
-
margin: 1em 40px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
48
|
/**
|
|
76
49
|
* 1. Add the correct box sizing in Firefox.
|
|
77
50
|
* 2. Show the overflow in Edge and IE.
|
|
@@ -97,17 +70,15 @@ pre {
|
|
|
97
70
|
========================================================================== */
|
|
98
71
|
|
|
99
72
|
/**
|
|
100
|
-
*
|
|
101
|
-
* 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
|
|
73
|
+
* Remove the gray background on active links in IE 10.
|
|
102
74
|
*/
|
|
103
75
|
|
|
104
76
|
a {
|
|
105
|
-
background-color: transparent;
|
|
106
|
-
-webkit-text-decoration-skip: objects; /* 2 */
|
|
77
|
+
background-color: transparent;
|
|
107
78
|
}
|
|
108
79
|
|
|
109
80
|
/**
|
|
110
|
-
* 1. Remove the bottom border in Chrome 57-
|
|
81
|
+
* 1. Remove the bottom border in Chrome 57-
|
|
111
82
|
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
|
112
83
|
*/
|
|
113
84
|
|
|
@@ -117,15 +88,6 @@ abbr[title] {
|
|
|
117
88
|
text-decoration: underline dotted; /* 2 */
|
|
118
89
|
}
|
|
119
90
|
|
|
120
|
-
/**
|
|
121
|
-
* Prevent the duplicate application of `bolder` by the next rule in Safari 6.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
b,
|
|
125
|
-
strong {
|
|
126
|
-
font-weight: inherit;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
91
|
/**
|
|
130
92
|
* Add the correct font weight in Chrome, Edge, and Safari.
|
|
131
93
|
*/
|
|
@@ -147,23 +109,6 @@ samp {
|
|
|
147
109
|
font-size: 1em; /* 2 */
|
|
148
110
|
}
|
|
149
111
|
|
|
150
|
-
/**
|
|
151
|
-
* Add the correct font style in Android 4.3-.
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
dfn {
|
|
155
|
-
font-style: italic;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Add the correct background and color in IE 9-.
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
mark {
|
|
163
|
-
background-color: #ff0;
|
|
164
|
-
color: #000;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
112
|
/**
|
|
168
113
|
* Add the correct font size in all browsers.
|
|
169
114
|
*/
|
|
@@ -197,44 +142,18 @@ sup {
|
|
|
197
142
|
========================================================================== */
|
|
198
143
|
|
|
199
144
|
/**
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
audio,
|
|
204
|
-
video {
|
|
205
|
-
display: inline-block;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Add the correct display in iOS 4-7.
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
audio:not([controls]) {
|
|
213
|
-
display: none;
|
|
214
|
-
height: 0;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Remove the border on images inside links in IE 10-.
|
|
145
|
+
* Remove the border on images inside links in IE 10.
|
|
219
146
|
*/
|
|
220
147
|
|
|
221
148
|
img {
|
|
222
149
|
border-style: none;
|
|
223
150
|
}
|
|
224
151
|
|
|
225
|
-
/**
|
|
226
|
-
* Hide the overflow in IE.
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
svg:not(:root) {
|
|
230
|
-
overflow: hidden;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
152
|
/* Forms
|
|
234
153
|
========================================================================== */
|
|
235
154
|
|
|
236
155
|
/**
|
|
237
|
-
* 1. Change the font styles in all browsers
|
|
156
|
+
* 1. Change the font styles in all browsers.
|
|
238
157
|
* 2. Remove the margin in Firefox and Safari.
|
|
239
158
|
*/
|
|
240
159
|
|
|
@@ -243,7 +162,7 @@ input,
|
|
|
243
162
|
optgroup,
|
|
244
163
|
select,
|
|
245
164
|
textarea {
|
|
246
|
-
font-family:
|
|
165
|
+
font-family: inherit; /* 1 */
|
|
247
166
|
font-size: 100%; /* 1 */
|
|
248
167
|
line-height: 1.15; /* 1 */
|
|
249
168
|
margin: 0; /* 2 */
|
|
@@ -272,16 +191,14 @@ select {
|
|
|
272
191
|
}
|
|
273
192
|
|
|
274
193
|
/**
|
|
275
|
-
*
|
|
276
|
-
* controls in Android 4.
|
|
277
|
-
* 2. Correct the inability to style clickable types in iOS and Safari.
|
|
194
|
+
* Correct the inability to style clickable types in iOS and Safari.
|
|
278
195
|
*/
|
|
279
196
|
|
|
280
197
|
button,
|
|
281
|
-
|
|
282
|
-
[type=
|
|
283
|
-
[type=
|
|
284
|
-
-webkit-appearance: button;
|
|
198
|
+
[type='button'],
|
|
199
|
+
[type='reset'],
|
|
200
|
+
[type='submit'] {
|
|
201
|
+
-webkit-appearance: button;
|
|
285
202
|
}
|
|
286
203
|
|
|
287
204
|
/**
|
|
@@ -332,17 +249,15 @@ legend {
|
|
|
332
249
|
}
|
|
333
250
|
|
|
334
251
|
/**
|
|
335
|
-
*
|
|
336
|
-
* 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
|
252
|
+
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
|
337
253
|
*/
|
|
338
254
|
|
|
339
255
|
progress {
|
|
340
|
-
|
|
341
|
-
vertical-align: baseline; /* 2 */
|
|
256
|
+
vertical-align: baseline;
|
|
342
257
|
}
|
|
343
258
|
|
|
344
259
|
/**
|
|
345
|
-
* Remove the default vertical scrollbar in IE
|
|
260
|
+
* Remove the default vertical scrollbar in IE 10+.
|
|
346
261
|
*/
|
|
347
262
|
|
|
348
263
|
textarea {
|
|
@@ -350,8 +265,8 @@ textarea {
|
|
|
350
265
|
}
|
|
351
266
|
|
|
352
267
|
/**
|
|
353
|
-
* 1. Add the correct box sizing in IE 10
|
|
354
|
-
* 2. Remove the padding in IE 10
|
|
268
|
+
* 1. Add the correct box sizing in IE 10.
|
|
269
|
+
* 2. Remove the padding in IE 10.
|
|
355
270
|
*/
|
|
356
271
|
|
|
357
272
|
[type='checkbox'],
|
|
@@ -380,10 +295,9 @@ textarea {
|
|
|
380
295
|
}
|
|
381
296
|
|
|
382
297
|
/**
|
|
383
|
-
* Remove the inner padding
|
|
298
|
+
* Remove the inner padding in Chrome and Safari on macOS.
|
|
384
299
|
*/
|
|
385
300
|
|
|
386
|
-
[type='search']::-webkit-search-cancel-button,
|
|
387
301
|
[type='search']::-webkit-search-decoration {
|
|
388
302
|
-webkit-appearance: none;
|
|
389
303
|
}
|
|
@@ -402,12 +316,10 @@ textarea {
|
|
|
402
316
|
========================================================================== */
|
|
403
317
|
|
|
404
318
|
/*
|
|
405
|
-
* Add the correct display in IE
|
|
406
|
-
* 1. Add the correct display in Edge, IE, and Firefox.
|
|
319
|
+
* Add the correct display in Edge, IE 10+, and Firefox.
|
|
407
320
|
*/
|
|
408
321
|
|
|
409
|
-
details
|
|
410
|
-
menu {
|
|
322
|
+
details {
|
|
411
323
|
display: block;
|
|
412
324
|
}
|
|
413
325
|
|
|
@@ -419,30 +331,19 @@ summary {
|
|
|
419
331
|
display: list-item;
|
|
420
332
|
}
|
|
421
333
|
|
|
422
|
-
/*
|
|
334
|
+
/* Misc
|
|
423
335
|
========================================================================== */
|
|
424
336
|
|
|
425
337
|
/**
|
|
426
|
-
* Add the correct display in IE
|
|
427
|
-
*/
|
|
428
|
-
|
|
429
|
-
canvas {
|
|
430
|
-
display: inline-block;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* Add the correct display in IE.
|
|
338
|
+
* Add the correct display in IE 10+.
|
|
435
339
|
*/
|
|
436
340
|
|
|
437
341
|
template {
|
|
438
342
|
display: none;
|
|
439
343
|
}
|
|
440
344
|
|
|
441
|
-
/* Hidden
|
|
442
|
-
========================================================================== */
|
|
443
|
-
|
|
444
345
|
/**
|
|
445
|
-
* Add the correct display in IE 10
|
|
346
|
+
* Add the correct display in IE 10.
|
|
446
347
|
*/
|
|
447
348
|
|
|
448
349
|
[hidden] {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const KeepAliveProvider: React.FC<{
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}>;
|
|
5
|
+
interface KeepAliveProps {
|
|
6
|
+
cacheKey: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const KeepAlive: React.FC<KeepAliveProps>;
|
|
10
|
+
export {};
|
package/cjs/KeepAlive.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.KeepAlive = exports.KeepAliveProvider = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
29
|
+
const KeepAliveContext = (0, react_1.createContext)(null);
|
|
30
|
+
const KeepAliveProvider = ({ children }) => {
|
|
31
|
+
const [cache, setCache] = (0, react_1.useState)(new Map());
|
|
32
|
+
return (react_1.default.createElement(KeepAliveContext.Provider, { value: { cache, setCache } },
|
|
33
|
+
children,
|
|
34
|
+
Array.from(cache.entries()).map(([key, item]) => (react_1.default.createElement("div", { key: key, style: {
|
|
35
|
+
display: item.status === 'active' ? 'block' : 'none',
|
|
36
|
+
height: '100%',
|
|
37
|
+
width: '100%',
|
|
38
|
+
} }, item.component)))));
|
|
39
|
+
};
|
|
40
|
+
exports.KeepAliveProvider = KeepAliveProvider;
|
|
41
|
+
const KeepAlive = ({ cacheKey, children }) => {
|
|
42
|
+
const context = (0, react_1.useContext)(KeepAliveContext);
|
|
43
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
44
|
+
const componentRef = (0, react_1.useRef)(children);
|
|
45
|
+
if (!context) {
|
|
46
|
+
throw new Error('KeepAlive must be used within KeepAliveProvider');
|
|
47
|
+
}
|
|
48
|
+
const { cache, setCache } = context;
|
|
49
|
+
react_1.default.useEffect(() => {
|
|
50
|
+
// 更新组件引用
|
|
51
|
+
componentRef.current = children;
|
|
52
|
+
setCache(prev => {
|
|
53
|
+
const next = new Map(prev);
|
|
54
|
+
if (next.has(cacheKey)) {
|
|
55
|
+
next.set(cacheKey, Object.assign(Object.assign({}, next.get(cacheKey)), { component: children }));
|
|
56
|
+
}
|
|
57
|
+
return next;
|
|
58
|
+
});
|
|
59
|
+
}, [children]);
|
|
60
|
+
react_1.default.useEffect(() => {
|
|
61
|
+
// 初始化缓存
|
|
62
|
+
if (!cache.has(cacheKey)) {
|
|
63
|
+
setCache(prev => {
|
|
64
|
+
const next = new Map(prev);
|
|
65
|
+
next.set(cacheKey, {
|
|
66
|
+
component: componentRef.current,
|
|
67
|
+
status: 'active',
|
|
68
|
+
});
|
|
69
|
+
return next;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// 更新状态
|
|
73
|
+
setCache(prev => {
|
|
74
|
+
const next = new Map(prev);
|
|
75
|
+
prev.forEach((value, key) => {
|
|
76
|
+
next.set(key, Object.assign(Object.assign({}, value), { status: key === cacheKey ? 'active' : 'inactive' }));
|
|
77
|
+
});
|
|
78
|
+
return next;
|
|
79
|
+
});
|
|
80
|
+
// 清理函数
|
|
81
|
+
return () => {
|
|
82
|
+
// 这里我们不会在路由变化时删除缓存
|
|
83
|
+
// 只是将状态设置为 inactive
|
|
84
|
+
setCache(prev => {
|
|
85
|
+
const next = new Map(prev);
|
|
86
|
+
if (next.has(cacheKey)) {
|
|
87
|
+
next.set(cacheKey, Object.assign(Object.assign({}, next.get(cacheKey)), { status: 'inactive' }));
|
|
88
|
+
}
|
|
89
|
+
return next;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
}, [cacheKey, location.pathname]);
|
|
93
|
+
// 不直接渲染children,因为所有缓存的组件都在Provider中渲染
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
exports.KeepAlive = KeepAlive;
|
package/cjs/PullToRefresh.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const RsmaxPullToRefresh: React.FC<any>;
|
|
3
|
+
export default RsmaxPullToRefresh;
|
package/cjs/PullToRefresh.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const rmc_pull_to_refresh_1 = __importDefault(require("rmc-pull-to-refresh"));
|
|
8
8
|
const LoadingIcon_1 = __importDefault(require("./LoadingIcon"));
|
|
9
|
-
const
|
|
9
|
+
const RsmaxPullToRefresh = props => {
|
|
10
10
|
return (react_1.default.createElement(rmc_pull_to_refresh_1.default, Object.assign({}, props, { getScrollContainer: () => {
|
|
11
11
|
document.body;
|
|
12
12
|
}, indicator: {
|
|
@@ -16,4 +16,4 @@ const RemaxPullToRefresh = props => {
|
|
|
16
16
|
finish: react_1.default.createElement(LoadingIcon_1.default, null),
|
|
17
17
|
} })));
|
|
18
18
|
};
|
|
19
|
-
exports.default =
|
|
19
|
+
exports.default = RsmaxPullToRefresh;
|
package/cjs/TabBar.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function TabBar({ config, history }: {
|
|
2
|
+
import type { TabBarConfig } from './types';
|
|
3
|
+
export declare function TabBar({ config }: {
|
|
5
4
|
config: TabBarConfig;
|
|
6
|
-
history: History;
|
|
7
5
|
}): React.JSX.Element;
|
package/cjs/TabBar.js
CHANGED
|
@@ -6,18 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.TabBar = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
|
-
function TabBar({ config
|
|
9
|
+
function TabBar({ config }) {
|
|
10
10
|
var _a;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return history.listen(() => {
|
|
15
|
-
setCurrentPath(history.location.pathname);
|
|
16
|
-
});
|
|
17
|
-
}, []);
|
|
11
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
12
|
+
const currentPath = location.pathname;
|
|
13
|
+
react_1.default.useEffect(() => { }, [currentPath]);
|
|
18
14
|
const isActive = (url) => {
|
|
19
15
|
if (!url.startsWith('/')) {
|
|
20
|
-
url =
|
|
16
|
+
url = `/${url}`;
|
|
21
17
|
}
|
|
22
18
|
return currentPath === url;
|
|
23
19
|
};
|
|
@@ -29,9 +25,9 @@ function TabBarItem({ config, isActive, item }) {
|
|
|
29
25
|
const icon = isActive ? item.activeImage || item.image : item.image;
|
|
30
26
|
const textColor = (_a = config.textColor) !== null && _a !== void 0 ? _a : '#333';
|
|
31
27
|
const selectedColor = (_b = config.selectedColor) !== null && _b !== void 0 ? _b : '#108ee9';
|
|
32
|
-
return (react_1.default.createElement(react_router_dom_1.Link, { to: `/${item.url}`, className:
|
|
33
|
-
react_1.default.createElement("div", { className:
|
|
34
|
-
react_1.default.createElement("div", { className:
|
|
28
|
+
return (react_1.default.createElement(react_router_dom_1.Link, { to: item.url.startsWith('/') ? item.url : `/${item.url}`, className: 'rsmax-tab-item' },
|
|
29
|
+
react_1.default.createElement("div", { className: 'rsmax-tab-item-image', style: { backgroundImage: `url(${icon})` } }),
|
|
30
|
+
react_1.default.createElement("div", { className: 'rsmax-tab-item-title', style: {
|
|
35
31
|
color: isActive ? selectedColor : textColor,
|
|
36
32
|
} }, item.title)));
|
|
37
33
|
}
|
package/cjs/api.js
CHANGED
|
@@ -3,20 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.switchTab = exports.reLaunch = exports.redirectTo = exports.navigateBack = exports.navigateTo = void 0;
|
|
4
4
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
5
5
|
function navigateTo(params) {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const navigate = framework_shared_1.RuntimeOptions.get('navigate');
|
|
7
|
+
navigate(params.url, {
|
|
8
|
+
replace: true,
|
|
9
|
+
});
|
|
8
10
|
return Promise.resolve();
|
|
9
11
|
}
|
|
10
12
|
exports.navigateTo = navigateTo;
|
|
11
13
|
function navigateBack(params) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
+
const navigate = framework_shared_1.RuntimeOptions.get('navigate');
|
|
15
|
+
navigate(-((params === null || params === void 0 ? void 0 : params.delta) || 1));
|
|
14
16
|
return Promise.resolve();
|
|
15
17
|
}
|
|
16
18
|
exports.navigateBack = navigateBack;
|
|
17
19
|
function redirectTo(params) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
+
const navigate = framework_shared_1.RuntimeOptions.get('navigate');
|
|
21
|
+
navigate(params.url, {
|
|
22
|
+
replace: true,
|
|
23
|
+
});
|
|
20
24
|
return Promise.resolve();
|
|
21
25
|
}
|
|
22
26
|
exports.redirectTo = redirectTo;
|
|
@@ -25,6 +29,6 @@ function reLaunch(params) {
|
|
|
25
29
|
}
|
|
26
30
|
exports.reLaunch = reLaunch;
|
|
27
31
|
function switchTab(params) {
|
|
28
|
-
navigateTo(params);
|
|
32
|
+
navigateTo(params).then();
|
|
29
33
|
}
|
|
30
34
|
exports.switchTab = switchTab;
|
package/cjs/bootstrap.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BootstrapOptions } from './types';
|
|
1
|
+
import type { BootstrapOptions } from './types';
|
|
2
2
|
export default function bootstrap(options: BootstrapOptions): void;
|
package/cjs/bootstrap.js
CHANGED
|
@@ -5,18 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const client_1 = require("react-dom/client");
|
|
7
7
|
const umi_hd_1 = __importDefault(require("umi-hd"));
|
|
8
|
-
const history_1 = require("history");
|
|
9
|
-
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
10
8
|
const createApp_1 = __importDefault(require("./createApp"));
|
|
11
9
|
function bootstrap(options) {
|
|
12
10
|
(0, umi_hd_1.default)();
|
|
13
|
-
const { appConfig } = options;
|
|
14
|
-
const history = !appConfig.router || appConfig.router.type !== 'browser' ? (0, history_1.createHashHistory)() : (0, history_1.createBrowserHistory)();
|
|
15
|
-
framework_shared_1.RuntimeOptions.apply({ history, mpa: false });
|
|
16
11
|
const container = document.getElementById('rsmax-app');
|
|
17
12
|
if (!container)
|
|
18
13
|
throw new Error('Failed to find the root element');
|
|
19
14
|
const root = (0, client_1.createRoot)(container);
|
|
20
|
-
root.render((0, createApp_1.default)(options
|
|
15
|
+
root.render((0, createApp_1.default)(options));
|
|
21
16
|
}
|
|
22
17
|
exports.default = bootstrap;
|
package/cjs/bootstrapMpa.js
CHANGED
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
6
7
|
const react_1 = __importDefault(require("react"));
|
|
7
8
|
const client_1 = require("react-dom/client");
|
|
8
9
|
const umi_hd_1 = __importDefault(require("umi-hd"));
|
|
9
10
|
const createAppConfig_1 = __importDefault(require("./createAppConfig"));
|
|
10
|
-
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
11
11
|
const createPageConfig_1 = __importDefault(require("./createPageConfig"));
|
|
12
12
|
const noop = () => {
|
|
13
13
|
// ignore
|
|
@@ -46,11 +46,11 @@ function bootstrap(options) {
|
|
|
46
46
|
if (url.startsWith('/'))
|
|
47
47
|
publicPath = location.pathname.replace(`/${page.route}.html`, '');
|
|
48
48
|
const arr = url.split('?');
|
|
49
|
-
arr[0] = arr[0]
|
|
49
|
+
arr[0] = `${arr[0]}.html`;
|
|
50
50
|
return publicPath + arr.join('?');
|
|
51
51
|
},
|
|
52
52
|
};
|
|
53
|
-
framework_shared_1.RuntimeOptions.apply({ pluginDriver,
|
|
53
|
+
framework_shared_1.RuntimeOptions.apply({ pluginDriver, mpa: true });
|
|
54
54
|
const App = createApp(options);
|
|
55
55
|
const container = document.getElementById('rsmax-app');
|
|
56
56
|
if (!container)
|
package/cjs/createApp.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export default function createApp(options: BootstrapOptions, history: History): React.JSX.Element;
|
|
2
|
+
import type { BootstrapOptions } from './types';
|
|
3
|
+
export default function createApp(options: BootstrapOptions): React.JSX.Element;
|