{"id":41589,"date":"2023-10-04T02:31:03","date_gmt":"2023-10-03T18:31:03","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=41589"},"modified":"2023-10-04T02:31:03","modified_gmt":"2023-10-03T18:31:03","slug":"eydhydkm","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/41589.html","title":{"rendered":"Electron\u4e00\u5b9a\u4f1a\u6709\u7aef\u53e3\u5417\uff1f"},"content":{"rendered":"
Electron\u662f\u4e00\u79cd\u5f00\u6e90\u3001\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u7528HTML\u3001CSS\u548cJavaScript\u7f16\u5199\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u7684\u51fa\u73b0\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u4e00\u6b3e\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u662f\u5b83\u662f\u5426\u4f1a\u6709\u7aef\u53e3\uff1f\u672c\u6587\u5c06\u4e3a\u60a8\u6df1\u5165\u89e3\u6790Electron\u662f\u5426\u4f1a\u6709\u7aef\u53e3\uff0c\u5e76\u4ecb\u7ecd\u5982\u4f55\u5728Electron\u4e2d\u4f7f\u7528\u7aef\u53e3\u3002<\/p>\n
\u7aef\u53e3\u662f\u8ba1\u7b97\u673a\u7f51\u7edc\u4e2d\u7684\u4e00\u79cd\u903b\u8f91\u63a5\u53e3\uff0c\u5b83\u7528\u4e8e\u6807\u8bc6\u4e0d\u540c\u7684\u7f51\u7edc\u670d\u52a1\u548c\u5e94\u7528\u7a0b\u5e8f\u3002\u7aef\u53e3\u662f\u4e00\u4e2a16\u4f4d\u7684\u65e0\u7b26\u53f7\u6574\u6570\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u6807\u8bc6\u4e00\u4e2a\u7a0b\u5e8f\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\uff0c\u6216\u8005\u7528\u6765\u4e0e\u53e6\u4e00\u53f0\u8ba1\u7b97\u673a\u8fdb\u884c\u901a\u4fe1\u3002\u7aef\u53e3\u53f7\u7684\u8303\u56f4\u662f0-65535\uff0c\u5176\u4e2d0-1023\u4e3a\u7cfb\u7edf\u4fdd\u7559\u7aef\u53e3\uff0c\u4e00\u822c\u4e0d\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n
\u7b54\u6848\u662f\u80af\u5b9a\u7684\uff0cElectron\u4f1a\u6709\u7aef\u53e3\u3002\u7531\u4e8eElectron\u662f\u4e00\u79cd\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\uff0c\u6240\u4ee5\u5b83\u4f1a\u6709\u7aef\u53e3\u3002\u7531\u4e8eElectron\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f\uff0c\u6240\u4ee5\u5b83\u4e5f\u4f1a\u6709\u7aef\u53e3\u3002<\/p>\n
\u5728Electron\u4e2d\u4f7f\u7528\u7aef\u53e3\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u7684main.js\u6587\u4ef6\u4e2d\u8c03\u7528electron.net\u6a21\u5757\u5373\u53ef\u3002electron.net\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684API\uff0c\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u548c\u4f7f\u7528\u7aef\u53e3\u3002<\/p>\n
\u8981\u5728Electron\u4e2d\u521b\u5efa\u7aef\u53e3\uff0c\u9996\u5148\u9700\u8981\u4f7f\u7528electron.net\u6a21\u5757\u7684createServer()\u51fd\u6570\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u56de\u8c03\u51fd\u6570\u4f1a\u5728\u7aef\u53e3\u521b\u5efa\u6210\u529f\u540e\u88ab\u8c03\u7528\uff0c\u5e76\u4f20\u5165\u4e00\u4e2aServer\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u5bf9\u8c61\u53ef\u4ee5\u7528\u6765\u64cd\u4f5c\u7aef\u53e3\u3002<\/p>\n
\u4e00\u65e6\u7aef\u53e3\u521b\u5efa\u6210\u529f\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Server\u5bf9\u8c61\u7684listen()\u51fd\u6570\u6765\u76d1\u542c\u8be5\u7aef\u53e3\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u7aef\u53e3\u53f7\u4f5c\u4e3a\u53c2\u6570\uff0c\u7528\u6765\u6307\u5b9a\u8981\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002listen()\u51fd\u6570\u8fd8\u63a5\u53d7\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u56de\u8c03\u51fd\u6570\u4f1a\u5728\u7aef\u53e3\u76d1\u542c\u6210\u529f\u540e\u88ab\u8c03\u7528\uff0c\u5e76\u4f20\u5165\u4e00\u4e2aSocket\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u5bf9\u8c61\u53ef\u4ee5\u7528\u6765\u64cd\u4f5c\u7aef\u53e3\u3002<\/p>\n
\u4e00\u65e6\u7aef\u53e3\u76d1\u542c\u6210\u529f\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Server\u5bf9\u8c61\u7684accept()\u51fd\u6570\u6765\u63a5\u53d7\u8fde\u63a5\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u56de\u8c03\u51fd\u6570\u4f1a\u5728\u63a5\u53d7\u8fde\u63a5\u6210\u529f\u540e\u88ab\u8c03\u7528\uff0c\u5e76\u4f20\u5165\u4e00\u4e2aSocket\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u8be5\u5bf9\u8c61\u53ef\u4ee5\u7528\u6765\u64cd\u4f5c\u7aef\u53e3\u3002<\/p>\n
\u672c\u6587\u4ecb\u7ecd\u4e86Electron\u662f\u5426\u4f1a\u6709\u7aef\u53e3\uff0c\u4ee5\u53ca\u5982\u4f55\u5728Electron\u4e2d\u4f7f\u7528\u7aef\u53e3\u3002Electron\u4f1a\u6709\u7aef\u53e3\uff0c\u53ea\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u7684main.js\u6587\u4ef6\u4e2d\u8c03\u7528electron.net\u6a21\u5757\uff0c\u7136\u540e\u4f7f\u7528createServer()\u3001listen()\u548caccept()\u51fd\u6570\u5373\u53ef\u521b\u5efa\u548c\u4f7f\u7528\u7aef\u53e3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Electron\u662f\u4e00\u79cd\u5f00\u6e90\u3001\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u7528HTML\u3001CSS\u548cJavaScript\u7f16\u5199\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u7684\u51fa\u73b0\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u4e00\u6b3e\u8de8<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305],"class_list":["post-41589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/41589"}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=41589"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/41589\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=41589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=41589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=41589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}