{"id":41803,"date":"2023-09-30T04:53:56","date_gmt":"2023-09-29T20:53:56","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=41803"},"modified":"2023-09-30T04:53:56","modified_gmt":"2023-09-29T20:53:56","slug":"erndyygyxl","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/41803.html","title":{"rendered":"Electron LoadFile\uff1a\u8ba9\u4f60\u7684\u5e94\u7528\u66f4\u6709\u6548\u7387"},"content":{"rendered":"
Electron LoadFile\u662f\u4e00\u6b3e\u57fa\u4e8eElectron\u7684\u6587\u4ef6\u52a0\u8f7d\u5e93\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u6709\u6548\u5730\u52a0\u8f7d\u672c\u5730\u6587\u4ef6\uff0c\u4ece\u800c\u66f4\u5feb\u5730\u5b8c\u6210\u5e94\u7528\u7684\u5f00\u53d1\u3002<\/strong>\u5b83\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f\uff0c\u5305\u62ec\u56fe\u7247\u3001\u6587\u672c\u6587\u4ef6\u3001\u89c6\u9891\u6587\u4ef6\u7b49\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u51fa\u529f\u80fd\u5f3a\u5927\u7684\u5e94\u7528\u3002<\/p>\n Electron LoadFile\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f\uff0c\u5305\u62ec\u56fe\u7247\u3001\u6587\u672c\u6587\u4ef6\u3001\u89c6\u9891\u6587\u4ef6\u7b49\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u51fa\u529f\u80fd\u5f3a\u5927\u7684\u5e94\u7528\u3002<\/p>\n Electron LoadFile\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u52a0\u8f7d\u672c\u5730\u6587\u4ef6\uff0c\u4ece\u800c\u5927\u5927\u63d0\u9ad8\u5e94\u7528\u5f00\u53d1\u6548\u7387\u3002\u5b83\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u5b8c\u6210\u5e94\u7528\u7684\u5f00\u53d1\uff0c\u4ece\u800c\u8282\u7701\u65f6\u95f4\u548c\u6210\u672c\u3002<\/p>\n Electron LoadFile\u652f\u6301\u8de8\u5e73\u53f0\uff0c\u53ef\u4ee5\u5728\u591a\u79cd\u5e73\u53f0\u4e0a\u8fd0\u884c\uff0c\u5305\u62ecWindows\u3001macOS\u3001Linux\u7b49\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8f7b\u677e\u6784\u5efa\u51fa\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u3002<\/p>\n \u5728\u4f7f\u7528Electron LoadFile\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\uff0c\u53ef\u4ee5\u4f7f\u7528npm\u6216\u8005yarn\u6765\u5b89\u88c5\uff1a<\/p>\n yarn add electron-loadfile<\/p><\/code><\/pre>\n \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Electron LoadFile\u6765\u52a0\u8f7d\u6587\u4ef6\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n loadFile('path\/to\/file').then(data => {<\/p> \/\/ do something with data<\/p> });<\/p><\/code><\/pre>\n \u52a0\u8f7d\u6587\u4ef6\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684API\u6765\u5904\u7406\u6587\u4ef6\uff0c\u6bd4\u5982\u89e3\u6790\u6587\u4ef6\u3001\u4fee\u6539\u6587\u4ef6\u7b49\uff0c\u4ece\u800c\u8fbe\u5230\u5e94\u7528\u7684\u76ee\u7684\u3002<\/p>\n Electron LoadFile\u662f\u4e00\u6b3e\u57fa\u4e8eElectron\u7684\u6587\u4ef6\u52a0\u8f7d\u5e93\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u6709\u6548\u5730\u52a0\u8f7d\u672c\u5730\u6587\u4ef6\uff0c\u4ece\u800c\u66f4\u5feb\u5730\u5b8c\u6210\u5e94\u7528\u7684\u5f00\u53d1\u3002<\/strong>\u5b83\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u66f4\u5feb\u5730\u5b8c\u6210\u5e94\u7528\u7684\u5f00\u53d1\uff0c\u4ece\u800c\u8282\u7701\u65f6\u95f4\u548c\u6210\u672c\u3002\u5b83\u8fd8\u652f\u6301\u8de8\u5e73\u53f0\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8f7b\u677e\u6784\u5efa\u51fa\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" ElectronLoadFile\u662f\u4e00\u6b3e\u57fa\u4e8eElectron\u7684\u6587\u4ef6\u52a0\u8f7d\u5e93\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u6709\u6548\u5730\u52a0\u8f7d\u672c\u5730\u6587\u4ef6\uff0c\u4ece\u800c\u66f4\u5feb\u5730\u5b8c\u6210\u5e94\u7528\u7684\u5f00\u53d1\u3002<\/strong\n<\/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-41803","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\/41803","targetHints":{"allow":["GET"]}}],"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=41803"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/41803\/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=41803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=41803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=41803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Electron LoadFile\u7684\u4f18\u52bf<\/h2>\n
\u652f\u6301\u591a\u79cd\u6587\u4ef6\u683c\u5f0f<\/h3>\n
\u5feb\u901f\u52a0\u8f7d\u672c\u5730\u6587\u4ef6<\/h3>\n
\u652f\u6301\u8de8\u5e73\u53f0<\/h3>\n
\u5982\u4f55\u4f7f\u7528Electron LoadFile<\/h2>\n
\u5b89\u88c5Electron LoadFile<\/h3>\n
npm install electron-loadfile
\u52a0\u8f7d\u6587\u4ef6<\/h3>\n
const { loadFile } = require('electron-loadfile');
\u5904\u7406\u6587\u4ef6<\/h3>\n
\u603b\u7ed3<\/h2>\n