@lark-apaas/miaoda-core 0.1.0-alpha.11 → 0.1.0-alpha.12
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.
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { useLocation, useNavigate } from "react-router-dom";
|
4
4
|
import { useUpdatingRef } from "../../hooks/useUpdatingRef.js";
|
5
5
|
import { isIncomingMessage, postMessage } from "../../utils/postMessage.js";
|
6
|
+
import { normalizeBasePath } from "../../utils/utils.js";
|
6
7
|
import "./LogInterceptor.js";
|
7
8
|
var IframeBridge_RouteMessageType = /*#__PURE__*/ function(RouteMessageType) {
|
8
9
|
RouteMessageType["RouteChange"] = "RouteChange";
|
@@ -64,7 +65,8 @@ function IframeBridge() {
|
|
64
65
|
}
|
65
66
|
];
|
66
67
|
try {
|
67
|
-
const
|
68
|
+
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
69
|
+
const res = await fetch(`${basePath}/routes.json`);
|
68
70
|
routes = await res.json();
|
69
71
|
} catch (error) {
|
70
72
|
console.warn('get routes.json error', error);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { IncomingMessage, OutgoingMessage } from '../types/iframe-events';
|
1
|
+
import type { IncomingMessage, OutgoingMessage } from '../types/iframe-events';
|
2
2
|
export declare function postMessage<T extends OutgoingMessage>(message: T, targetOrigin?: string): void;
|
3
3
|
export declare function isOutgoingMessage<T extends OutgoingMessage['type']>(msg: OutgoingMessage, type: T): msg is Extract<OutgoingMessage, {
|
4
4
|
type: T;
|
package/lib/utils/utils.d.ts
CHANGED
@@ -9,3 +9,9 @@ export declare function clsxWithTw(...inputs: ClassValue[]): string;
|
|
9
9
|
* 当前是否是预览态
|
10
10
|
*/
|
11
11
|
export declare function isPreview(): boolean;
|
12
|
+
/**
|
13
|
+
* @internal
|
14
|
+
* 标准化基础路径,确保路径格式一致
|
15
|
+
* 移除末尾的斜杠,确保路径不以斜杠结尾
|
16
|
+
*/
|
17
|
+
export declare function normalizeBasePath(basePath?: string): string;
|
package/lib/utils/utils.js
CHANGED
@@ -6,4 +6,8 @@ function clsxWithTw(...inputs) {
|
|
6
6
|
function isPreview() {
|
7
7
|
return window.IS_MIAODA_PREVIEW;
|
8
8
|
}
|
9
|
-
|
9
|
+
function normalizeBasePath(basePath) {
|
10
|
+
if (!basePath || '/' === basePath) return '';
|
11
|
+
return basePath.replace(/\/+$/, '');
|
12
|
+
}
|
13
|
+
export { clsxWithTw, isPreview, normalizeBasePath };
|