@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.
@@ -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
- // 如果子应用路径不同,主动通知子应用 popstate 事件
174
- var nextPath = peelPath(App.context.location);
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.pushState = originalReplaceState;
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.32';
1
+ export var version = '1.4.33';
@@ -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
- // 如果子应用路径不同,主动通知子应用 popstate 事件
196
- var nextPath = peelPath(App.context.location);
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.pushState = originalReplaceState;
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
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '1.4.32';
7
+ var version = '1.4.33';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.4.32",
3
+ "version": "1.4.33",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -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
  }
@@ -1 +1 @@
1
- export declare const version = "1.4.32";
1
+ export declare const version = "1.4.33";