Laravel:离线模式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27846770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel: Offline Mode?
提问by David
I want to make my web app (which is built with laravel) work offline...but I cant found out how to do it!
我想让我的网络应用程序(用 laravel 构建)离线工作……但我不知道怎么做!
I am using the "app cache" for static files, but im not sure exactly how to handle the dynamic side of the app.
我正在为静态文件使用“应用程序缓存”,但我不确定如何处理应用程序的动态方面。
The app uses a database which im guessing I need to use localStorage for? (from what ive read online so far)
该应用程序使用了一个我猜我需要使用 localStorage 的数据库?(到目前为止我在网上阅读的内容)
Im basically just looking for someone to point me in the right direction as im struggling to find much online on setting up Laravel for use offline
我基本上只是在寻找某人为我指明正确的方向,因为我正在努力在网上找到很多关于设置 Laravel 以供离线使用的内容
Thanks, Dave
谢谢,戴夫
采纳答案by Lorenz Meyer
You can only have a static site offline with appcache. You cannot do this with laravel.
您只能使用 appcache 使静态站点脱机。你不能用 laravel 做到这一点。
If you want to move the data into localstorage and have a semi- dynamic website, you have to completly change your architecture. Let me outline a possible approach :
如果您想将数据移动到本地存储并拥有一个半动态网站,您必须彻底改变您的架构。让我概述一种可能的方法:
A single page web app written in javascript ( using a framework like for instance ExtJs ) that connects to a backend in a form of a webservice that gives access to the database ( you could write it using laravel ).
一个用 javascript 编写的单页 web 应用程序(使用框架,例如 ExtJs ),它以 web 服务的形式连接到后端,可以访问数据库(您可以使用 laravel 编写它)。
When you are connected to the server you can load the data in localstorage When you are offline you can continue to work with the data. When the client reconnects, you have to synchronize the changes with the server.
当您连接到服务器时,您可以在 localstorage 中加载数据 当您离线时,您可以继续处理数据。当客户端重新连接时,您必须将更改与服务器同步。
Edit: As of 2020, Application Storage is deprecated. Look into ServiceWorkers instead.
编辑:自 2020 年起,不推荐使用应用程序存储。改为查看 ServiceWorkers。