Skip to content

Commit 3277448

Browse files
authored
Merge pull request #4601 from easyops-cn/jojiang/v2
fix(): refine loading bar custom event
2 parents f951fa2 + 05a7981 commit 3277448

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

packages/brick-container/src/index.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,6 @@ http.interceptors.request.use(function (config: HttpRequestConfig) {
121121
};
122122
});
123123

124-
const isInSpecialFrame = (): boolean => {
125-
return (
126-
getRuntimeMisc().isInIframeOfSameSite &&
127-
!getRuntimeMisc().isInIframeOfVisualBuilder
128-
);
129-
};
130-
131124
http.interceptors.request.use(function (config: HttpRequestConfig) {
132125
if (analyzer) {
133126
const { userInstanceId: uid, username } = getAuth();
@@ -141,16 +134,14 @@ http.interceptors.request.use(function (config: HttpRequestConfig) {
141134
}
142135

143136
if (!config.options?.interceptorParams?.ignoreLoadingBar) {
144-
const curWindow = isInSpecialFrame() ? window.parent : window;
145-
curWindow.dispatchEvent(new CustomEvent("request.start"));
137+
window.dispatchEvent(new CustomEvent("request.start"));
146138
}
147139
return config;
148140
});
149141

150142
http.interceptors.response.use(
151143
function (response: HttpResponse) {
152-
const curWindow = isInSpecialFrame() ? window.parent : window;
153-
curWindow.dispatchEvent(new CustomEvent("request.end"));
144+
window.dispatchEvent(new CustomEvent("request.end"));
154145
(getRuntime().getFeatureFlags()["enable-analyzer"] || false) &&
155146
analyzer?.analyses(response);
156147
return response.config.options?.observe === "response"
@@ -160,8 +151,7 @@ http.interceptors.response.use(
160151
function (error: HttpError) {
161152
(getRuntime().getFeatureFlags()["enable-analyzer"] || false) &&
162153
analyzer?.analyses(error);
163-
const curWindow = isInSpecialFrame() ? window.parent : window;
164-
curWindow.dispatchEvent(new CustomEvent("request.end"));
154+
window.dispatchEvent(new CustomEvent("request.end"));
165155
return Promise.reject(error.error);
166156
}
167157
);

0 commit comments

Comments
 (0)