如何使用Google App脚本开发Progressive Web App

如何使用Google App脚本开发Progressive Web App

问题描述:

我用Google应用程序脚本开发了一些应用程序,并将它们部署为可以正常运行的Web应用程序.然后,我决定将它们转换为PWA.原因是使它们可安装在智能手机用户的主屏幕上,从而能够使用推送通知,缓存等(简而言之,PWA提供的所有优势.)

I developed a few appllications with google app script and deployed them as Web apps they are all working fine.Then I decided to convert them to PWA's.The reason was to make them installable on smart phone User's Home Screen, being able to use push notifications, cacheing e.t.c. (All the advantages that PWA's offer in short.)

我开始学习PWA.结果我得出一个结论,我需要一个浏览器dowload的maifest.json文件,一个再次浏览并下载并运行的service-worker.js文件.

I started learning about PWA's. As a result I came to a conclusion that I need a maifest.json file that browsers dowload , a service-worker.js that again browswers download and run.

不幸的是,应用程序脚本开发环境不允许添加带有* .json和* .js扩展名的文件.

Unfortunately, app script development environment does not allow to add files with *.json and *.js extensions.

那么,这是否意味着我无法将Google应用程序脚本网络应用程序转换为PWA?

So, does that mean I can't convert my google app script web apps to PWA's?

谢谢.

理论上的解决方案是将内联文件包括在内,以某种方式用于清单(取自

A theoretical solution would be include the files inline, somehow like this for the manifest (taken from this answer)

<link rel="manifest" href='data:application/manifest+json,{ "name": "theName", "short_name": "shortName", "description": "theDescription"}' />

,对于服务人员,仅直接包含标签;但服务工作者本质上必须独立于页面(请参阅此处).

and for the service workers just including directly the tag; but service workers must be by nature independent from the page (see here).

因此,我们可以尝试通过doGet(e)为他们提供服务.但遗憾的是,由于您需要外部获取服务工作人员,因此目前无法实现,但是已将外部获取从服务工作人员中移除

So we could try to serve them through doGet(e). BUT unfortunately is not possible at current time, since you'd need to foreign fetch the service worker, but Foreign Fetch has been removed from Service Workers see this other reply for more details