@alicloud/alfa-react 1.4.32 → 1.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/es/createApplication.js +17 -4
- package/es/version.js +1 -1
- package/lib/createApplication.js +17 -4
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/types/createApplication.d.ts +5 -1
- package/types/version.d.ts +1 -1
package/es/createApplication.js
CHANGED
|
@@ -34,6 +34,17 @@ var addBasename = function addBasename(path, basename) {
|
|
|
34
34
|
return resolvePath(basename, path);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
var addLeftSlash = function addLeftSlash(path) {
|
|
38
|
+
return path.charAt(0) === '/' ? path : "/".concat(path);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 从 path 移除 basename 部分
|
|
42
|
+
* @param path
|
|
43
|
+
* @param basename
|
|
44
|
+
* @returns string
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
37
48
|
var stripBasename = function stripBasename(path, basename) {
|
|
38
49
|
if (!basename) return path;
|
|
39
50
|
|
|
@@ -92,7 +103,8 @@ export default function createApplication(loader) {
|
|
|
92
103
|
var $basename = useRef(basename);
|
|
93
104
|
var tagName = normalizeName(props.name);
|
|
94
105
|
$syncHistory.current = syncHistory;
|
|
95
|
-
$basename.current = basename;
|
|
106
|
+
$basename.current = basename;
|
|
107
|
+
if (customProps.path) customProps.path = addLeftSlash(customProps.path); // 受控模式锁定一些参数
|
|
96
108
|
|
|
97
109
|
if ($syncHistory.current) {
|
|
98
110
|
// 禁止子应用和 consoleBase 通信
|
|
@@ -170,8 +182,9 @@ export default function createApplication(loader) {
|
|
|
170
182
|
|
|
171
183
|
var updateAppHistory = function updateAppHistory() {
|
|
172
184
|
if (App) {
|
|
173
|
-
//
|
|
174
|
-
|
|
185
|
+
var nextPath = peelPath(App.context.location); // 路由同步只应该在相同 basename 下生效
|
|
186
|
+
|
|
187
|
+
if (!peelPath(window.location).startsWith($basename.current || '')) return; // 如果主子应用路径不同,主动通知子应用 popstate 事件
|
|
175
188
|
|
|
176
189
|
if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
|
|
177
190
|
if (originalReplaceState) {
|
|
@@ -315,7 +328,7 @@ export default function createApplication(loader) {
|
|
|
315
328
|
|
|
316
329
|
if (frameHistory) {
|
|
317
330
|
if (originalPushState !== frameHistory.pushState) frameHistory.pushState = originalPushState;
|
|
318
|
-
if (originalReplaceState !== frameHistory.replaceState) frameHistory.
|
|
331
|
+
if (originalReplaceState !== frameHistory.replaceState) frameHistory.replaceState = originalReplaceState;
|
|
319
332
|
if (originalGo !== frameHistory.go) frameHistory.go = originalGo;
|
|
320
333
|
}
|
|
321
334
|
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.4.
|
|
1
|
+
export var version = '1.4.33';
|
package/lib/createApplication.js
CHANGED
|
@@ -56,6 +56,17 @@ var addBasename = function addBasename(path, basename) {
|
|
|
56
56
|
return resolvePath(basename, path);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
var addLeftSlash = function addLeftSlash(path) {
|
|
60
|
+
return path.charAt(0) === '/' ? path : "/".concat(path);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* 从 path 移除 basename 部分
|
|
64
|
+
* @param path
|
|
65
|
+
* @param basename
|
|
66
|
+
* @returns string
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
|
|
59
70
|
var stripBasename = function stripBasename(path, basename) {
|
|
60
71
|
if (!basename) return path;
|
|
61
72
|
|
|
@@ -114,7 +125,8 @@ function createApplication(loader) {
|
|
|
114
125
|
var $basename = (0, _react.useRef)(basename);
|
|
115
126
|
var tagName = (0, _utils.normalizeName)(props.name);
|
|
116
127
|
$syncHistory.current = syncHistory;
|
|
117
|
-
$basename.current = basename;
|
|
128
|
+
$basename.current = basename;
|
|
129
|
+
if (customProps.path) customProps.path = addLeftSlash(customProps.path); // 受控模式锁定一些参数
|
|
118
130
|
|
|
119
131
|
if ($syncHistory.current) {
|
|
120
132
|
// 禁止子应用和 consoleBase 通信
|
|
@@ -192,8 +204,9 @@ function createApplication(loader) {
|
|
|
192
204
|
|
|
193
205
|
var updateAppHistory = function updateAppHistory() {
|
|
194
206
|
if (App) {
|
|
195
|
-
//
|
|
196
|
-
|
|
207
|
+
var nextPath = peelPath(App.context.location); // 路由同步只应该在相同 basename 下生效
|
|
208
|
+
|
|
209
|
+
if (!peelPath(window.location).startsWith($basename.current || '')) return; // 如果主子应用路径不同,主动通知子应用 popstate 事件
|
|
197
210
|
|
|
198
211
|
if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
|
|
199
212
|
if (originalReplaceState) {
|
|
@@ -335,7 +348,7 @@ function createApplication(loader) {
|
|
|
335
348
|
|
|
336
349
|
if (frameHistory) {
|
|
337
350
|
if (originalPushState !== frameHistory.pushState) frameHistory.pushState = originalPushState;
|
|
338
|
-
if (originalReplaceState !== frameHistory.replaceState) frameHistory.
|
|
351
|
+
if (originalReplaceState !== frameHistory.replaceState) frameHistory.replaceState = originalReplaceState;
|
|
339
352
|
if (originalGo !== frameHistory.go) frameHistory.go = originalGo;
|
|
340
353
|
}
|
|
341
354
|
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { BaseLoader } from '@alicloud/alfa-core';
|
|
3
3
|
import { AlfaFactoryOption } from './types';
|
|
4
4
|
interface IProps<C = any> extends AlfaFactoryOption {
|
|
5
|
-
customProps: C
|
|
5
|
+
customProps: C & {
|
|
6
|
+
consoleBase?: any;
|
|
7
|
+
path?: string;
|
|
8
|
+
__injectHistory?: any;
|
|
9
|
+
};
|
|
6
10
|
syncHistory?: boolean;
|
|
7
11
|
basename?: string;
|
|
8
12
|
}
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.4.
|
|
1
|
+
export declare const version = "1.4.33";
|