我知道更新 SPA 版本的推荐方法是使用服务工作者并提醒用户他应该刷新页面.但是当有很多页面和不断添加新东西时,我们有什么选择?我相信这会惹恼很多用户,尤其是当这些更新甚至与他们现在使用的页面无关时.
I know that recommended approach to updating SPA versions is to use service workers and alert user that he should refresh page. But what options do we have when there's lots of pages and new things constantly getting added? I believe this would annoy a lot of users especially when those updates aren't even related to the page they are using right now.
我在想,当用户转到其他页面(例如单击菜单项)时,每当新版本存在时都会刷新页面.但它远非完美.我还有其他选择吗?
I was thinking about whenever new version exists refresh page when user goes to other page like clicking menu item. But it's far from perfect. Do I have other options?
推荐答案您可以完成此任务 - "当用户正在查看的页面有可用的新 UI 版本时,显示警报以刷新页面用户.
You can achieve this task - "Show the alert to refresh the page when there is a new UI version available for the page being viewed by the user".
为此,您需要在后端存储该版本的版本和更新的 UI 模块.例如假设 Report-1、Report-5 在新版本 1.2.3 中进行了更改.
For that, you need to store version and updated UI modules for that version at the backend. e.g. lets say Report-1, Report-5 were changed in a new version 1.2.3.
现在,UI 可以通过每个 AJAX HTTP 调用发送当前的 UI 版本(可能在自定义标头中),如果后端发现 UI陈旧,它可以用新版本进行响应 和更改的 UI 模块 的列表:例如新版本:1.2.3 和更改的 UI 模块:Report-1、Report-5.
Now, UI can send current UI version with each AJAX HTTP call (maybe in custom headers) and if the backend finds that UI is stale, it can respond with the new version and the list of changed UI modules: e.g. new version: 1.2.3 and changed UI modules: Report-1, Report-5.
现在 UI 可以通过检查用户当前是否正在查看已更改的模块之一(在此示例中为 Report-1 和 Report-5)来决定是否显示警报.
Now UI can decide whether to show an alert or not by checking if the user is currently looking at one of the changed modules (which are Report-1 & Report-5 in this example).
所以,对于这个例子:
如果用户正在查看 Report-1,则显示警报.
if the user is looking at Report-1, show the alert.
如果用户正在查看 Report-6,则不要显示警报.
if the user is looking at Report-6, don't show the alert.
更多推荐
SPA 内容不断更新,不断更新
发布评论