数据库驱动的Web应用程序:如何处理离线使用 [英] Database-driven web app: How to handle offline use

查看:97
本文介绍了数据库驱动的Web应用程序:如何处理离线使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Laravel (PHP框架)开发网络应用。我的约30位同事将在Windows笔记本电脑上使用该应用。

I'm developing a web app using Laravel (a PHP framework). The app is going to be used by about 30 of my co-workers on their Windows laptops.

我的同事会定期采访人们。首次访问某人时,他们将使用Web应用程序将新的个人资料添加到数据库中,并且在以后的访问中将为这些个人资料添加注释。配置文件和注释使用MySQL存储,但是由于我使用Laravel,因此我可以轻松切换到另一个数据库。

My co-workers interview people on a regular basis. They will use the web app to add a new profile to a database once they interview somebody for the first time and they will append notes to these profiles on subsequent visits. Profiles and notes are stored using MySQL, but since I'm using Laravel, I could easily switch to another database.

有时候,我的同事不得不
$ b $他们可能会在访问过程中访问一组受访者,添加一些个人资料并在现有笔记中添加一些笔记。

Sometimes, my co-workers have to interview people when they're offline. They might visit a group of interviewees, add a few profiles and add some notes to existing ones during a session without any internet access.

我应该如何处理?


  1. 每台笔记本电脑上都装有本地Web服务器。我已经看到应用程序附带某种安装程序,包括LAMP堆栈,但是我找不到关于此的任何文档。

  2. 我可以在每台笔记本电脑上安装该应用程序以及类似XAMPP的东西我自己
    。这是有可能的,但是将来可能会有更多的人使用该应用程序,而并非所有人都位于附近。

  3. 我可以使用Service Workers,也许与
    作为 UpUp 。这似乎是最优雅的方法。

  1. With a local web server on every laptop. I've seen applications ship with some kind of installer including a LAMP stack, but I can't find any documentation on this.
  2. I could install the app and something like XAMPP on every laptop myself. That would be possible, but in the future more people might use the app and not all of them might be located nearby.
  3. I could use Service Workers, maybe in connection with a libray such as UpUp. This seems to be the most elegant approach.

我想尝试选项(3),但我的应用程序是数据库驱动,我不确定是否可以实现此方法:

I'd like to give option (3) a try, but my app is database driven and I'm not sure whether I could realize this approach:


  • 是否有可能将数据写入所有(相关)数据中? DB to-假设-在脱机模式下可以访问而不是DB的JSON文件?我们不必处理太多数据(在一次面试过程中应少于100条小数据记录)。

  • 当我的同事在脱机模式下添加个人资料或注释时,

感谢

Pida是否有任何 Web服务方式可将数据插入已输入的数据库?

Thanks
Pida

推荐答案

您可以使用服务工作者构建您描述的内容,以缓存站点的静态内容以使其可以脱机使用,而特定的<服务工作者中的code> fetch 处理程序,以检测失败的 PUT POST ,然后将数据放入 IndexedDB 中。然后,在加载Web应用程序后,您将定期检查 IndexedDB 是否有任何排队的数据,然后尝试重新发送。

You can build what you describe using service workers to cache your site's static content to make it available offline, and a specific fetch handler in the service worker to detect a failed PUT or POST and queue the data in IndexedDB. You'd then periodically check IndexedDB for any queued data when your web app is loaded, and attempt to resend it.

我已经在 https://developers.google.com/web/showcase/case-study/service-workers-iowa#updates-to-users-schedules

该文章假定使用 sw-precache 库,用于缓存网站的静态资产,以及 sw-工具箱 库,以提供运行时 fetch 处理程序,以检查失败的业务逻辑请求。它还使用基于承诺的 IndexedDB 包装器,该包装器称为 simpleDB ,尽管我可能会选择较新的 idb 图书馆。

That article assumes the use of the sw-precache library for caching your site's static assets, and the sw-toolbox library to provide runtime fetch handlers that check for failed business-logic requests. It also uses a promise-based IndexedDB wrapper called simpleDB although I'd probably go with the more recent idb library nowadays.

这篇关于数据库驱动的Web应用程序:如何处理离线使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆