{"id":6239,"date":"2017-06-27T23:22:22","date_gmt":"2017-06-27T15:22:22","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6239"},"modified":"2017-06-27T23:23:58","modified_gmt":"2017-06-27T15:23:58","slug":"how-electron-online-update-hot-fix","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2017\/06\/how-electron-online-update-hot-fix\/","title":{"rendered":"\u6211\u662f\u5982\u4f55\u5b9e\u73b0electron\u7684\u5728\u7ebf\u5347\u7ea7\u70ed\u66f4\u65b0\u529f\u80fd\u7684\uff1f"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6239\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6239<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u5f97\u5230\u539f\u4f5c\u8005\u4e66\u9762\u8bb8\u53ef\uff0c\u540c\u65f6\u4fdd\u7559\u539f\u4f5c\u8005\u548c\u51fa\u5904\uff0c\u6458\u8981\u5f15\u6d41\u5219\u968f\u610f\u3002<\/p>\n<p>\u901a\u5e38electron\u6253\u5305\u51fa\u6765\u7684\u6587\u4ef6\u90fd\u5f88\u5927\uff0c\u670940~50M\uff0c\u5982\u679c\u6bcf\u6b21\u6539\u52a8\u5347\u7ea7\u90fd\u8981\u4e0b\u8f7d\u4e2a\u5b8c\u6574\u7248\u672c\uff0c\u5b9e\u9645\u4e0a\u662f\u5f88\u70e6\u7684\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u53ea\u8981\u4e3b\u7ebf\u7a0b\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u6211\u4eec\u662f\u53ef\u4ee5\u76f4\u63a5\u5728\u7ebf\u70ed\u66f4\u65b0\u6211\u4eec\u7684electron\u5e94\u7528\u7684\u3002<\/p>\n<h3>\u4e00\u3001electron\u7684\u70ed\u66f4\u65b0\u6548\u679c\u9884\u89c8<\/h3>\n<p>\u4e0b\u9762\u51e0\u5f20\u56fe\u662f\u6211\u5b9e\u73b0\u7684\u5e26\u70ed\u66f4\u65b0\u529f\u80fd\u7684electron\u5e94\u7528\u5b9e\u9645\u6548\u679c\u622a\u56fe\uff1a<\/p>\n<p>\u6253\u5f00electron\u5e94\u7528\uff0c\u6b64\u65f6\u4f1a\u53bb\u68c0\u6d4b\u7ebf\u4e0a\u662f\u5426\u6709\u65b0\u7248\u672c\uff0c\u4f8b\u5982\uff0c\u6211\u672c\u5730\u7248\u672c\u662f1.2.2\uff0c\u7136\u540e\u7ebf\u4e0a\u7248\u672c\u662f1.2.4\uff0c\u5219\u4f1a\u6709\u8fd9\u6837\u7684\u663e\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/2017-06-27_215154.png\" width=\"304\" height=\"103\" alt=\"\u53ef\u5347\u7ea7\u63d0\u793a\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u70b9\u51fb\u201c\u65b0\u7248\u529f\u80fd\u201d\u4f1a\u663e\u793a\u6700\u65b0\u7248\u7684\u5347\u7ea7\u63cf\u8ff0\uff0c\u4f8b\u5982\uff0c\u8fd9\u91cc\u70b9\u51fb\u540e\u51fa\u73b0\u5f39\u6846\u4fe1\u606f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/2017-06-27_210008.png\" width=\"449\" height=\"249\" alt=\"\u65b0\u7248\u529f\u80fd\u5f39\u6846\u8bf4\u660e\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u70b9\u51fb\u7ea2\u8272\u7684\u201c\u5347\u7ea7\u201d\u6309\u94ae\uff0c\u5219\u76f4\u63a5\u8bf7\u6c42\u7ebf\u4e0a\u7684\u8d44\u6e90\u66ff\u6362\u672c\u5730\u8d44\u6e90\uff0c\u5b8c\u6210\u5347\u7ea7\uff08\u5347\u7ea7\u6210\u529f\u540e\u5237\u65b0\u9875\u9762\uff09\uff0c\u5347\u7ea7\u6548\u679c\u53c2\u89c1\u4e0bgif\u622a\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/electron-update-s.gif\" width=\"334\" height=\"80\" alt=\"\u5347\u7ea7\u6548\u679c\u5b9e\u65f6gif\u622a\u56fe\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<h3>\u4e8c\u3001electron\u7684\u70ed\u66f4\u65b0\u539f\u7406\u8bf4\u660e<\/h3>\n<p><strong>1. \u6211\u662f\u76f4\u63a5\u4f7f\u7528github\u4f5c\u4e3a\u7ebf\u4e0a\u8d44\u6e90\u4ed3\u50a8\u7684<\/strong><\/p>\n<p>\u5f53\u4f7f\u7528<code>raw.githubusercontent.com<\/code>\u4f5c\u4e3a\u8bf7\u6c42\u57df\u540d\uff0c\u6211\u4eec\u662f\u53ef\u4ee5\u76f4\u63a5\u83b7\u53d6\u8d44\u6e90\u5185\u5bb9\u7684\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u8981\u83b7\u53d6\u4e00\u4e2a\u8def\u5f84\u4e3a<code>js\/test.js<\/code>\u7684\u6587\u4ef6\uff0c\u5219\u8be5\u6587\u4ef6\u5b8c\u6574\u5730\u5740\u4e3a\uff1a<\/p>\n<pre>https:\/\/raw.githubusercontent.com\/username\/project-name\/master\/js\/test.js<\/pre>\n<p>\u6b64\u65f6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u4f7f\u7528node.js\u7684<code>https.get()<\/code>\u65b9\u6cd5\u83b7\u53d6\u8fd9\u4e2a<code>js\/test.js<\/code>\u5b8c\u6574\u5185\u5bb9\u4e86\u3002<\/p>\n<p><strong>2. \u6211\u662f\u501f\u52a9<code>package.json<\/code>\u6807\u8bb0\u7248\u672c\u548c\u66f4\u65b0\u5185\u5bb9\u7684<\/strong><\/p>\n<p>\u4e4b\u6240\u4ee5\u501f\u52a9<code>package.json<\/code>\uff0c\u4e3b\u8981\u662f\u88ab\u91cc\u9762\u7ea6\u5b9a\u4fd7\u6210\u7684<code>version<\/code>\u7248\u672c\u5173\u952e\u5b57\u5438\u5f15\uff0c\u5982\u679c\u7528\u6237\u672c\u5730<code>version<\/code>\u7248\u672c\u6bd4github\u9879\u76ee\u7ebf\u4e0a<code>version<\/code>\u7248\u672c\u4f4e\uff0c\u5c82\u4e0d\u5c31\u610f\u5473\u7740\u53ef\u4ee5\u8fdb\u884c\u5347\u7ea7\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u518d\u628a\u5347\u7ea7\u6587\u4ef6\u5217\u8868\u548c\u66f4\u65b0\u4fe1\u606f\u4e00\u6574\u5408\uff0c\u5c31\u6709\u4e86\u5b8c\u6574\u7684\u5347\u7ea7\u6570\u636e\u4e86\uff0c\u5982\u4e0b\u622a\u56fe\u793a\u610f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/2017-06-27_223020.png\" width=\"676\" height=\"546\" alt=\"\u5347\u7ea7\u63cf\u8ff0\u548c\u5347\u7ea7\u7248\u672c\u4fe1\u606f\u622a\u56fe\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p><strong>3. electron\u7684\u70ed\u66f4\u65b0\u539f\u7406\u8bf4\u660e<\/strong><\/p>\n<p>\u5f53\u6bcf\u6b21\u6211\u4eec\u7684electron\u52a0\u8f7d\u5b8c\u6bd5\u4e4b\u540e\uff0c\u5c31\u4f1a\u53d1\u9001\u4e00\u4e2a\u8bf7\u6c42\uff0c\u53bb\u83b7\u53d6github\u9879\u76ee\u4e0a\u7684<code>package.json<\/code>\u6587\u4ef6\uff0c\u4e3b\u8981\u662f\u77e5\u9053\u76ee\u524d\u7ebf\u4e0a\u7684\u7248\u672c\u662f\u591a\u5c11\uff0c\u7136\u540e\u548c\u672c\u5730\u7684<code>package.json<\/code>\u6587\u4ef6\u7684<code>version<\/code>\u7248\u672c\u6570\u636e\u505a\u6bd4\u8f83\u3002\u5982\u679c\u53d1\u73b0\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u5219\u8bf4\u660e\u6709\u65b0\u7248\u53ef\u4ee5\u5347\u7ea7\uff0c\u4e8e\u662f\u8ba9\u754c\u9762\u53d8\u6210\u8fd9\u6837\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/2017-06-27_215154.png\" width=\"304\" height=\"103\" alt=\"\u53ef\u5347\u7ea7\u63d0\u793a\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u5f53\u6211\u4eec\u70b9\u51fb\u201c\u5347\u7ea7\u201d\u6309\u94ae\u540e\uff0c\u4f1a\u628a\u9ad8\u4e8e\u672c\u5730\u7248\u672c\u7684\u9700\u8981\u66f4\u65b0\u7684\u6587\u4ef6\u91cd\u65b0\u6574\u5408\u6210\u4e00\u4e2a\u65b0\u7684\u5b8c\u6574\u7684\u5347\u7ea7\u6587\u4ef6\u5217\u8868\uff0c\u7136\u540e\u4f9d\u6b21\u4ecegithub\u4e0a\u8fdc\u7a0b\u83b7\u53d6\uff0c\u5b58\u50a8\u5728\u4e00\u4e2a\u4e34\u65f6\u6587\u4ef6\u5939\u4e2d\uff0c\u5982\u679c\u5168\u90e8\u6587\u4ef6\u83b7\u53d6\u6210\u529f\uff0c\u518d\u4e00\u5e76\u8986\u76d6\u672c\u5730\u8d44\u6e90\uff0c\u5168\u90e8\u8986\u76d6\u5b8c\u6210\u540e\uff0c\u5237\u65b0\u9875\u9762\uff0c\u5b8c\u6210\u5347\u7ea7\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b8c\u6574\u7684\u5347\u7ea7\u539f\u7406\u3002<\/p>\n<h3>\u4e09\u3001electron\u7684\u70ed\u66f4\u65b0\u4e00\u4e9b\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>electron\u70ed\u66f4\u65b0\u6700\u5927\u7684\u96be\u70b9\u5e94\u8be5\u662f\u5982\u4f55\u83b7\u53d6\u8fdc\u7a0b\u8d44\u6e90\uff0c\u6211\u7b80\u5355\u6574\u7406\u4e86\u4e0b\uff0c\u5e0c\u671b\u80fd\u591f\u5bf9\u6709\u9700\u6c42\u7684\u5c0f\u4f19\u4f34\u6709\u6240\u5e2e\u52a9\uff0c\u7531\u4e8eES6\u5e76\u672a\u82b1\u65f6\u95f4\u5b66\u4e60\uff0c\u56e0\u6b64\uff0c\u76f8\u5173JS\u8fd8\u662fES5\u8bed\u6cd5\uff1a<\/p>\n<pre>var https = require('https');\n\nvar getHttpsData = function (filepath, success, error) {\n  <span style=\"color:green;\">\/\/ \u56de\u8c03\u7f3a\u7701\u65f6\u5019\u7684\u5904\u7406<\/span>\n  success = success || function () {};\n  error = error || function () {};\n\n  var url = 'https:\/\/raw.githubusercontent.com\/username\/project-name\/master\/' + filepath + '?r=' + Math.random();\n\n  https.get(url, function (res) {\n    var statusCode = res.statusCode;\n\n    if (statusCode !== 200) {\n        <span style=\"color:green;\">\/\/ \u51fa\u9519\u56de\u8c03<\/span>\n        error();\n        <span style=\"color:green;\">\/\/ \u6d88\u8017\u54cd\u5e94\u6570\u636e\u4ee5\u91ca\u653e\u5185\u5b58<\/span>\n        res.resume();\n        return;\n    }\n\n    res.setEncoding('utf8');\n    var rawData = '';\n    res.on('data', function (chunk) {\n      rawData += chunk;\n    });\n\n    <span style=\"color:green;\">\/\/ \u8bf7\u6c42\u7ed3\u675f<\/span>\n    res.on('end', function () {\n      <span style=\"color:green;\">\/\/ \u6210\u529f\u56de\u8c03<\/span>\n      success(rawData);\n    }).on('error', function (e) {\n      <span style=\"color:green;\">\/\/ \u51fa\u9519\u56de\u8c03<\/span>\n      error();\n    });\n  });\n};<\/pre>\n<p>\u7136\u540e\uff0c\u4e0b\u9762\u7684\u4e8b\u60c5\u5c31\u7b80\u5355\u4e86\uff0c\u76f4\u63a5\u628a\u8bf7\u6c42\u7684\u6570\u636e\u5199\u5165\u672c\u5730\u5c31\u53ef\u4ee5\u4e86\uff0c\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u4e00\u4e2a<code>index.html<\/code>\u6587\u4ef6\uff1a<\/p>\n<pre>getHttpsData('index.html', function (data) {\n  <span style=\"color:green;\">\/\/ \u5199\u5165\u6587\u4ef6<\/span>\n  fs.writeFileSync('index.html', data);\n  <span style=\"color:green;\">\/\/ \u7136\u540e\u4e0b\u4e00\u4e2a\u6587\u4ef6\u83b7\u53d6\u5e76\u5199\u5165...<\/span>\n});<\/pre>\n<p>\u914d\u5408\u4e00\u4e9bloading\u4ea4\u4e92\u6548\u679c\uff0c\u5c31\u5b8c\u6210\u4e86\u5b8c\u6574\u7684\u5728\u7ebf\u70ed\u66f4\u65b0\u529f\u80fd\u3002<\/p>\n<h3>\u56db\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u4e0a\u5468\u516d\u7684\u4f5c\u4e3a\u5609\u5bbe\u53c2\u89c1\u4e86\u817e\u8baf2017 TFC\u524d\u7aef\u5927\u4f1a\uff0c\u5176\u4e2d\u4e0d\u5c11\u5206\u4eab\u4e3b\u9898\u5185\u5bb9\u5176\u5b9e\u662f\u4e0d\u9519\u7684\uff0c\u4f46\u662f\u6548\u679c\u5374\u4e00\u822c\u3002\u4e3b\u8981\u5728\u4e8e\u72af\u4e86\u4e0b\u9762\u51e0\u4e2a\u5927\u578b\u5206\u4eab\u5e38\u89c1\u9519\u8bef\uff1a<br \/>\n1. PPT\u6587\u5b57\u5c0f\u591a\uff0c\u653e\u7f6e\u5927\u6bb5\u7684\u4ee3\u7801\uff0c\u5728\u5927\u578b\u4f1a\u8bae\u573a\u5408\uff0c\u540e\u6392\u7684\u6839\u672c\u5c31\u770b\u4e0d\u5230\u5185\u5bb9\uff0c\u56e0\u6b64\uff0c\u53ea\u80fd\u73a9\u624b\u673a\uff0c\u8fd9\u548c\u5e73\u65f6\u5728\u56e2\u961f\u6216\u8005\u5b66\u9662\u5185\u5206\u4eab\u662f\u4e0d\u4e00\u6837\u7684\uff1b<br \/>\n2. \u5206\u4eab\u5185\u5bb9\u4e3a\u4e2d\u89c4\u4e2d\u77e9\u7684\u6d41\u6c34\u9648\u8ff0\uff0c\u5927\u578b\u5206\u4eab\u548c\u664b\u5347\u6c47\u62a5\u4e0d\u4e00\u6837\uff0c\u5e94\u8be5\u50cf\u7535\u5f71\u4e00\u6837\uff0c\u901a\u8fc7\u53ef\u4ee5\u5236\u9020\u51b2\u7a81\u548c\u5de7\u5999\u7684\u5185\u5bb9\u526a\u8f91\uff0c\u8ba9\u5206\u4eab\u66f4\u6709\u5438\u5f15\u529b\uff0c\u5426\u5219\u957f\u9014\u5954\u6ce2+\u65e9\u8d77\u7684\u542c\u4f17\u5f88\u5bb9\u6613\u6253\u778c\u7761\uff1b<br \/>\n3. \u4e00\u4e9b\u4e0d\u9002\u7528\u4e8e\u5927\u578b\u5206\u4eab\u7684\u5c0f\u6280\u5de7\uff0c\u4f8b\u5982\uff0c\u8bf7\u95ee\u5982\u4f55\u5982\u4f55\u8bf7\u4e3e\u624b\uff0c\u5982\u679c\u662f\u4e2d\u5c0f\u578b\u5206\u4eab\uff0c\u6216\u8005\u5f53\u524d\u6c1b\u56f4\u4e0d\u9519\uff0c\u8fd9\u4e9b\u6280\u5de7\u6709\u52a9\u4e8e\u589e\u52a0\u4e92\u52a8\uff0c\u4f46\u662f\u5728\u5982\u6b64\u5bbd\u5e7f\u7684\u573a\u5730\uff0c\u4ee5\u53ca\u5927\u591a\u4eba\u542c\u4f17\u4e0d\u662f\u5f88\u4e13\u6ce8\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u79cd\u7b56\u7565\u5c31\u7565\u663e\u5c34\u5c2c\uff0c\u56e0\u4e3a\u4e00\u4e2a\u95ee\u9898\u51fa\u6765\u4f1a\u6ca1\u6709\u9884\u60f3\u7684\u4e92\u52a8\u573a\u666f\u51fa\u73b0\u3002\u56e0\u6b64\u5c3d\u53ef\u80fd\u901a\u8fc7\u5355\u5411\u7684\u80a2\u4f53\uff0c\u8bed\u8c03\uff0c\u63aa\u8f9e\u4ee5\u53ca\u5e72\u8d27\u7684\u5185\u5bb9\u5c55\u793a\u81ea\u8eab\u98ce\u91c7\u624d\u662f\u4e0a\u7b56\u3002<\/p>\n<p>\u6700\u540e\uff0c\u5949\u4e0a\u5e05\u7167\u4e00\u5f20\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201706\/2017-06-27_231403.jpg\" width=\"266\" height=\"199\" class=\"alignnone\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6239\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6239<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u5e38electron\u6253\u5305\u51fa\u6765\u7684\u6587\u4ef6\u90fd\u5f88\u5927\uff0c\u670940~50M\uff0c\u5982\u679c\u6bcf\u6b21\u6539\u52a8\u5347\u7ea7\u90fd\u8981\u4e0b\u8f7d\u4e2a\u5b8c\u6574\u7248\u672c\uff0c\u5b9e\u9645\u4e0a\u662f\u5f88\u70e6\u7684\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u53ea\u8981\u4e3b\u7ebf\u7a0b\u6ca1\u6709\u53d1\u751f\u53d8\u5316\uff0c\u6211\u4eec\u662f\u53ef\u4ee5\u76f4\u63a5\u5728\u7ebf\u70ed\u66f4\u65b0\u6211\u4eec\u7684electron\u5e94\u7528\u7684\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1127,778,1100,773,1142],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6239"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=6239"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6239\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}