Progressive Web application is a progressive web app launched by Google that uses Service-worker to achieve similar native apps and can be added to the home page in Chrome, completely like an app. To be honest, I think that PWA is a good development direction, although the small program for a period of time tepid, but the limitations of PWA less, but also Google support, but now some browsers may not support very good.
Domestic hungry did a time ago to do a PWA, I think it is very good https://h5.ele.me/msite/.
I think the use of the native app is closer, and there's no need to install it.
Pull a bit more, today is mainly about how to do a PWA. Of course, I am also a novice, and my PWA is based on Google's PWA sample to make some improvements. Google Now a lot of developer documentation has been translated, sample is mainly a weather application, the concrete implementation of the logic I will not talk about, I say the following how to deploy this PWA.
In Google's sample is recommended to use Firebase to deploy your PWA, but because of the domestic wall, Firebase init at the time always authentication Error,stackoverflow said that is the reason for the agent, But no proxy and no way to use firebase, so this is a dead loop. But!! We have GitHub Page,github page is a good way to show static pages, previously can only support the content of the render GH branch, now GitHub for GitHub page feature has been perfected, detailed can see this article http:// blog.csdn.net/neal1991/article/details/53535914.
Follow me here:
1. Enter Https://github.com/neal1991/pwa can fork or clone this project, I have some things inside, get rid of, can run directly.
2. Enter the settings inside the set
Now you get into the https://yourusername.github.io/your-reporistry-name/and you can start, isn't it soon.
And then I want to talk about some of the improvements I've made in this project, because this weather PWA uses an API from Yahoo, and by using Woeid, you can query the weather and related information in each city. But there is no Chinese cities on the digital Code, note is wepid code, I later found that http://www.imeihua.net/tool/weathercode.aspx this site is can query Wepid, originally wanted to write a crawler crawl, But this site seems to do what limits, I use the curl simulation under the request, restrict access to this website to use. NET implementation of the. NET's Web request always contains some strange attributes. Later I found a foreign site, very convenient, direct GET request can get http://woeid.rosselliot.co.nz/lookup, so I wrote a crawler to crawl, source code in https://github.com/ Neal1991/woeid-parser
Core code
varRequest =require(' superagent ');varFS =require(' FS ');varCityconfig = [' Wuhu ',' Shanghai ',' Beijing ',' Hangzhou ',' Nanjing ',' Wuxi ',' Xiamen ',' Longyan '];varCheerio =require(' Cheerio ');varURL =' http://woeid.rosselliot.co.nz/lookup/';varAttrnames = [' City ',' province ',' Country ',' Woeid '];varresult = [];cityconfig.foreach ( function(city) {Request.get (url + city). End ( function(err, res) {$ = cheerio.load (Res.text); $(' #woeid_results_table tr '). each ( function(i, ele) { varobj = {}; $ = cheerio.load (ele); $(' TD '). each ( function(index, TD) {Obj[attrnames[index]] = $ ( This). text (); }) Result.push (obj); });varIsEmpty = function(object) { for(varKeyinchObject) {return false; }return true; } result = Result.filter ( function(obj) { returnObj.country = = =' China '&&!isempty (obj); }) Fs.writefile (' Result.json ',JSON. Stringify (Result,NULL,"\ T")); })});
Mainly use the superagent and cheerio these two packages, one is used to send the request, the other is used to parse the HTML, the city name needs an English city name, I here is config to configure, and then the results are filtered to save the file in JSON format.
This provides our Chinese city wepid data source, of course, I have not yet done to read the JSON to get the data, or to write these wepid dead in weather PWA.
For weather PWA I also added the ability to delete a city because it could only be added to the city, there is no way to delete the city, there may be some small bugs. Access Address:
https://neal1991.github.io/pwa/
Above, is my first time progressive Web application, you crossing, if think my content writes also can, must give my GitHub repository star to encourage!!!
The first progressive Web application, the departure!