{"id":128,"date":"2016-07-23T18:00:15","date_gmt":"2016-07-23T10:00:15","guid":{"rendered":"http:\/\/xlight.me\/blog\/?p=128"},"modified":"2023-05-29T09:46:11","modified_gmt":"2023-05-29T01:46:11","slug":"phonegap-html5-webapp-auto-update","status":"publish","type":"post","link":"https:\/\/xlight.me\/blog\/2016\/07\/phonegap-html5-webapp-auto-update\/","title":{"rendered":"phonegap html5 webapp \u514d\u5e72\u9884\u81ea\u52a8\u66f4\u65b0"},"content":{"rendered":"<h4>\u514d\u66f4\u65b0\u5fc5\u8981\u6761\u4ef6<\/h4>\n<p>1. \u5728app\u672c\u5730\u5b58\u50a8\u6700\u65b0\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90\uff08\u56fe\u7247\u3001\u58f0\u97f3\uff09<br \/>\n2. \u53ef\u4ee5\u5728js\u3001html\u4e2d\u8c03\u7528\u5b58\u50a8\u5728app\u672c\u5730\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90<br \/>\n3. \u53ef\u4ee5\u7528js\u66f4\u65b0app\u672c\u5730\u5b58\u50a8\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90<\/p>\n<h4>\u76ee\u524dapp\u7684\u73b0\u72b6<\/h4>\n<p>APK\u4e2d\u5168\u90e8\u662f\u9759\u6001\u6587\u4ef6\uff0creadonly\uff0c\u66f4\u65b0\u4e0d\u80fd\uff0c\u53ea\u6709update APK\u624d\u53ef\u66f4\u65b0\u3002<\/p>\n<h4>\u53ef\u7528\u7684\u5b58\u50a8<\/h4>\n<p>1. browser cache<br \/>\n2. offline manifest<br \/>\n3. localStorage<br \/>\n4. webSQL<\/p>\n<h4>\u76ee\u524d\u7684\u5404\u79cd\u8d44\u6e90\u5982\u4f55\u5b58\u50a8\u5230\u672c\u5730<\/h4>\n<p>1. js<br \/>\n2. css<br \/>\n3. image<br \/>\n4. sound<\/p>\n<h4>DataURI<\/h4>\n<p>http:\/\/en.wikipedia.org\/wiki\/Data_URI_scheme<sup><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.okooo.net\/images\/icons\/linkext7.gif\" alt=\"\" width=\"7\" height=\"7\" align=\"absmiddle\" border=\"0\" \/><\/sup><\/p>\n<h4>\u5982\u4f55\u8c03\u7528\u5b58\u50a8\u5728\u672c\u5730\u7684\u8d44\u6e90<\/h4>\n<p>1. get js and css from Storage<br \/>\n2. eval js<br \/>\n3. append css style to DOM<\/p>\n<h4>How to update<\/h4>\n<p>1. \u4f7f\u7528ajax \u53bbfetch js \u548c css<br \/>\n2. \u5b58\u5165Storage<\/p>\n<h4>How to determine to update<\/h4>\n<p>1. index.html\u542f\u52a8\u65f6\u8bf7\u6c42\u8fdc\u7a0bgetVersion\uff0c<br \/>\n2. \u4e0e\u672c\u5730\u7684js\u6587\u4ef6\u4e2d\u7684Version\u5bf9\u6bd4\uff0c\u5982\u679c\u4e0d\u540c\u5219\u66f4\u65b0<br \/>\n3. \u66f4\u65b0\u5b8c\u6210\u540e\u63d0\u793a\u7528\u6237\u91cd\u65b0\u5f15\u5bfcapp\uff08refresh index.html\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u514d\u66f4\u65b0\u5fc5\u8981\u6761\u4ef6 1. \u5728app\u672c\u5730\u5b58\u50a8\u6700\u65b0\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90\uff08\u56fe\u7247\u3001\u58f0\u97f3\uff09 2. \u53ef\u4ee5\u5728js\u3001html\u4e2d\u8c03\u7528\u5b58\u50a8\u5728app\u672c\u5730\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90 3. \u53ef\u4ee5\u7528js\u66f4\u65b0app\u672c\u5730\u5b58\u50a8\u7684\u7a0b\u5e8f\u3001\u8d44\u6e90 \u76ee\u524dapp\u7684\u73b0\u72b6 APK\u4e2d\u5168\u90e8\u662f\u9759\u6001\u6587\u4ef6\uff0creadonly\uff0c\u66f4\u65b0\u4e0d\u80fd\uff0c\u53ea\u6709update APK\u624d\u53ef\u66f4\u65b0\u3002 \u53ef\u7528\u7684\u5b58\u50a8 1. browser cache 2. offline manifest 3. localStorage 4. webSQL \u76ee\u524d\u7684\u5404\u79cd\u8d44\u6e90\u5982\u4f55\u5b58\u50a8\u5230\u672c\u5730 1. js 2. css 3. image 4. sound DataURI http:\/\/en.wikipedia.org\/wiki\/Data_URI_scheme \u5982\u4f55\u8c03\u7528\u5b58\u50a8\u5728\u672c\u5730\u7684\u8d44\u6e90 1. get js and css from Storage 2. eval js 3. append css style to DOM How to update 1. \u4f7f\u7528ajax \u53bbfetch&#8230; <\/p>\n<div class=\"read-more\"><a href=\"https:\/\/xlight.me\/blog\/2016\/07\/phonegap-html5-webapp-auto-update\/\">Read More<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":10,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":860,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions\/860"}],"wp:attachment":[{"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlight.me\/blog\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}