与模块联合会的角度微主恩截止HTTP请求在主机应用程序中

发布于 2025-01-31 19:44:03 字数 285 浏览 4 评论 0原文

我需要拦截来自主机应用程序中所有遥控器的所有http请求,以便重新启动监视用户不活动的计时器。所有应用程序都使用Angular与WebPack模块联合使用。 有什么想法吗?

最好的应该是主机应用拦截器可以拦截所有请求,我发现的替代解决方案是:

  • 通过对象 window 共享一个全局变量,每当从遥控器中提出请求时,将其从遥控器重置并在主机中增加每秒
  • 使用自定义事件的应用程序与已提出请求的主机应用程序进行通信,并且主机必须重置一个

可首选解决方案的计数?

I need to intercept all HTTP request coming from all the remotes in my host application in order to restart a timer that monitor the user inactivity. All applications are using Angular with Webpack Module Federation.
Any ideas?

The best should be the host app interceptor could intercept all requests, alternatives solutions i found are:

  • sharing a global variable through the object window resetting it from the remote whenever a request is made from it and increment in host app every second
  • using custom events to communicate to the host app that a request has been made and the host has to reset the count

Which is the preferrable solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2025-02-07 19:44:03

我本周遇到了这种情况,对我而言,最合适的是创建一个使拦截器暴露的角图书馆,并通过模块联合会在外壳和微额线之间共享此库。

I ran into this situation this week, and for me the best fit was creating an angular library that exposes the interceptor, and share this library between the shell and the microfrontends through module federation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文